Вход Регистрация
Файл: wordpress/wp-includes/js/admin-bar.js
Строк: 520
<?php
/* jshint loopfunc: true */
// use jQuery and hoverIntent if loaded
if ( typeof(jQuery) != 'undefined' ) {
    if ( 
typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
        
/* jshint ignore:start */
        // hoverIntent v1.8.1 - Copy of wp-includes/js/hoverIntent.min.js
        
!function(a){a.fn.hoverIntent=function(b,c,d){var e={interval:100,sensitivity:6,timeout:0};e="object"==typeof b?a.extend(e,b):a.isFunction(c)?a.extend(e,{over:b,out:c,selector:d}):a.extend(e,{over:b,out:b,selector:c});var f,g,h,i,j=function(a){f=a.pageX,g=a.pageY},k=function(b,c){return c.hoverIntent_t=clearTimeout(c.hoverIntent_t),Math.sqrt((h-f)*(h-f)+(i-g)*(i-g))<e.sensitivity?(a(c).off("mousemove.hoverIntent",j),c.hoverIntent_s=!0,e.over.apply(c,[b])):(h=f,i=g,c.hoverIntent_t=setTimeout(function(){k(b,c)},e.interval),void 0)},l=function(a,b){return b.hoverIntent_t=clearTimeout(b.hoverIntent_t),b.hoverIntent_s=!1,e.out.apply(b,[a])},m=function(b){var c=a.extend({},b),d=this;d.hoverIntent_t&&(d.hoverIntent_t=clearTimeout(d.hoverIntent_t)),"mouseenter"===b.type?(h=c.pageX,i=c.pageY,a(d).on("mousemove.hoverIntent",j),d.hoverIntent_s||(d.hoverIntent_t=setTimeout(function(){k(c,d)},e.interval))):(a(d).off("mousemove.hoverIntent",j),d.hoverIntent_s&&(d.hoverIntent_t=setTimeout(function(){l(c,d)},e.timeout)))};return this.on({"mouseenter.hoverIntent":m,"mouseleave.hoverIntent":m},e.selector)}}(jQuery);
        
/* jshint ignore:end */
    
}
    
jQuery(document).ready(function($){
        var 
adminbar = $('#wpadminbar'), refreshtouchOpentouchClosedisableHoverIntent false;

        
refresh = function(iel){ // force the browser to refresh the tabbing index
            
var node = $(el), tab node.attr('tabindex');
            if ( 
tab )
                
node.attr('tabindex''0').attr('tabindex'tab);
        };

        
touchOpen = function(unbind) {
            
adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) {
                var 
el = $(this);

                if ( 
el.parent().is('#wp-admin-bar-root-default') && !el.hasClass('hover') ) {
                    
e.preventDefault();
                    
adminbar.find('li.menupop.hover').removeClass('hover');
                    
el.addClass('hover');
                } else if ( !
el.hasClass('hover') ) {
                    
e.stopPropagation();
                    
e.preventDefault();
                    
el.addClass('hover');
                }

                if ( 
unbind ) {
                    $(
'li.menupop').off('click.wp-mobile-hover');
                    
disableHoverIntent false;
                }
            });
        };

        
touchClose = function() {
            var 
mobileEvent = /Mobile/.+Safari/.test(navigator.userAgent) ? 'touchstart' 'click';
            
// close any open drop-downs when the click/touch is not on the toolbar
            
$(document.body).onmobileEvent+'.wp-mobile-hover', function(e) {
                if ( !$(
e.target).closest('#wpadminbar').length )
                    
adminbar.find('li.menupop.hover').removeClass('hover');
            });
        };

        
adminbar.removeClass('nojq').removeClass('nojs');

        if ( 
'ontouchstart' in window ) {
            
adminbar.on('touchstart', function(){
                
touchOpen(true);
                
disableHoverIntent true;
            });
            
touchClose();
        } else if ( /
IEMobile/[1-9]/.test(navigator.userAgent) ) {
            
touchOpen();
            
touchClose();
        }

        
adminbar.find('li.menupop').hoverIntent({
            
over: function() {
                if ( 
disableHoverIntent )
                    return;

                $(
this).addClass('hover');
            },
            
out: function() {
                if ( 
disableHoverIntent )
                    return;

                $(
this).removeClass('hover');
            },
            
timeout180,
            
sensitivity7,
            
interval100
        
});

        if ( 
window.location.hash )
            
