Changeset 35313
- Timestamp:
- 10/21/2015 03:40:38 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/common.js
r35239 r35313 2 2 var showNotice, adminMenu, columns, validateForm, screenMeta; 3 3 ( function( $, window, undefined ) { 4 var $document = $( document ), 5 $window = $( window ), 6 $body = $( document.body ); 7 4 8 // Removed in 3.3. 5 9 // (perhaps) needed for back-compat … … 71 75 }; 72 76 73 $ (document).ready(function(){columns.init();});77 $document.ready(function(){columns.init();}); 74 78 75 79 validateForm = function( form ) { … … 134 138 }); 135 139 136 $ ( document ).trigger( 'screen:options:open' );140 $document.trigger( 'screen:options:open' ); 137 141 }, 138 142 … … 144 148 }); 145 149 146 $ ( document ).trigger( 'screen:options:close' );150 $document.trigger( 'screen:options:close' ); 147 151 } 148 152 }; … … 172 176 }); 173 177 174 $ (document).ready( function() {178 $document.ready( function() { 175 179 var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions, 176 180 lastClicked = false, … … 180 184 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1, 181 185 isIE8 = $( document.documentElement ).hasClass( 'ie8' ), 182 $document = $( document ),183 $window = $( window ),184 $body = $( document.body ),185 186 $adminMenuWrap = $( '#adminmenuwrap' ), 186 187 $wpwrap = $( '#wpwrap' ), … … 211 212 212 213 $('#collapse-menu').on('click.collapse-menu', function() { 213 var body = $( document.body ),respWidth, state;214 var respWidth, state; 214 215 215 216 // reset any compensation for submenus near the bottom of the screen … … 225 226 226 227 if ( respWidth && respWidth < 960 ) { 227 if ( body.hasClass('auto-fold') ) {228 body.removeClass('auto-fold').removeClass('folded');228 if ( $body.hasClass('auto-fold') ) { 229 $body.removeClass('auto-fold').removeClass('folded'); 229 230 setUserSetting('unfold', 1); 230 231 setUserSetting('mfold', 'o'); 231 232 state = 'open'; 232 233 } else { 233 body.addClass('auto-fold');234 $body.addClass('auto-fold'); 234 235 setUserSetting('unfold', 0); 235 236 state = 'folded'; 236 237 } 237 238 } else { 238 if ( body.hasClass('folded') ) {239 body.removeClass('folded');239 if ( $body.hasClass('folded') ) { 240 $body.removeClass('folded'); 240 241 setUserSetting('mfold', 'o'); 241 242 state = 'open'; 242 243 } else { 243 body.addClass('folded');244 $body.addClass('folded'); 244 245 setUserSetting('mfold', 'f'); 245 246 state = 'folded'; … … 247 248 } 248 249 249 $( document ).trigger( 'wp-collapse-menu', { state: state } ); 250 currentMenuItemHasPopup(); 251 $document.trigger( 'wp-collapse-menu', { state: state } ); 250 252 }); 253 254 // Handle the `aria-haspopup` attribute on the current menu item when it has a sub-menu. 255 function currentMenuItemHasPopup() { 256 var respWidth, 257 $current = $( 'a.wp-has-current-submenu' ); 258 259 if ( window.innerWidth ) { 260 respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); 261 } else { 262 respWidth = 961; 263 } 264 265 if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && respWidth && respWidth <= 960 && respWidth > 782 ) ) { 266 // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu. 267 $current.attr( 'aria-haspopup', 'true' ); 268 } else { 269 // When expanded or in responsive view, reset aria-haspopup. 270 $current.attr( 'aria-haspopup', 'false' ); 271 } 272 }; 273 274 $document.on( 'wp-window-resized wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup ); 251 275 252 276 /** … … 290 314 291 315 // close any open submenus when touch/click is not on the menu 292 $ (document.body).on( mobileEvent+'.wp-mobile-hover', function(e) {316 $body.on( mobileEvent+'.wp-mobile-hover', function(e) { 293 317 if ( $adminmenu.data('wp-responsive') ) { 294 318 return; … … 867 891 window.wpResponsive.init(); 868 892 setPinMenu(); 893 currentMenuItemHasPopup(); 869 894 870 895 $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu ); … … 876 901 877 902 function triggerEvent() { 878 $ (document).trigger( 'wp-window-resized' );903 $document.trigger( 'wp-window-resized' ); 879 904 } 880 905 … … 884 909 } 885 910 886 $ (window).on( 'resize.wp-fire-once', fireOnce );911 $window.on( 'resize.wp-fire-once', fireOnce ); 887 912 }()); 888 913
Note: See TracChangeset
for help on using the changeset viewer.