Вход Регистрация
Файл: public/js/ips.embedded.js
Строк: 100
<?php
/**
 * Embed IP.Board via iFrame
 * Using old school JS, none of your fancy stuffs!
 *
 * (c) 2011 Invision Power Services, Inc.
 * By Matt Mecham
 */

var _idx window.IPBoard;

_idx.prototype.embedded = {
    
curHeightnull,
    
remoteMsgnull,
    
inFrame:   ( top !== self ) ? true false,
    
ajaxIsLoadingnull,
    
    
init: function()
    {
        if ( 
this.inFrame )
        {
            
/* We need to do two things: set up a setLocation and setMessage functions
             * if we have everything > IE7 this is easy, see...
             * So lets pretent IE7 does NOT exist.
             */
            
if ( 'postMessage' in parent )
            {
                
this.setMessage = function( messagetarget )
                {
                    
Debug.write("SENDING msg: " message " to " target );
                    return 
parent.postMessagemessagetarget );
                };
                
                
this.setLocation = function( newLocation )
                {
                    
Debug.write"Setting location to " newLocation );
                    
parent.window.frames[0].location.replacenewLocation );
                };
                
                
this.setHeight = function()
                {
                    var 
newHeight document.body.offsetHeight;
                    
                    if ( 
newHeight != this.curHeight )
                    {
                        
this.curHeight newHeight;
                        
                        
this.setMessage('height:' this.curHeight'*');
                    }
                };
                
                
this.checkAjaxStatus = function()
                {
                    if ( $(
'ajax_loading') )
                    {
                        if ( $(
'ajax_loading').visible() )
                        {
                            
this.ajaxIsLoading true;
                            
this.setMessage'ajaxLoading''*' );
                        }
                        else if ( 
this.ajaxIsLoading && ! $('ajax_loading').visible() )
                        {
                            
this.ajaxIsLoading false;
                            
this.setMessage'ajaxDone''*' );
                        }
                    }
                }
                
                
this.aClicked = function( eelem )
                {
                    
href   elem.readAttribute('href');
                    
rel    '';
                    
target '';
                    
                    try
                    {
                        
rel    elem.readAttribute('rel');
                        
target elem.readAttribute('target');
                    } catch(
e){}
                    
                    if ( ( 
href.substr(04) == 'http' ) && rel != 'external' && target != '_blank' )
                    {
                        
                        
/* One last check */
                        
if ( ipb.vars['board_url'] == href.substr0ipb.vars['board_url'].length ) )
                        {
                            
Event.stop(e);
                            var 
path      href.substripb.vars['board_url'].length );
                            var 
hashIndex path.indexOf('#');
                            var 
hash      '';
                            
                            if ( 
hashIndex > -)
                            {
                               
hash path.substrhashIndex );
                               
path path.substr0hashIndex );
                            }
                            
                            
ipb.embedded.setMessage('location:' path'*');
                            
ipb.embedded.setLocationipb.vars['board_url'] + path hash );
                        }
                    }
                    
                    return 
true;
                };
                
                
/* Intercept a links */
                
ipb.delegate.register"a"this.aClicked );
                
                
/* Routintely check height */
                
setIntervalthis.setHeight.bindAsEventListener(this), 300 );
                
                
/* And ajax status */
                
setIntervalthis.checkAjaxStatus.bindAsEventListener(this), 300 );
                
                
Event.observedocument'unload', function() { this.setMessage('unload''*').bindAsEventListener(this); } );
            }
        }
    }
};

ipb.embedded.init();
?>
Онлайн: 1
Реклама