changeset 5 | 5e2f62d02dcd |
parent 0 | d970ebf37754 |
child 7 | cf61fcea0001 |
4:346c88efed21 | 5:5e2f62d02dcd |
---|---|
1 /* jshint loopfunc: true */ |
|
1 // use jQuery and hoverIntent if loaded |
2 // use jQuery and hoverIntent if loaded |
2 if ( typeof(jQuery) != 'undefined' ) { |
3 if ( typeof(jQuery) != 'undefined' ) { |
3 if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) { |
4 if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) { |
4 // hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js |
5 /* jshint ignore:start */ |
5 (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); |
6 // hoverIntent v1.8.1 - Copy of wp-includes/js/hoverIntent.min.js |
7 !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); |
|
8 /* jshint ignore:end */ |
|
6 } |
9 } |
7 jQuery(document).ready(function($){ |
10 jQuery(document).ready(function($){ |
8 var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false; |
11 var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false; |
9 |
12 |
10 refresh = function(i, el){ // force the browser to refresh the tabbing index |
13 refresh = function(i, el){ // force the browser to refresh the tabbing index |
15 |
18 |
16 touchOpen = function(unbind) { |
19 touchOpen = function(unbind) { |
17 adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { |
20 adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { |
18 var el = $(this); |
21 var el = $(this); |
19 |
22 |
20 if ( !el.hasClass('hover') ) { |
23 if ( el.parent().is('#wp-admin-bar-root-default') && !el.hasClass('hover') ) { |
21 e.preventDefault(); |
24 e.preventDefault(); |
22 adminbar.find('li.menupop.hover').removeClass('hover'); |
25 adminbar.find('li.menupop.hover').removeClass('hover'); |
26 el.addClass('hover'); |
|
27 } else if ( !el.hasClass('hover') ) { |
|
28 e.stopPropagation(); |
|
29 e.preventDefault(); |
|
23 el.addClass('hover'); |
30 el.addClass('hover'); |
24 } |
31 } |
25 |
32 |
26 if ( unbind ) { |
33 if ( unbind ) { |
27 $('li.menupop').off('click.wp-mobile-hover'); |
34 $('li.menupop').off('click.wp-mobile-hover'); |
51 touchOpen(); |
58 touchOpen(); |
52 touchClose(); |
59 touchClose(); |
53 } |
60 } |
54 |
61 |
55 adminbar.find('li.menupop').hoverIntent({ |
62 adminbar.find('li.menupop').hoverIntent({ |
56 over: function(e){ |
63 over: function() { |
57 if ( disableHoverIntent ) |
64 if ( disableHoverIntent ) |
58 return; |
65 return; |
59 |
66 |
60 $(this).addClass('hover'); |
67 $(this).addClass('hover'); |
61 }, |
68 }, |
62 out: function(e){ |
69 out: function() { |
63 if ( disableHoverIntent ) |
70 if ( disableHoverIntent ) |
64 return; |
71 return; |
65 |
72 |
66 $(this).removeClass('hover'); |
73 $(this).removeClass('hover'); |
67 }, |
74 }, |
82 |
89 |
83 $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ |
90 $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ |
84 if ( e.which != 13 ) |
91 if ( e.which != 13 ) |
85 return; |
92 return; |
86 |
93 |
87 var target = $(e.target), wrap = target.closest('ab-sub-wrapper'); |
94 var target = $(e.target), |
95 wrap = target.closest('.ab-sub-wrapper'), |
|
96 parentHasHover = target.parent().hasClass('hover'); |
|
88 |
97 |
89 e.stopPropagation(); |
98 e.stopPropagation(); |
90 e.preventDefault(); |
99 e.preventDefault(); |
91 |
100 |
92 if ( !wrap.length ) |
101 if ( !wrap.length ) |
93 wrap = $('#wpadminbar .quicklinks'); |
102 wrap = $('#wpadminbar .quicklinks'); |
94 |
103 |
95 wrap.find('.menupop').removeClass('hover'); |
104 wrap.find('.menupop').removeClass('hover'); |
96 target.parent().toggleClass('hover'); |
105 |
106 if ( ! parentHasHover ) { |
|
107 target.parent().toggleClass('hover'); |
|
108 } |
|
109 |
|
97 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); |
110 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); |
98 }).each(refresh); |
111 }).each(refresh); |
99 |
112 |
100 $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){ |
113 $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){ |
101 if ( e.which != 27 ) |
114 if ( e.which != 27 ) |
118 $('html, body').animate({ scrollTop: 0 }, 'fast'); |
131 $('html, body').animate({ scrollTop: 0 }, 'fast'); |
119 }); |
132 }); |
120 |
133 |
121 // fix focus bug in WebKit |
134 // fix focus bug in WebKit |
122 $('.screen-reader-shortcut').keydown( function(e) { |
135 $('.screen-reader-shortcut').keydown( function(e) { |
136 var id, ua; |
|
137 |
|
123 if ( 13 != e.which ) |
138 if ( 13 != e.which ) |
124 return; |
139 return; |
125 |
140 |
126 var id = $(this).attr('href'); |
141 id = $( this ).attr( 'href' ); |
127 |
142 |
128 var ua = navigator.userAgent.toLowerCase(); |
143 ua = navigator.userAgent.toLowerCase(); |
144 |
|
129 if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) { |
145 if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) { |
130 setTimeout(function () { |
146 setTimeout(function () { |
131 $(id).focus(); |
147 $(id).focus(); |
132 }, 100); |
148 }, 100); |
133 } |
149 } |
134 }); |
150 }); |
151 |
|
152 $( '#adminbar-search' ).on({ |
|
153 focus: function() { |
|
154 $( '#adminbarsearch' ).addClass( 'adminbar-focused' ); |
|
155 }, blur: function() { |
|
156 $( '#adminbarsearch' ).removeClass( 'adminbar-focused' ); |
|
157 } |
|
158 } ); |
|
135 |
159 |
136 // Empty sessionStorage on logging out |
160 // Empty sessionStorage on logging out |
137 if ( 'sessionStorage' in window ) { |
161 if ( 'sessionStorage' in window ) { |
138 $('#wp-admin-bar-logout a').click( function() { |
162 $('#wp-admin-bar-logout a').click( function() { |
139 try { |
163 try { |
142 sessionStorage.removeItem(key); |
166 sessionStorage.removeItem(key); |
143 } |
167 } |
144 } catch(e) {} |
168 } catch(e) {} |
145 }); |
169 }); |
146 } |
170 } |
171 |
|
172 if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && |
|
173 /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 ) ) { |
|
174 |
|
175 document.body.className += ' no-font-face'; |
|
176 } |
|
147 }); |
177 }); |
148 } else { |
178 } else { |
149 (function(d, w) { |
179 (function(d, w) { |
150 var addEvent = function( obj, type, fn ) { |
180 var addEvent = function( obj, type, fn ) { |
151 if ( obj.addEventListener ) |
181 if ( obj.addEventListener ) |
335 }); |
365 }); |
336 } |
366 } |
337 |
367 |
338 if ( w.location.hash ) |
368 if ( w.location.hash ) |
339 w.scrollBy(0,-32); |
369 w.scrollBy(0,-32); |
370 |
|
371 if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && |
|
372 /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 ) ) { |
|
373 |
|
374 document.body.className += ' no-font-face'; |
|
375 } |
|
340 }); |
376 }); |
341 })(document, window); |
377 })(document, window); |
342 |
378 |
343 } |
379 } |