Customize: Fix persistence of toggles for displayed nav menu item properties.

* Eliminates need to click more than one checkbox to have preferences saved.
* Adds debouncing to saving user-selected menu item properties.
* Also removes discrepancies between available nav menu item properties on admin page vs Customizer.

Fixes #35273.
Props afercia, westonruter.


git-svn-id: https://develop.svn.wordpress.org/trunk@36908 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2016-03-09 21:40:27 +00:00
parent 326806a961
commit 7ececb24f5
3 changed files with 33 additions and 36 deletions
+18 -14
View File
@@ -218,7 +218,7 @@
.prop( 'tabIndex', -1 )
.removeClass( 'is-visible' );
}
this.searchTerm = event.target.value;
this.pages.search = 1;
this.doSearch( 1 );
@@ -614,15 +614,21 @@
});
},
saveManageColumnsState: function() {
var hidden = this.hidden();
$.post( wp.ajax.settings.url, {
action: 'hidden-columns',
hidden: hidden,
saveManageColumnsState: _.debounce( function() {
var panel = this;
if ( panel._updateHiddenColumnsRequest ) {
panel._updateHiddenColumnsRequest.abort();
}
panel._updateHiddenColumnsRequest = wp.ajax.post( 'hidden-columns', {
hidden: panel.hidden(),
screenoptionnonce: $( '#screenoptionnonce' ).val(),
page: 'nav-menus'
});
},
} );
panel._updateHiddenColumnsRequest.always( function() {
panel._updateHiddenColumnsRequest = null;
} );
}, 2000 ),
checked: function( column ) {
this.container.addClass( 'field-' + column + '-active' );
@@ -633,12 +639,10 @@
},
hidden: function() {
this.hidden = function() {
return $( '.hide-column-tog' ).not( ':checked' ).map( function() {
var id = this.id;
return id.substring( id, id.length - 5 );
}).get().join( ',' );
};
return $( '.hide-column-tog' ).not( ':checked' ).map( function() {
var id = this.id;
return id.substring( 0, id.length - 5 );
}).get().join( ',' );
}
} );