window.scrollBy0, -32 );

        $(
'#wp-admin-bar-get-shortlink').click(function(e){
            
e.preventDefault();
            $(
this).addClass('selected').children('.shortlink-input').blur(function(){
                $(
this).parents('#wp-admin-bar-get-shortlink').removeClass('selected');
            }).
focus().select();
        });

        $(
'#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){
            if ( 
e.which != 13 )
                return;

            var 
target = $(e.target),
                
wrap target.closest('.ab-sub-wrapper'),
                
parentHasHover target.parent().hasClass('hover');

            
e.stopPropagation();
            
e.preventDefault();

            if ( !
wrap.length )
                
wrap = $('#wpadminbar .quicklinks');

            
wrap.find('.menupop').removeClass('hover');

            if ( ! 
parentHasHover ) {
                
target.parent().toggleClass('hover');
            }

            
target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
        }).
each(refresh);

        $(
'#wpadminbar .ab-item').bind('keydown.adminbar', function(e){
            if ( 
e.which != 27 )
                return;

            var 
target = $(e.target);

            
e.stopPropagation();
            
e.preventDefault();

            
target.closest('.hover').removeClass('hover').children('.ab-item').focus();
            
target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
        });

        $(
'#wpadminbar').click( function(e) {
            if ( 
e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' )
                return;

            
e.preventDefault();
            $(
'html, body').animate({ scrollTop}, 'fast');
        });

        
// fix focus bug in WebKit
        
$('.screen-reader-shortcut').keydown( function(e) {
            var 
idua;

            if ( 
13 != e.which )
                return;

            
id = $( this ).attr'href' );

            
ua navigator.userAgent.toLowerCase();

            if ( 
ua.indexOf('applewebkit') != -&& id && id.charAt(0) == '#' ) {
                
setTimeout(function () {
                    $(
id).focus();
                }, 
100);
            }
        });

        $( 
'#adminbar-search' ).on({
            
focus: function() {
                $( 
'#adminbarsearch' ).addClass'adminbar-focused' );
            }, 
blur: function() {
                $( 
'#adminbarsearch' ).removeClass'adminbar-focused' );
            }
        } );

        
// Empty sessionStorage on logging out
        
if ( 'sessionStorage' in window ) {
            $(
'#wp-admin-bar-logout a').click( function() {
                try {
                    for ( var 
key in sessionStorage ) {
                        if ( 
key.indexOf('wp-autosave-') != -)
                            
sessionStorage.removeItem(key);
                    }
                } catch(
e) {}
            });
        }

        if ( 
navigator.userAgent && document.body.className.indexOf'no-font-face' ) === -&&
            /
Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.testnavigator.userAgent ) ) {

            
document.body.className += ' no-font-face';
        }
    });
} else {
    (function(
dw) {
        var 
addEvent = function( objtypefn ) {
            if ( 
obj.addEventListener )
                
obj.addEventListener(typefnfalse);
            else if ( 
obj.attachEvent )
                
obj.attachEvent('on' type, function() { return fn.call(objwindow.event);});
        },

        
aBhc = new RegExp('\bhover\b''g'), = [],
        
rselected = new RegExp('\bselected\b''g'),

        
/**
         * Get the timeout ID of the given element
         */
        
getTOID = function(el) {
            var 
q.length;
            while ( 
i-- ) {
                if ( 
q[i] && el == q[i][1] )
                    return 
q[i][0];
            }
            return 
false;
        },

        
addHoverClass = function(t) {
            var 
iidinAhoveringulli,
                
ancestors = [],
                
ancestorLength 0;

            while ( 
&& != aB && != ) {
                if ( 
'LI' == t.nodeName.toUpperCase() ) {
                    
ancestorsancestors.length ] = t;
                    
id getTOID(t);
                    if ( 
id )
                        
clearTimeoutid );
                    
t.className t.className ? ( t.className.replace(hc'') + ' hover' ) : 'hover';
                    
hovering t;
                }
                
t.parentNode;
            }

            
// Remove any selected classes.
            
if ( hovering && hovering.parentNode ) {
                
ul hovering.parentNode;
                if ( 
ul && 'UL' == ul.nodeName.toUpperCase() ) {
                    
ul.childNodes.length;
                    while ( 
i-- ) {
                        
li ul.childNodes[i];
                        if ( 
li != hovering )
                            
li.className li.className li.className.replacerselected'' ) : '';
                    }
                }
            }

            
/* remove the hover class for any objects not in the immediate element's ancestry */
            
q.length;
            while ( 
i-- ) {
                
inA false;
                
ancestorLength ancestors.length;
                while( 
ancestorLength-- ) {
                    if ( 
ancestorsancestorLength ] == q[i][1] )
                        
inA true;
                }

                if ( ! 
inA )
                    
q[i][1].className q[i][1].className q[i][1].className.replace(hc'') : '';
            }
        },

        
