]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/admin-bar.js
WordPress 4.2
[autoinstalls/wordpress.git] / wp-includes / js / admin-bar.js
index b75823ce8b700ac97bd0419e344ce401f61d2ad0..c028db9d64849bbe844c4b524329d29f67f84c31 100644 (file)
@@ -1,8 +1,11 @@
+/* jshint loopfunc: true */
 // use jQuery and hoverIntent if loaded
 if ( typeof(jQuery) != 'undefined' ) {
        if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
-               // hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js
-               (function(a){a.fn.hoverIntent=function(m,d,h){var j={interval:100,sensitivity:7,timeout:0};if(typeof m==="object"){j=a.extend(j,m)}else{if(a.isFunction(d)){j=a.extend(j,{over:m,out:d,selector:h})}else{j=a.extend(j,{over:m,out:m,selector:d})}}var l,k,g,f;var e=function(n){l=n.pageX;k=n.pageY};var c=function(o,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if((Math.abs(g-l)+Math.abs(f-k))<j.sensitivity){a(n).off("mousemove.hoverIntent",e);n.hoverIntent_s=1;return j.over.apply(n,[o])}else{g=l;f=k;n.hoverIntent_t=setTimeout(function(){c(o,n)},j.interval)}};var i=function(o,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);n.hoverIntent_s=0;return j.out.apply(n,[o])};var b=function(p){var o=jQuery.extend({},p);var n=this;if(n.hoverIntent_t){n.hoverIntent_t=clearTimeout(n.hoverIntent_t)}if(p.type=="mouseenter"){g=o.pageX;f=o.pageY;a(n).on("mousemove.hoverIntent",e);if(n.hoverIntent_s!=1){n.hoverIntent_t=setTimeout(function(){c(o,n)},j.interval)}}else{a(n).off("mousemove.hoverIntent",e);if(n.hoverIntent_s==1){n.hoverIntent_t=setTimeout(function(){i(o,n)},j.timeout)}}};return this.on({"mouseenter.hoverIntent":b,"mouseleave.hoverIntent":b},j.selector)}})(jQuery);
+               /* 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'), refresh, touchOpen, touchClose, disableHoverIntent = false;
@@ -17,10 +20,14 @@ if ( typeof(jQuery) != 'undefined' ) {
                        adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) {
                                var el = $(this);
 
-                               if ( !el.hasClass('hover') ) {
+                               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 ) {
@@ -53,13 +60,13 @@ if ( typeof(jQuery) != 'undefined' ) {
                }
 
                adminbar.find('li.menupop').hoverIntent({
-                       over: function(e){
+                       over: function({
                                if ( disableHoverIntent )
                                        return;
 
                                $(this).addClass('hover');
                        },
-                       out: function(e){
+                       out: function({
                                if ( disableHoverIntent )
                                        return;
 
@@ -84,7 +91,9 @@ if ( typeof(jQuery) != 'undefined' ) {
                        if ( e.which != 13 )
                                return;
 
-                       var target = $(e.target), wrap = target.closest('ab-sub-wrapper');
+                       var target = $(e.target),
+                               wrap = target.closest('.ab-sub-wrapper'),
+                               parentHasHover = target.parent().hasClass('hover');
 
                        e.stopPropagation();
                        e.preventDefault();
@@ -93,7 +102,11 @@ if ( typeof(jQuery) != 'undefined' ) {
                                wrap = $('#wpadminbar .quicklinks');
 
                        wrap.find('.menupop').removeClass('hover');
-                       target.parent().toggleClass('hover');
+
+                       if ( ! parentHasHover ) {
+                               target.parent().toggleClass('hover');
+                       }
+
                        target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
                }).each(refresh);
 
@@ -120,12 +133,15 @@ if ( typeof(jQuery) != 'undefined' ) {
 
                // fix focus bug in WebKit
                $('.screen-reader-shortcut').keydown( function(e) {
+                       var id, ua;
+
                        if ( 13 != e.which )
                                return;
 
-                       var id = $(this).attr('href');
+                       id = $( this ).attr( 'href' );
+
+                       ua = navigator.userAgent.toLowerCase();
 
-                       var ua = navigator.userAgent.toLowerCase();
                        if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) {
                                setTimeout(function () {
                                        $(id).focus();
@@ -133,6 +149,14 @@ if ( typeof(jQuery) != 'undefined' ) {
                        }
                });
 
+               $( '#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() {
@@ -144,6 +168,12 @@ if ( typeof(jQuery) != 'undefined' ) {
                                } catch(e) {}
                        });
                }
+
+               if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 &&
+                       /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/.test( navigator.userAgent ) ) {
+
+                       document.body.className += ' no-font-face';
+               }
        });
 } else {
        (function(d, w) {
@@ -337,6 +367,12 @@ if ( typeof(jQuery) != 'undefined' ) {
 
                        if ( w.location.hash )
                                w.scrollBy(0,-32);
+
+                       if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 &&
+                               /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/.test( navigator.userAgent ) ) {
+
+                               document.body.className += ' no-font-face';
+                       }
                });
        })(document, window);