Menu customizer: More clearly separate search results from available items.

Available items now fade from view while you're searching, and there is an explicit way to clear search results. No results gives a better message, though still brief this time around.

props valendesigns, designsimply, DH-Shredder, helen.
fixes #32710.

Built from https://develop.svn.wordpress.org/trunk@33511


git-svn-id: http://core.svn.wordpress.org/trunk@33478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2015-07-29 23:40:25 +00:00
parent 3dfce31be0
commit ea8f8acc79
10 changed files with 165 additions and 31 deletions

View File

@ -590,7 +590,8 @@
bottom: 0;
right: -301px;
visibility: hidden;
overflow: hidden;
overflow-x: hidden;
overflow-y: auto;
width: 300px;
margin: 0;
z-index: 4;
@ -600,8 +601,13 @@
border-left: 1px solid #ddd;
}
#available-menu-items.allow-scroll {
overflow-y: auto;
#available-menu-items.opening {
overflow-y: hidden; /* avoid scrollbar jitter with animating heights */
}
#available-menu-items #available-menu-items-search.open {
height: 100%;
border-bottom: none;
}
#available-menu-items .accordion-section-title {
@ -610,7 +616,8 @@
background: #fff;
}
#available-menu-items .open .accordion-section-title {
#available-menu-items .open .accordion-section-title,
#available-menu-items #available-menu-items-search .accordion-section-title {
background: #eee;
}
@ -702,6 +709,15 @@ button.not-a-button {
max-height: 290px;
}
#available-menu-items #available-menu-items-search .accordion-section-content {
position: absolute;
right: 1px;
top: 60px; /* below title div / search input */
bottom: 0px; /* 100% height that still triggers lazy load */
max-height: none;
width: 270px;
}
#available-menu-items .menu-item-tpl {
margin: 0;
}
@ -802,6 +818,43 @@ button.not-a-button {
margin: 0 20px;
}
#available-menu-items-search .clear-results {
position: absolute;
top: 20px;
left: 20px;
width: 20px;
height: 20px;
cursor: pointer;
color: #a00;
text-decoration: none;
}
#available-menu-items-search .clear-results,
#available-menu-items-search.loading .clear-results.is-visible {
display: none;
}
#available-menu-items-search .clear-results.is-visible {
display: block;
}
#available-menu-items-search .clear-results:before {
content: "\f335";
font: normal 20px/1 dashicons;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#available-menu-items-search .clear-results:hover,
#available-menu-items-search .clear-results:focus {
color: #f00;
}
#available-menu-items-search .clear-results:focus {
-webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
}
#available-menu-items-search .spinner {
position: absolute;
top: 20px;

File diff suppressed because one or more lines are too long

View File