removeHoverClass = function(t) {
            while ( 
&& != aB && != ) {
                if ( 
'LI' == t.nodeName.toUpperCase() ) {
                    (function(
t) {
                        var 
to setTimeout(function() {
                            
t.className t.className t.className.replace(hc'') : '';
                        }, 
500);
                        
q[q.length] = [tot];
                    })(
t);
                }
                
t.parentNode;
            }
        },

        
clickShortlink = function(e) {
            var 
ilnode,
                
e.target || e.srcElement;

            
// Make t the shortlink menu item, or return.
            
while ( true ) {
                
// Check if we've gone past the shortlink node,
                // or if the user is clicking on the input.
                
if ( ! || == || == aB )
                    return;
                
// Check if we've found the shortlink node.
                
if ( t.id && t.id == 'wp-admin-bar-get-shortlink' )
                    break;
                
t.parentNode;
            }

            
// IE doesn't support preventDefault, and does support returnValue
            
if ( e.preventDefault )
                
e.preventDefault();
            
e.returnValue false;

            if ( -
== t.className.indexOf('selected') )
                
t.className += ' selected';

            for ( 
0t.childNodes.lengthli++ ) {
                
node t.childNodes[i];
                if ( 
node.className && -!= node.className.indexOf('shortlink-input') ) {
                    
node.focus();
                    
node.select();
                    
node.onblur = function() {
                        
t.className t.className t.className.replacerselected'' ) : '';
                    };
                    break;
                }
            }
            return 
false;
        },

        
scrollToTop = function(t) {
            var 
distancespeedstepstepstimerspeed_step;

            
// Ensure that the #wpadminbar was the target of the click.
            
if ( t.id != 'wpadminbar' && t.id != 'wp-admin-bar-top-secondary' )
                return;

            
distance    window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;

            if ( 
distance )
                return;

            
speed_step distance 800 130 100;
            
speed     Math.min12Math.rounddistance speed_step ) );
            
step      distance 800 Math.rounddistance 30  ) : Math.rounddistance 20  );
            
steps     = [];
            
timer     0;

            
// Animate scrolling to the top of the page by generating steps to
            // the top of the page and shifting to each step at a set interval.
            
while ( distance ) {
                
distance -= step;
                if ( 
distance )
                    
distance 0;
                
steps.pushdistance );

                
setTimeout( function() {
                    
window.scrollTo0steps.shift() );
                }, 
timer speed );

                
timer++;
            }
        };

        
addEvent(w'load', function() {
            
aB d.getElementById('wpadminbar');

            if ( 
d.body && aB ) {
                
d.body.appendChildaB );

                if ( 
aB.className )
                    
aB.className aB.className.replace(/nojs/, '');

                
addEvent(aB'mouseover', function(e) {
                    
addHoverClasse.target || e.srcElement );
                });

                
addEvent(aB'mouseout', function(e) {
                    
removeHoverClasse.target || e.srcElement );
                });

                
addEvent(aB'click'clickShortlink );

                
addEvent(aB'click', function(e) {
                    
scrollToTope.target || e.srcElement );
                });

                
addEventdocument.getElementById('wp-admin-bar-logout'), 'click', function() {
                    if ( 
'sessionStorage' in window ) {
                        try {
                            for ( var 
key in sessionStorage ) {
                                if ( 
key.indexOf('wp-autosave-') != -)
                                    
sessionStorage.removeItem(key);
                            }
                        } catch(
e) {}
                    }
                });
            }

            if ( 
w.location.hash )
                
w.scrollBy(0,-32);

            if ( 
navigator.userAgent && document.body.className.indexOf'no-font-face' ) === -&&
                /
Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.testnavigator.userAgent ) ) {

                
document.body.className += ' no-font-face';
            }
        });
    })(
documentwindow);

}
?>
Онлайн: 1
Реклама