diff --git a/src/wp-admin/css/admin-menu.css b/src/wp-admin/css/admin-menu.css index 2d556378b1..74b922ec47 100644 --- a/src/wp-admin/css/admin-menu.css +++ b/src/wp-admin/css/admin-menu.css @@ -264,7 +264,7 @@ .folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu a.menu-top:focus + .wp-submenu, .folded #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu, -.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu { +.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu { top: 0; left: 36px; } @@ -547,79 +547,82 @@ ul#adminmenu > li.current > a.current:after { display: none; } -#collapse-menu { - font-size: 13px; +#collapse-button { + display: block; + width: 100%; + height: 34px; + margin: 0; + border: none; + padding: 0; + position: relative; + overflow: visible; line-height: 34px; - margin-top: 10px; - color: #a0a5aa; - color: rgba(240,245,250,0.6); - -webkit-transition: all .1s ease-in-out; - transition: all .1s ease-in-out; + background: none; + color: #aaa; + cursor: pointer; + outline: 0; } -#collapse-menu:hover, -#collapse-menu:hover #collapse-button div:after { +#collapse-button:hover, +#collapse-button:focus { color: #00b9eb; } -.folded #collapse-menu span { +#collapse-button .collapse-button-icon, +#collapse-button .collapse-button-label { + /* absolutely positioned to avoid 1px shift in IE when button is pressed */ + display: block; + position: absolute; + top: 0; + left: 0; + line-height: 34px; +} + +#collapse-button .collapse-button-icon { + width: 36px; + height: 34px; +} + +#collapse-button .collapse-button-label { + padding: 0 0 0 36px; +} + +.folded #collapse-button .collapse-button-label { display: none; } -#collapse-button, -#collapse-button div { - width: 15px; - height: 15px; -} - -#collapse-button { - float: left; - height: 15px; - margin: 10px 8px 10px 11px; - width: 15px; - -webkit-border-radius: 10px; - border-radius: 10px; -} - -#wpwrap #collapse-button div { - padding: 0; -} - -#collapse-button div:after { +#collapse-button .collapse-button-icon:after { content: "\f148"; display: block; - line-height: 15px; - left: -3px; - top: -3px; - color: #a0a5aa; - color: rgba(240,245,250,0.6); + position: relative; + top: 7px; + text-align: center; font: normal 20px/1 dashicons !important; speak: none; - margin: 0 auto; - padding: 0 !important; - position: relative; - text-align: center; - width: 20px; - -webkit-transition: all .1s ease-in-out; - transition: all .1s ease-in-out; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } /* rtl:ignore */ -.folded #collapse-button div:after, -.rtl #collapse-button div:after { +.folded #collapse-button .collapse-button-icon:after, +.rtl #collapse-button .collapse-button-icon:after { -webkit-transform: rotate(180deg); -ms-transform: rotate(180deg); transform: rotate(180deg); } -.rtl.folded #collapse-button div:after { +.rtl.folded #collapse-button .collapse-button-icon:after { -webkit-transform: none; -ms-transform: none; transform: none; } +#collapse-button .collapse-button-icon:after, +#collapse-button .collapse-button-label { + -webkit-transition: all .1s ease-in-out; + transition: all .1s ease-in-out; +} + /** * Toolbar menu toggle */ @@ -652,7 +655,7 @@ li#wp-admin-bar-menu-toggle { .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, .auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .auto-fold #adminmenu a.menu-top:focus + .wp-submenu, - .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { + .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { top: 0px; left: 36px; } @@ -731,22 +734,18 @@ li#wp-admin-bar-menu-toggle { z-index: 10000; } - .auto-fold #collapse-menu span { + .auto-fold #collapse-menu .collapse-button-label { display: none; } - .auto-fold #collapse-button div { - background: none; - } - /* rtl:ignore */ - .auto-fold #collapse-button div:after { + .auto-fold #collapse-button .collapse-button-icon:after { -webkit-transform: rotate(180deg); -ms-transform: rotate(180deg); transform: rotate(180deg); } - .rtl.auto-fold #collapse-button div:after { + .rtl.auto-fold #collapse-button .collapse-button-icon:after { -webkit-transform: none; -ms-transform: none; transform: none; diff --git a/src/wp-admin/css/colors/_admin.scss b/src/wp-admin/css/colors/_admin.scss index 07753a641e..c74b0fa69a 100644 --- a/src/wp-admin/css/colors/_admin.scss +++ b/src/wp-admin/css/colors/_admin.scss @@ -227,23 +227,15 @@ ul#adminmenu > li.current > a.current:after { /* Admin Menu: collapse button */ -#collapse-menu { +#collapse-button { color: $menu-collapse-text; } -#collapse-menu:hover { - color: $menu-collapse-focus-text; +#collapse-button:hover, +#collapse-button:focus { + color: $menu-submenu-focus-text; } -#collapse-button div:after { - color: $menu-collapse-icon; -} - -#collapse-menu:hover #collapse-button div:after { - color: $menu-collapse-focus-icon; -} - - /* Admin Bar */ #wpadminbar { diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 5a367334c0..e43079bd4c 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -196,6 +196,7 @@ $document.ready( function() { pinnedMenuTop = false, pinnedMenuBottom = false, menuTop = 0, + menuState, menuIsPinned = false, height = { window: $window.height(), @@ -211,59 +212,43 @@ $document.ready( function() { $(e.target).parent().siblings('a').get(0).click(); }); - $('#collapse-menu').on('click.collapse-menu', function() { - var respWidth, state; + $( '#collapse-button' ).on( 'click.collapse-menu', function() { + var viewportWidth = getViewportWidth() || 961; // reset any compensation for submenus near the bottom of the screen $('#adminmenu div.wp-submenu').css('margin-top', ''); - if ( window.innerWidth ) { - // window.innerWidth is affected by zooming on phones - respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); - } else { - // IE < 9 doesn't support @media CSS rules - respWidth = 961; - } - - if ( respWidth && respWidth < 960 ) { + if ( viewportWidth < 960 ) { if ( $body.hasClass('auto-fold') ) { $body.removeClass('auto-fold').removeClass('folded'); setUserSetting('unfold', 1); setUserSetting('mfold', 'o'); - state = 'open'; + menuState = 'open'; } else { $body.addClass('auto-fold'); setUserSetting('unfold', 0); - state = 'folded'; + menuState = 'folded'; } } else { if ( $body.hasClass('folded') ) { $body.removeClass('folded'); setUserSetting('mfold', 'o'); - state = 'open'; + menuState = 'open'; } else { $body.addClass('folded'); setUserSetting('mfold', 'f'); - state = 'folded'; + menuState = 'folded'; } } - currentMenuItemHasPopup(); - $document.trigger( 'wp-collapse-menu', { state: state } ); + $document.trigger( 'wp-collapse-menu', { state: menuState } ); }); // Handle the `aria-haspopup` attribute on the current menu item when it has a sub-menu. function currentMenuItemHasPopup() { - var respWidth, - $current = $( 'a.wp-has-current-submenu' ); + var $current = $( 'a.wp-has-current-submenu' ); - if ( window.innerWidth ) { - respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); - } else { - respWidth = 961; - } - - if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && respWidth && respWidth <= 960 && respWidth > 782 ) ) { + if ( 'folded' === menuState ) { // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu. $current.attr( 'aria-haspopup', 'true' ); } else { @@ -272,7 +257,7 @@ $document.ready( function() { } } - $document.on( 'wp-window-resized wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup ); + $document.on( 'wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup ); /** * Ensure an admin submenu is within the visual viewport. @@ -836,17 +821,14 @@ $document.ready( function() { }, trigger: function() { - var width; + var viewportWidth = getViewportWidth(); - if ( window.innerWidth ) { - // window.innerWidth is affected by zooming on phones - width = Math.max( window.innerWidth, document.documentElement.clientWidth ); - } else { - // Exclude IE < 9, it doesn't support @media CSS rules + // Exclude IE < 9, it doesn't support @media CSS rules. + if ( ! viewportWidth ) { return; } - if ( width <= 782 ) { + if ( viewportWidth <= 782 ) { if ( ! wpResponsiveActive ) { $document.trigger( 'wp-responsive-activate' ); wpResponsiveActive = true; @@ -858,7 +840,7 @@ $document.ready( function() { } } - if ( width <= 480 ) { + if ( viewportWidth <= 480 ) { this.enableOverlay(); } else { this.disableOverlay(); @@ -912,8 +894,82 @@ $document.ready( function() { aria_button_if_js(); }); + /** + * @summary Get the viewport width. + * + * @since 4.7 + * + * @returns {number|boolean} The current viewport width or false if the + * browser doesn't support innerWidth (IE < 9). + */ + function getViewportWidth() { + var viewportWidth = false; + + if ( window.innerWidth ) { + // On phones, window.innerWidth is affected by zooming. + viewportWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); + } + + return viewportWidth; + } + + /** + * @summary Set the admin menu collapsed/expanded state. + * + * Sets the global variable `menuState` and triggers a custom event passing + * the current menu state. + * + * @since 4.7 + * + * @returns {void} + */ + function setMenuState() { + var viewportWidth = getViewportWidth() || 961; + + if ( viewportWidth <= 782 ) { + menuState = 'responsive'; + } else if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && viewportWidth <= 960 && viewportWidth > 782 ) ) { + menuState = 'folded'; + } else { + menuState = 'open'; + } + + $document.trigger( 'wp-menu-state-set', { state: menuState } ); + } + + // Set the menu state when the window gets resized. + $document.on( 'wp-window-resized.set-menu-state', setMenuState ); + + /** + * @summary Set ARIA attributes on the collapse/expand menu button. + * + * When the admin menu is open or folded, updates the `aria-expanded` and + * `aria-label` attributes of the button to give feedback to assistive + * technologies. In the responsive view, the button is always hidden. + * + * @since 4.7 + * + * @returns {void} + */ + $document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) { + var $collapseButton = $( '#collapse-button' ), + ariaExpanded = 'true', + ariaLabelText = commonL10n.collapseMenu; + + if ( 'folded' === eventData.state ) { + ariaExpanded = 'false'; + ariaLabelText = commonL10n.expandMenu; + } + + $collapseButton.attr({ + 'aria-expanded': ariaExpanded, + 'aria-label': ariaLabelText + }); + }); + window.wpResponsive.init(); setPinMenu(); + setMenuState(); currentMenuItemHasPopup(); makeNoticesDismissible(); aria_button_if_js(); diff --git a/src/wp-admin/menu-header.php b/src/wp-admin/menu-header.php index df7744db56..31a35c7723 100644 --- a/src/wp-admin/menu-header.php +++ b/src/wp-admin/menu-header.php @@ -234,9 +234,11 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { echo ""; } - echo '
'; + echo ''; } ?> diff --git a/src/wp-includes/css/customize-preview.css b/src/wp-includes/css/customize-preview.css index ad219e4537..0a33edfe4d 100644 --- a/src/wp-includes/css/customize-preview.css +++ b/src/wp-includes/css/customize-preview.css @@ -23,6 +23,7 @@ border: 0; background: transparent; color: transparent; + -webkit-box-shadow: none; box-shadow: none; outline: none; z-index: 5; @@ -48,17 +49,39 @@ z-index: 5; background-color: #0085ba; background: #0085ba; + -webkit-border-radius: 50%; border-radius: 50%; border: 2px solid #fff; + -webkit-box-shadow: 0 2px 1px rgba(46,68,83,0.15); box-shadow: 0 2px 1px rgba(46,68,83,0.15); text-align: center; + display: -webkit-box; + display: -webkit-flex; + display: -moz-box; + display: -ms-flexbox; display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -moz-box-orient: horizontal; + -moz-box-direction: normal; + -ms-flex-direction: row; flex-direction: row; + -webkit-box-pack: center; + -webkit-justify-content: center; + -moz-box-pack: center; + -ms-flex-pack: center; justify-content: center; + -webkit-box-align: center; + -webkit-align-items: center; + -moz-box-align: center; + -ms-flex-align: center; align-items: center; cursor: pointer; padding: 0; + -webkit-animation-fill-mode: both; animation-fill-mode: both; + -webkit-animation-duration: .4s; animation-duration: .4s; opacity: 0; pointer-events: none; @@ -84,10 +107,12 @@ } body.customize-partial-edit-shortcuts-shown .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-appear; animation-name: customize-partial-edit-shortcut-bounce-appear; pointer-events: auto; } body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-disappear; animation-name: customize-partial-edit-shortcut-bounce-disappear; pointer-events: none; } @@ -101,56 +126,138 @@ body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut bu left: 0; } -@keyframes customize-partial-edit-shortcut-bounce-appear { +@-webkit-keyframes customize-partial-edit-shortcut-bounce-appear { from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); } 0% { opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); transform: scale3d(.3, .3, .3); } 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); transform: scale3d(1.1, 1.1, 1.1); } 40% { + -webkit-transform: scale3d(.9, .9, .9); transform: scale3d(.9, .9, .9); } 60% { opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); transform: scale3d(1.03, 1.03, 1.03); } 80% { + -webkit-transform: scale3d(.97, .97, .97); transform: scale3d(.97, .97, .97); } to { opacity: 1; + -webkit-transform: scale3d(1, 1, 1); transform: scale3d(1, 1, 1); } } +@keyframes customize-partial-edit-shortcut-bounce-appear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@-webkit-keyframes customize-partial-edit-shortcut-bounce-disappear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + 20% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + 40% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 60% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + @keyframes customize-partial-edit-shortcut-bounce-disappear { from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); } 0% { opacity: 1; + -webkit-transform: scale3d(1, 1, 1); transform: scale3d(1, 1, 1); } 20% { + -webkit-transform: scale3d(.97, .97, .97); transform: scale3d(.97, .97, .97); } 40% { opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); transform: scale3d(1.03, 1.03, 1.03); } 60% { + -webkit-transform: scale3d(.9, .9, .9); transform: scale3d(.9, .9, .9); } 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); transform: scale3d(1.1, 1.1, 1.1); } to { opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); transform: scale3d(.3, .3, .3); } } diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 78a18a0bfc..1f3ae7bc1e 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -77,8 +77,10 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array( - 'warnDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), - 'dismiss' => __( 'Dismiss this notice.' ), + 'warnDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), + 'dismiss' => __( 'Dismiss this notice.' ), + 'collapseMenu' => __( 'Collapse Main menu' ), + 'expandMenu' => __( 'Expand Main menu' ), ) ); $scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 );