Set additional fields when searching. Fixes #15211
git-svn-id: https://develop.svn.wordpress.org/trunk@16022 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9c918c6a05
commit
b2f927ed76
@ -37,16 +37,6 @@ window.listTable = {
|
|||||||
this.update_rows({'paged': paged});
|
this.update_rows({'paged': paged});
|
||||||
},
|
},
|
||||||
|
|
||||||
// searching
|
|
||||||
change_search: function(s) {
|
|
||||||
this.update_rows({'s': s}, true, function() {
|
|
||||||
$('h2 .subtitle').remove();
|
|
||||||
|
|
||||||
if ( s )
|
|
||||||
$('h2').eq(0).append($('<span class="subtitle">').html(listTableL10n.search.replace('%s', this.htmlencode(s))));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
htmlencode: function(value) {
|
htmlencode: function(value) {
|
||||||
return $('<div/>').text(value).html();
|
return $('<div/>').text(value).html();
|
||||||
},
|
},
|
||||||
@ -216,20 +206,26 @@ listTable.init();
|
|||||||
});
|
});
|
||||||
|
|
||||||
// searchbox
|
// searchbox
|
||||||
$('.search-box :submit').click(function() {
|
function change_search(ev) {
|
||||||
listTable.change_search($(this).parent('.search-box').find(':text').val());
|
if ( 'keypress' == ev.type && 13 != e.keyCode )
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.search-box :text').keypress(function(e) {
|
|
||||||
if ( 13 != e.keyCode )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
listTable.change_search($(this).val());
|
ev.preventDefault();
|
||||||
|
ev.stopImmediatePropagation();
|
||||||
|
|
||||||
return false;
|
var data = $(this).parent('.search-box').find(':input').serializeObject();
|
||||||
});
|
|
||||||
|
listTable.update_rows(data, true, function() {
|
||||||
|
$('h2 .subtitle').remove();
|
||||||
|
|
||||||
|
if ( data.s )
|
||||||
|
$('h2').append($('<span class="subtitle">').html(
|
||||||
|
listTableL10n.search.replace('%s', this.htmlencode(data.s))
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('.search-box :submit').click(change_search);
|
||||||
|
$('.search-box :text').keypress(change_search);
|
||||||
|
|
||||||
// tablenav dropdowns
|
// tablenav dropdowns
|
||||||
$('#post-query-submit').click(function() {
|
$('#post-query-submit').click(function() {
|
||||||
|
31
wp-includes/js/jquery/jquery.serialize-object.js
Normal file
31
wp-includes/js/jquery/jquery.serialize-object.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*!
|
||||||
|
* jQuery serializeObject - v0.2 - 1/20/2010
|
||||||
|
* http://benalman.com/projects/jquery-misc-plugins/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
* http://benalman.com/about/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
|
||||||
|
// serializes a form into an (arguably more useful) object.
|
||||||
|
|
||||||
|
(function($,undefined){
|
||||||
|
'$:nomunge'; // Used by YUI compressor.
|
||||||
|
|
||||||
|
$.fn.serializeObject = function(){
|
||||||
|
var obj = {};
|
||||||
|
|
||||||
|
$.each( this.serializeArray(), function(i,o){
|
||||||
|
var n = o.name,
|
||||||
|
v = o.value;
|
||||||
|
|
||||||
|
obj[n] = obj[n] === undefined ? v
|
||||||
|
: $.isArray( obj[n] ) ? obj[n].concat( v )
|
||||||
|
: [ obj[n], v ];
|
||||||
|
});
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
@ -171,6 +171,9 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
$scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
|
$scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
|
||||||
$scripts->add_data( 'jquery-query', 'group', 1 );
|
$scripts->add_data( 'jquery-query', 'group', 1 );
|
||||||
|
|
||||||
|
$scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2' );
|
||||||
|
$scripts->add_data( 'jquery-serialize-object', 'group', 1 );
|
||||||
|
|
||||||
$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
|
$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
|
||||||
$scripts->add_data( 'jquery-hotkeys', 'group', 1 );
|
$scripts->add_data( 'jquery-hotkeys', 'group', 1 );
|
||||||
|
|
||||||
@ -354,7 +357,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
|
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
|
||||||
$scripts->add_data( 'theme-preview', 'group', 1 );
|
$scripts->add_data( 'theme-preview', 'group', 1 );
|
||||||
|
|
||||||
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery', 'jquery-query' ), '20101023' );
|
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20101027' );
|
||||||
$scripts->add_data( 'list-table', 'group', 1 );
|
$scripts->add_data( 'list-table', 'group', 1 );
|
||||||
$scripts->localize( 'list-table', 'listTableL10n', array(
|
$scripts->localize( 'list-table', 'listTableL10n', array(
|
||||||
'loading' => __('Loading...'),
|
'loading' => __('Loading...'),
|
||||||
|
Loading…
Reference in New Issue
Block a user