1 /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, pagenow */
2 var showNotice, adminMenu, columns, validateForm, screenMeta;
3 ( function( $, window, undefined ) {
4 var $document = $( document ),
6 $body = $( document.body );
9 // (perhaps) needed for back-compat
13 restoreMenuState : function() {},
14 toggle : function() {},
15 favorites : function() {}
18 // show/hide/save table columns
22 $('.hide-column-tog', '#adv-settings').click( function() {
23 var $t = $(this), column = $t.val();
24 if ( $t.prop('checked') )
27 that.unchecked(column);
29 columns.saveManageColumnsState();
33 saveManageColumnsState : function() {
34 var hidden = this.hidden();
36 action: 'hidden-columns',
38 screenoptionnonce: $('#screenoptionnonce').val(),
43 checked : function(column) {
44 $('.column-' + column).removeClass( 'hidden' );
45 this.colSpanChange(+1);
48 unchecked : function(column) {
49 $('.column-' + column).addClass( 'hidden' );
50 this.colSpanChange(-1);
54 return $( '.manage-column[id]' ).filter( ':hidden' ).map(function() {
59 useCheckboxesForHidden : function() {
60 this.hidden = function(){
61 return $('.hide-column-tog').not(':checked').map(function() {
63 return id.substring( id, id.length - 5 );
68 colSpanChange : function(diff) {
69 var $t = $('table').find('.colspanchange'), n;
72 n = parseInt( $t.attr('colspan'), 10 ) + diff;
73 $t.attr('colspan', n.toString());
77 $document.ready(function(){columns.init();});
79 validateForm = function( form ) {
81 .find( '.form-required' )
82 .filter( function() { return $( 'input:visible', this ).val() === ''; } )
83 .addClass( 'form-invalid' )
84 .find( 'input:visible' )
85 .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
89 // stub for doing better warnings
92 var msg = commonL10n.warnDelete || '';
100 note : function(text) {
106 element: null, // #screen-meta
107 toggles: null, // .screen-meta-toggle
108 page: null, // #wpcontent
111 this.element = $('#screen-meta');
112 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' );
113 this.page = $('#wpcontent');
115 this.toggles.click( this.toggleEvent );
118 toggleEvent: function() {
119 var panel = $( '#' + $( this ).attr( 'aria-controls' ) );
124 if ( panel.is(':visible') )
125 screenMeta.close( panel, $(this) );
127 screenMeta.open( panel, $(this) );
130 open: function( panel, button ) {
132 $( '#screen-meta-links' ).find( '.screen-meta-toggle' ).not( button.parent() ).css( 'visibility', 'hidden' );
134 panel.parent().show();
135 panel.slideDown( 'fast', function() {
137 button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true );
140 $document.trigger( 'screen:options:open' );
143 close: function( panel, button ) {
144 panel.slideUp( 'fast', function() {
145 button.removeClass( 'screen-meta-active' ).attr( 'aria-expanded', false );
146 $('.screen-meta-toggle').css('visibility', '');
147 panel.parent().hide();
150 $document.trigger( 'screen:options:close' );
157 $('.contextual-help-tabs').delegate('a', 'click', function(e) {
163 // Don't do anything if the click is for the tab already showing.
164 if ( link.is('.active a') )
168 $('.contextual-help-tabs .active').removeClass('active');
169 link.parent('li').addClass('active');
171 panel = $( link.attr('href') );
174 $('.help-tab-content').not( panel ).removeClass('active').hide();
175 panel.addClass('active').show();
178 $document.ready( function() {
179 var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
181 pageInput = $('input.current-page'),
182 currentPage = pageInput.val(),
183 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ),
184 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1,
185 isIE8 = $( document.documentElement ).hasClass( 'ie8' ),
186 $adminMenuWrap = $( '#adminmenuwrap' ),
187 $wpwrap = $( '#wpwrap' ),
188 $adminmenu = $( '#adminmenu' ),
189 $overlay = $( '#wp-responsive-overlay' ),
190 $toolbar = $( '#wp-toolbar' ),
191 $toolbarPopups = $toolbar.find( 'a[aria-haspopup="true"]' ),
192 $sortables = $('.meta-box-sortables'),
193 wpResponsiveActive = false,
194 $adminbar = $( '#wpadminbar' ),
195 lastScrollPosition = 0,
196 pinnedMenuTop = false,
197 pinnedMenuBottom = false,
200 menuIsPinned = false,
202 window: $window.height(),
203 wpwrap: $wpwrap.height(),
204 adminbar: $adminbar.height(),
205 menu: $adminMenuWrap.height()
207 $headerEnd = $( '.wp-header-end' );
210 // when the menu is folded, make the fly-out submenu header clickable
211 $adminmenu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){
212 $(e.target).parent().siblings('a').get(0).click();
215 $( '#collapse-button' ).on( 'click.collapse-menu', function() {
216 var viewportWidth = getViewportWidth() || 961;
218 // reset any compensation for submenus near the bottom of the screen
219 $('#adminmenu div.wp-submenu').css('margin-top', '');
221 if ( viewportWidth < 960 ) {
222 if ( $body.hasClass('auto-fold') ) {
223 $body.removeClass('auto-fold').removeClass('folded');
224 setUserSetting('unfold', 1);
225 setUserSetting('mfold', 'o');
228 $body.addClass('auto-fold');
229 setUserSetting('unfold', 0);
230 menuState = 'folded';
233 if ( $body.hasClass('folded') ) {
234 $body.removeClass('folded');
235 setUserSetting('mfold', 'o');
238 $body.addClass('folded');
239 setUserSetting('mfold', 'f');
240 menuState = 'folded';
244 $document.trigger( 'wp-collapse-menu', { state: menuState } );
247 // Handle the `aria-haspopup` attribute on the current menu item when it has a sub-menu.
248 function currentMenuItemHasPopup() {
249 var $current = $( 'a.wp-has-current-submenu' );
251 if ( 'folded' === menuState ) {
252 // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu.
253 $current.attr( 'aria-haspopup', 'true' );
255 // When expanded or in responsive view, reset aria-haspopup.
256 $current.attr( 'aria-haspopup', 'false' );
260 $document.on( 'wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup );
263 * Ensure an admin submenu is within the visual viewport.
267 * @param {jQuery} $menuItem The parent menu item containing the submenu.
269 function adjustSubmenu( $menuItem ) {
270 var bottomOffset, pageHeight, adjustment, theFold, menutop, wintop, maxtop,
271 $submenu = $menuItem.find( '.wp-submenu' );
273 menutop = $menuItem.offset().top;
274 wintop = $window.scrollTop();
275 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
277 bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu
278 pageHeight = $wpwrap.height(); // Height of the entire page
279 adjustment = 60 + bottomOffset - pageHeight;
280 theFold = $window.height() + wintop - 50; // The fold
282 if ( theFold < ( bottomOffset - adjustment ) ) {
283 adjustment = bottomOffset - theFold;
286 if ( adjustment > maxtop ) {
290 if ( adjustment > 1 ) {
291 $submenu.css( 'margin-top', '-' + adjustment + 'px' );
293 $submenu.css( 'margin-top', '' );
297 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
298 // iOS Safari works with touchstart, the rest work with click
299 mobileEvent = isIOS ? 'touchstart' : 'click';
301 // close any open submenus when touch/click is not on the menu
302 $body.on( mobileEvent+'.wp-mobile-hover', function(e) {
303 if ( $adminmenu.data('wp-responsive') ) {
307 if ( ! $( e.target ).closest( '#adminmenu' ).length ) {
308 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
312 $adminmenu.find( 'a.wp-has-submenu' ).on( mobileEvent + '.wp-mobile-hover', function( event ) {
313 var $menuItem = $(this).parent();
315 if ( $adminmenu.data( 'wp-responsive' ) ) {
319 // Show the sub instead of following the link if:
320 // - the submenu is not open
321 // - the submenu is not shown inline or the menu is not folded
322 if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) {
323 event.preventDefault();
324 adjustSubmenu( $menuItem );
325 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
326 $menuItem.addClass('opensub');
331 if ( ! isIOS && ! isAndroid ) {
332 $adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({
334 var $menuItem = $( this ),
335 $submenu = $menuItem.find( '.wp-submenu' ),
336 top = parseInt( $submenu.css( 'top' ), 10 );
338 if ( isNaN( top ) || top > -5 ) { // the submenu is visible
342 if ( $adminmenu.data( 'wp-responsive' ) ) {
343 // The menu is in responsive mode, bail
347 adjustSubmenu( $menuItem );
348 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
349 $menuItem.addClass( 'opensub' );
352 if ( $adminmenu.data( 'wp-responsive' ) ) {
353 // The menu is in responsive mode, bail
357 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' );
364 $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) {
365 if ( $adminmenu.data( 'wp-responsive' ) ) {
366 // The menu is in responsive mode, bail
370 $( event.target ).closest( 'li.menu-top' ).addClass( 'opensub' );
371 }).on( 'blur.adminmenu', '.wp-submenu a', function( event ) {
372 if ( $adminmenu.data( 'wp-responsive' ) ) {
376 $( event.target ).closest( 'li.menu-top' ).removeClass( 'opensub' );
377 }).find( 'li.wp-has-submenu.wp-not-current-submenu' ).on( 'focusin.adminmenu', function() {
378 adjustSubmenu( $( this ) );
383 * The `.below-h2` class is here just for backward compatibility with plugins
384 * that are (incorrectly) using it. Do not use. Use `.inline` instead. See #34570.
385 * If '.wp-header-end' is found, append the notices after it otherwise
386 * after the first h1 or h2 heading found within the main content.
388 if ( ! $headerEnd.length ) {
389 $headerEnd = $( '.wrap h1, .wrap h2' ).first();
391 $( 'div.updated, div.error, div.notice' ).not( '.inline, .below-h2' ).insertAfter( $headerEnd );
393 // Make notices dismissible
394 function makeNoticesDismissible() {
395 $( '.notice.is-dismissible' ).each( function() {
397 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
398 btnText = commonL10n.dismiss || '';
401 $button.find( '.screen-reader-text' ).text( btnText );
402 $button.on( 'click.wp-dismiss-notice', function( event ) {
403 event.preventDefault();
404 $el.fadeTo( 100, 0, function() {
405 $el.slideUp( 100, function() {
411 $el.append( $button );
415 $document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error', makeNoticesDismissible );
420 // This event needs to be delegated. Ticket #37973.
421 $body.on( 'click', 'tbody .check-column :checkbox', function( event ) {
422 // Shift click to select a range of checkboxes.
423 if ( 'undefined' == event.shiftKey ) { return true; }
424 if ( event.shiftKey ) {
425 if ( !lastClicked ) { return true; }
426 checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' );
427 first = checks.index( lastClicked );
428 last = checks.index( this );
429 checked = $(this).prop('checked');
430 if ( 0 < first && 0 < last && first != last ) {
431 sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first );
432 sliced.prop( 'checked', function() {
433 if ( $(this).closest('tr').is(':visible') )
442 // Toggle the "Select all" checkboxes depending if the other ones are all checked or not.
443 var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked');
444 $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() {
445 return ( 0 === unchecked.length );
451 // This event needs to be delegated. Ticket #37973.
452 $body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) {
454 $table = $this.closest( 'table' ),
455 controlChecked = $this.prop('checked'),
456 toggle = event.shiftKey || $this.data('wp-toggle');
458 $table.children( 'tbody' ).filter(':visible')
459 .children().children('.check-column').find(':checkbox')
460 .prop('checked', function() {
461 if ( $(this).is(':hidden,:disabled') ) {
466 return ! $(this).prop( 'checked' );
467 } else if ( controlChecked ) {
474 $table.children('thead, tfoot').filter(':visible')
475 .children().children('.check-column').find(':checkbox')
476 .prop('checked', function() {
479 } else if ( controlChecked ) {
487 // Show row actions on keyboard focus of its parent container element or any other elements contained within
488 $( '#wpbody-content' ).on({
489 focusin: function() {
490 clearTimeout( transitionTimeout );
491 focusedRowActions = $( this ).find( '.row-actions' );
492 // transitionTimeout is necessary for Firefox, but Chrome won't remove the CSS class without a little help.
493 $( '.row-actions' ).not( this ).removeClass( 'visible' );
494 focusedRowActions.addClass( 'visible' );
496 focusout: function() {
497 // Tabbing between post title and .row-actions links needs a brief pause, otherwise
498 // the .row-actions div gets hidden in transit in some browsers (ahem, Firefox).
499 transitionTimeout = setTimeout( function() {
500 focusedRowActions.removeClass( 'visible' );
503 }, '.has-row-actions' );
505 // Toggle list table rows on small screens
506 $( 'tbody' ).on( 'click', '.toggle-row', function() {
507 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
510 $('#default-password-nag-no').click( function() {
511 setUserSetting('default_password_nag', 'hide');
512 $('div.default-password-nag').hide();
517 $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) {
518 var el = e.target, selStart, selEnd, val, scroll, sel;
520 if ( e.keyCode == 27 ) { // escape key
521 // when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them
523 $(el).data('tab-out', true);
527 if ( e.keyCode != 9 || e.ctrlKey || e.altKey || e.shiftKey ) // tab key
530 if ( $(el).data('tab-out') ) {
531 $(el).data('tab-out', false);
535 selStart = el.selectionStart;
536 selEnd = el.selectionEnd;
539 if ( document.selection ) {
541 sel = document.selection.createRange();
543 } else if ( selStart >= 0 ) {
544 scroll = this.scrollTop;
545 el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
546 el.selectionStart = el.selectionEnd = selStart + 1;
547 this.scrollTop = scroll;
550 if ( e.stopPropagation )
552 if ( e.preventDefault )
556 if ( pageInput.length ) {
557 pageInput.closest('form').submit( function() {
559 // Reset paging var for new filters/searches but not for bulk actions. See #17685.
560 if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage )
565 $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () {
566 $('select[name^="action"]').val('-1');
569 // Scroll into view when focused
570 $('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){
571 if ( e.target.scrollIntoView )
572 e.target.scrollIntoView(false);
575 // Disable upload buttons until files are selected
577 var button, input, form = $('form.wp-upload-form');
580 button = form.find('input[type="submit"]');
581 input = form.find('input[type="file"]');
583 function toggleUploadButton() {
584 button.prop('disabled', '' === input.map( function() {
585 return $(this).val();
588 toggleUploadButton();
589 input.on('change', toggleUploadButton);
592 function pinMenu( event ) {
593 var windowPos = $window.scrollTop(),
594 resizing = ! event || event.type !== 'scroll';
596 if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) {
600 if ( height.menu + height.adminbar < height.window ||
601 height.menu + height.adminbar + 20 > height.wpwrap ) {
608 if ( height.menu + height.adminbar > height.window ) {
609 // Check for overscrolling
610 if ( windowPos < 0 ) {
611 if ( ! pinnedMenuTop ) {
612 pinnedMenuTop = true;
613 pinnedMenuBottom = false;
623 } else if ( windowPos + height.window > $document.height() - 1 ) {
624 if ( ! pinnedMenuBottom ) {
625 pinnedMenuBottom = true;
626 pinnedMenuTop = false;
638 if ( windowPos > lastScrollPosition ) {
640 if ( pinnedMenuTop ) {
642 pinnedMenuTop = false;
643 menuTop = $adminMenuWrap.offset().top - height.adminbar - ( windowPos - lastScrollPosition );
645 if ( menuTop + height.menu + height.adminbar < windowPos + height.window ) {
646 menuTop = windowPos + height.window - height.menu - height.adminbar;
650 position: 'absolute',
654 } else if ( ! pinnedMenuBottom && $adminMenuWrap.offset().top + height.menu < windowPos + height.window ) {
656 pinnedMenuBottom = true;
664 } else if ( windowPos < lastScrollPosition ) {
666 if ( pinnedMenuBottom ) {
668 pinnedMenuBottom = false;
669 menuTop = $adminMenuWrap.offset().top - height.adminbar + ( lastScrollPosition - windowPos );
671 if ( menuTop + height.menu > windowPos + height.window ) {
676 position: 'absolute',
680 } else if ( ! pinnedMenuTop && $adminMenuWrap.offset().top >= windowPos + height.adminbar ) {
682 pinnedMenuTop = true;
690 } else if ( resizing ) {
692 pinnedMenuTop = pinnedMenuBottom = false;
693 menuTop = windowPos + height.window - height.menu - height.adminbar - 1;
697 position: 'absolute',
707 lastScrollPosition = windowPos;
710 function resetHeights() {
712 window: $window.height(),
713 wpwrap: $wpwrap.height(),
714 adminbar: $adminbar.height(),
715 menu: $adminMenuWrap.height()
719 function unpinMenu() {
720 if ( isIOS || ! menuIsPinned ) {
724 pinnedMenuTop = pinnedMenuBottom = menuIsPinned = false;
732 function setPinMenu() {
735 if ( $adminmenu.data('wp-responsive') ) {
736 $body.removeClass( 'sticky-menu' );
738 } else if ( height.menu + height.adminbar > height.window ) {
740 $body.removeClass( 'sticky-menu' );
742 $body.addClass( 'sticky-menu' );
748 $window.on( 'scroll.pin-menu', pinMenu );
749 $document.on( 'tinymce-editor-init.pin-menu', function( event, editor ) {
750 editor.on( 'wp-autoresize', resetHeights );
754 window.wpResponsive = {
758 // Modify functionality based on custom activate/deactivate event
759 $document.on( 'wp-responsive-activate.wp-responsive', function() {
761 }).on( 'wp-responsive-deactivate.wp-responsive', function() {
765 $( '#wp-admin-bar-menu-toggle a' ).attr( 'aria-expanded', 'false' );
767 // Toggle sidebar when toggle is clicked
768 $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) {
769 event.preventDefault();
771 // close any open toolbar submenus
772 $adminbar.find( '.hover' ).removeClass( 'hover' );
774 $wpwrap.toggleClass( 'wp-responsive-open' );
775 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) {
776 $(this).find('a').attr( 'aria-expanded', 'true' );
777 $( '#adminmenu a:first' ).focus();
779 $(this).find('a').attr( 'aria-expanded', 'false' );
784 $adminmenu.on( 'click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
785 if ( ! $adminmenu.data('wp-responsive') ) {
789 $( this ).parent( 'li' ).toggleClass( 'selected' );
790 event.preventDefault();
794 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
796 // This needs to run later as UI Sortable may be initialized later on $(document).ready()
797 $window.on( 'load.wp-responsive', function() {
798 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth;
800 if ( width <= 782 ) {
801 self.disableSortables();
806 activate: function() {
809 if ( ! $body.hasClass( 'auto-fold' ) ) {
810 $body.addClass( 'auto-fold' );
813 $adminmenu.data( 'wp-responsive', 1 );
814 this.disableSortables();
817 deactivate: function() {
819 $adminmenu.removeData('wp-responsive');
820 this.enableSortables();
823 trigger: function() {
824 var viewportWidth = getViewportWidth();
826 // Exclude IE < 9, it doesn't support @media CSS rules.
827 if ( ! viewportWidth ) {
831 if ( viewportWidth <= 782 ) {
832 if ( ! wpResponsiveActive ) {
833 $document.trigger( 'wp-responsive-activate' );
834 wpResponsiveActive = true;
837 if ( wpResponsiveActive ) {
838 $document.trigger( 'wp-responsive-deactivate' );
839 wpResponsiveActive = false;
843 if ( viewportWidth <= 480 ) {
844 this.enableOverlay();
846 this.disableOverlay();
850 enableOverlay: function() {
851 if ( $overlay.length === 0 ) {
852 $overlay = $( '<div id="wp-responsive-overlay"></div>' )
853 .insertAfter( '#wpcontent' )
855 .on( 'click.wp-responsive', function() {
856 $toolbar.find( '.menupop.hover' ).removeClass( 'hover' );
861 $toolbarPopups.on( 'click.wp-responsive', function() {
866 disableOverlay: function() {
867 $toolbarPopups.off( 'click.wp-responsive' );
871 disableSortables: function() {
872 if ( $sortables.length ) {
874 $sortables.sortable('disable');
879 enableSortables: function() {
880 if ( $sortables.length ) {
882 $sortables.sortable('enable');
888 // Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on.
889 function aria_button_if_js() {
890 $( '.aria-button-if-js' ).attr( 'role', 'button' );
893 $( document ).ajaxComplete( function() {
898 * @summary Get the viewport width.
902 * @returns {number|boolean} The current viewport width or false if the
903 * browser doesn't support innerWidth (IE < 9).
905 function getViewportWidth() {
906 var viewportWidth = false;
908 if ( window.innerWidth ) {
909 // On phones, window.innerWidth is affected by zooming.
910 viewportWidth = Math.max( window.innerWidth, document.documentElement.clientWidth );
913 return viewportWidth;
917 * @summary Set the admin menu collapsed/expanded state.
919 * Sets the global variable `menuState` and triggers a custom event passing
920 * the current menu state.
926 function setMenuState() {
927 var viewportWidth = getViewportWidth() || 961;
929 if ( viewportWidth <= 782 ) {
930 menuState = 'responsive';
931 } else if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && viewportWidth <= 960 && viewportWidth > 782 ) ) {
932 menuState = 'folded';
937 $document.trigger( 'wp-menu-state-set', { state: menuState } );
940 // Set the menu state when the window gets resized.
941 $document.on( 'wp-window-resized.set-menu-state', setMenuState );
944 * @summary Set ARIA attributes on the collapse/expand menu button.
946 * When the admin menu is open or folded, updates the `aria-expanded` and
947 * `aria-label` attributes of the button to give feedback to assistive
948 * technologies. In the responsive view, the button is always hidden.
954 $document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) {
955 var $collapseButton = $( '#collapse-button' ),
956 ariaExpanded = 'true',
957 ariaLabelText = commonL10n.collapseMenu;
959 if ( 'folded' === eventData.state ) {
960 ariaExpanded = 'false';
961 ariaLabelText = commonL10n.expandMenu;
964 $collapseButton.attr({
965 'aria-expanded': ariaExpanded,
966 'aria-label': ariaLabelText
970 window.wpResponsive.init();
973 currentMenuItemHasPopup();
974 makeNoticesDismissible();
977 $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 );
979 // Set initial focus on a specific element.
980 $( '.wp-initial-focus' ).focus();
983 // Fire a custom jQuery event at the end of window resize
987 function triggerEvent() {
988 $document.trigger( 'wp-window-resized' );
991 function fireOnce() {
992 window.clearTimeout( timeout );
993 timeout = window.setTimeout( triggerEvent, 200 );
996 $window.on( 'resize.wp-fire-once', fireOnce );
999 // Make Windows 8 devices play along nicely.
1001 if ( '-ms-user-select' in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/) ) {
1002 var msViewportStyle = document.createElement( 'style' );
1003 msViewportStyle.appendChild(
1004 document.createTextNode( '@-ms-viewport{width:auto!important}' )
1006 document.getElementsByTagName( 'head' )[0].appendChild( msViewportStyle );
1010 }( jQuery, window ));