@ -590,7 +590,8 @@
bottom: 0;
left: -301px;
visibility: hidden;
overflow: hidden;
overflow-x: hidden;
overflow-y: auto;
width: 300px;
margin: 0;
z-index: 4;
@ -600,8 +601,13 @@
border-right: 1px solid #ddd;
}
#available-menu-items.allow-scroll {
overflow-y: auto;
#available-menu-items.opening {
overflow-y: hidden; /* avoid scrollbar jitter with animating heights */
}
#available-menu-items #available-menu-items-search.open {
height: 100%;
border-bottom: none;
}
#available-menu-items .accordion-section-title {
@ -610,7 +616,8 @@
background: #fff;
}
#available-menu-items .open .accordion-section-title {
#available-menu-items .open .accordion-section-title,
#available-menu-items #available-menu-items-search .accordion-section-title {
background: #eee;
}
@ -702,6 +709,15 @@ button.not-a-button {
max-height: 290px;
}
#available-menu-items #available-menu-items-search .accordion-section-content {
position: absolute;
left: 1px;
top: 60px; /* below title div / search input */
bottom: 0px; /* 100% height that still triggers lazy load */
max-height: none;
width: 270px;
}
#available-menu-items .menu-item-tpl {
margin: 0;
}
@ -802,6 +818,43 @@ button.not-a-button {
margin: 0 20px;
}
#available-menu-items-search .clear-results {
position: absolute;
top: 20px;
right: 20px;
width: 20px;
height: 20px;
cursor: pointer;
color: #a00;
text-decoration: none;
}
#available-menu-items-search .clear-results,
#available-menu-items-search.loading .clear-results.is-visible {
display: none;
}
#available-menu-items-search .clear-results.is-visible {
display: block;
}
#available-menu-items-search .clear-results:before {
content: "\f335";
font: normal 20px/1 dashicons;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#available-menu-items-search .clear-results:hover,
#available-menu-items-search .clear-results:focus {
color: #f00;
}
#available-menu-items-search .clear-results:focus {
-webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
}
#available-menu-items-search .spinner {
position: absolute;
top: 20px;

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,8 @@
function accordionSwitch ( el ) {
var section = el.closest( '.accordion-section' ),
sectionToggleControl = section.find( '[aria-expanded]' ).first(),
siblings = section.closest( '.accordion-container' ).find( '.open' ),
container = section.closest( '.accordion-container' ),
siblings = container.find( '.open' ),
siblingsToggleControl = siblings.find( '[aria-expanded]' ).first(),
content = section.find( '.accordion-section-content' );
@ -63,6 +64,10 @@
return;
}
// Add a class to the container to let us know something is happening inside.
// This helps in cases such as hiding a scrollbar while animations are executing.
container.addClass( 'opening' );
if ( section.hasClass( 'open' ) ) {
section.toggleClass( 'open' );
content.toggle( true ).slideToggle( 150 );
@ -74,6 +79,11 @@
section.toggleClass( 'open' );
}
// We have to wait for the animations to finish
setTimeout(function(){
container.removeClass( 'opening' );
}, 150);
// If there's an element with an aria-expanded attribute, assume it's a toggle control and toggle the aria-expanded value.
if ( sectionToggleControl ) {
sectionToggleControl.attr( 'aria-expanded', String( sectionToggleControl.attr( 'aria-expanded' ) === 'false' ) );

View File

@ -1 +1 @@
!function(a){function b(a){var b=a.closest(".accordion-section"),c=b.find("[aria-expanded]").first(),d=b.closest(".accordion-container").find(".open"),e=d.find("[aria-expanded]").first(),f=b.find(".accordion-section-content");b.hasClass("cannot-expand")||(b.hasClass("open")?(b.toggleClass("open"),f.toggle(!0).slideToggle(150)):(e.attr("aria-expanded","false"),d.removeClass("open"),d.find(".accordion-section-content").show().slideUp(150),f.toggle(!1).slideToggle(150),b.toggleClass("open")),c&&c.attr("aria-expanded",String("false"===c.attr("aria-expanded"))))}a(document).ready(function(){a(".accordion-container").on("click keydown",".accordion-section-title",function(c){("keydown"!==c.type||13===c.which)&&(c.preventDefault(),b(a(this)))})})}(jQuery);
!function(a){function b(a){var b=a.closest(".accordion-section"),c=b.find("[aria-expanded]").first(),d=b.closest(".accordion-container"),e=d.find(".open"),f=e.find("[aria-expanded]").first(),g=b.find(".accordion-section-content");b.hasClass("cannot-expand")||(d.addClass("opening"),b.hasClass("open")?(b.toggleClass("open"),g.toggle(!0).slideToggle(150)):(f.attr("aria-expanded","false"),e.removeClass("open"),e.find(".accordion-section-content").show().slideUp(150),g.toggle(!1).slideToggle(150),b.toggleClass("open")),setTimeout(function(){d.removeClass("opening")},150),c&&c.attr("aria-expanded",String("false"===c.attr("aria-expanded"))))}a(document).ready(function(){a(".accordion-container").on("click keydown",".accordion-section-title",function(c){("keydown"!==c.type||13===c.which)&&(c.preventDefault(),b(a(this)))})})}(jQuery);

View File

@ -96,7 +96,6 @@
events: {
'input #menu-items-search': 'debounceSearch',
'keyup #menu-items-search': 'debounceSearch',
'click #menu-items-search': 'debounceSearch',
'focus .menu-item-tpl': 'focus',
'click .menu-item-tpl': '_submit',
'click #custom-menu-item-submit': '_submitLink',
@ -138,6 +137,20 @@
}
} );
// Clear the search results.
$( '.clear-results' ).on( 'click keydown', function( event ) {
console.log(event);
if ( event.type === 'keydown' && ( 13 !== event.which && 32 !== event.which ) ) { // "return" or "space" keys only
return;
}
event.preventDefault();
$( '#menu-items-search' ).val( '' ).focus();
event.target.value = '';
self.search( event );
} );
this.$el.on( 'input', '#custom-menu-item-name.invalid, #custom-menu-item-url.invalid', function() {
$( this ).removeClass( 'invalid' );
});
@ -176,25 +189,31 @@
// Search input change handler.
search: function( event ) {
var $searchSection = $( '#available-menu-items-search' ),
$openSections = $( '#available-menu-items .accordion-section.open' );
$otherSections = $( '#available-menu-items .accordion-section' ).not( $searchSection );
if ( ! event ) {
return;
}
// Manual accordion-opening behavior.
if ( this.searchTerm && ! $searchSection.hasClass( 'open' ) ) {
$openSections.find( '.accordion-section-content' ).slideUp( 'fast' );
$searchSection.find( '.accordion-section-content' ).slideDown( 'fast' );
$openSections.find( '[aria-expanded]' ).first().attr( 'aria-expanded', 'false' );
$openSections.removeClass( 'open' );
$searchSection.addClass( 'open' );
}
if ( '' === event.target.value ) {
$searchSection.removeClass( 'open' );
}
if ( this.searchTerm === event.target.value ) {
return;
}
if ( '' !== event.target.value && ! $searchSection.hasClass( 'open' ) ) {
$otherSections.fadeOut( 100 );
$searchSection.find( '.accordion-section-content' ).slideDown( 'fast' );
$searchSection.addClass( 'open' );
$searchSection.find( '.clear-results' )
.prop( 'tabIndex', 0 )
.addClass( 'is-visible' );
} else if ( '' === event.target.value ) {
$searchSection.removeClass( 'open' );
$otherSections.show();
$searchSection.find( '.clear-results' )
.prop( 'tabIndex', -1 )
.removeClass( 'is-visible' );
}
this.searchTerm = event.target.value;
this.pages.search = 1;
this.doSearch( 1 );
@ -351,8 +370,6 @@
diff = totalHeight - accordionHeight;
if ( 120 < diff && 290 > diff ) {
sections.css( 'max-height', diff );
} else if ( 120 >= diff ) {
this.$el.addClass( 'allow-scroll' );
}
},

File diff suppressed because one or more lines are too long

View File

@ -217,7 +217,7 @@ final class WP_Customize_Nav_Menus {
$items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) );
if ( empty( $items ) ) {
wp_send_json_error( array( 'message' => __( 'No menu items found.' ) ) );
wp_send_json_error( array( 'message' => __( 'No results found.' ) ) );
} else {
wp_send_json_success( array( 'items' => $items ) );
}
@ -718,6 +718,7 @@ final class WP_Customize_Nav_Menus {
<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items&hellip;' ) ?>" aria-describedby="menu-items-search-desc" />
<p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
<span class="spinner"></span>
<span class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></span>
</div>
<ul class="accordion-section-content" data-type="search"></ul>
</div>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-beta4-33510';
$wp_version = '4.3-beta4-33511';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.