Rename admin-table.js to list-table.js
git-svn-id: http://svn.automattic.com/wordpress/trunk@15530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
099d01d85d
commit
ab4fc9bba9
|
@ -88,7 +88,7 @@ class WP_List_Table {
|
|||
$this->_args = $args;
|
||||
|
||||
if ( $args['ajax'] ) {
|
||||
wp_enqueue_script( 'admin-table' );
|
||||
wp_enqueue_script( 'list-table' );
|
||||
add_action( 'admin_footer', array( $this, '_js_vars' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
jQuery(document).ready(function(a){window.adminTable={init:function(){this.loading=false;a("form").each(function(){this.reset()});if(""==a.query.GET("paged")){a.query.SET("paged",1)}this.set_total_pages();this.$tbody=a("#the-list, #the-comment-list");this.$overlay=a('<div id="loading-items>').html(adminTableL10n.loading).hide().prependTo(a("body"))},set_total_pages:function(){this.total_pages=parseInt(a(".total-pages").eq(0).text())},get_total_pages:function(){return this.total_pages},change_page:function(b){if(b<1||b>this.total_pages){return false}this.update_rows({paged:b})},change_search:function(b){this.update_rows({s:b},true,function(){a("h2 .subtitle").remove();if(b){a("h2").eq(0).append(a('<span class="subtitle">').html(adminTableL10n.search.replace("%s",this.htmlencode(b))))}})},htmlencode:function(b){return a("<div/>").text(b).html()},update_rows:function(c,b,f){if(this.loading){return false}var e=false;a.each(c,function(g,h){if(h!=a.query.GET(g)){a.query.SET(g,h);e=true}});if(!e){return false}this.show_overlay();if(b){a.query.SET("paged",1)}var d=a.query.get();this._callback=f;this.fetch_list(d,a.proxy(this,"handle_success"),a.proxy(this,"handle_error"));return true},fetch_list:function(c,d,b){c=a.extend(c,{action:"fetch-list",list_args:list_args,});a.ajax({url:ajaxurl,global:false,dataType:"json",data:c,success:d,error:b,})},handle_success:function(b){if("object"!=typeof b){this.handle_error()}else{this.hide_overlay();this.$tbody.html(b.rows);a(".displaying-num").html(b.total_items);a(".total-pages").html(b.total_pages);this.set_total_pages();a(".current-page").val(a.query.GET("paged"));if(this._callback){this._callback()}}},handle_error:function(){this.hide_overlay();a("h2").after('<div class="error ajax below-h2"><p>'+adminTableL10n.error+"</p></div>")},show_overlay:function(){this.loading=true;a(".error.ajax").remove();this.$overlay.css({width:this.$tbody.width()+"px",height:this.$tbody.height()-20+"px"}).css(this.$tbody.offset()).show()},hide_overlay:function(){this.loading=false;this.$overlay.hide()}};adminTable.init();a(".tablenav-pages a").click(function(){var b=a.query.GET("paged");switch(a(this).attr("class")){case"first-page":b=1;break;case"prev-page":b-=1;break;case"next-page":b+=1;break;case"last-page":b=adminTable.get_total_pages();break}adminTable.change_page(b);return false});a(".current-page").keypress(function(b){if(13!=b.keyCode){return}adminTable.change_page(parseInt(a(this).val()));return false});a("th a").click(function(){var d=a.query.GET("orderby"),b=a.query.GET("order"),c=a(this).parent("th");if(c.hasClass("sortable")){d=a.query.load(a(this).attr("href")).get("orderby");b="asc";a("th.sorted-desc, th.sorted-asc").removeClass("sorted-asc").removeClass("sorted-desc").addClass("sortable");c.removeClass("sortable").addClass("sorted-asc")}else{if(c.hasClass("sorted-asc")){b="desc";c.removeClass("sorted-asc").addClass("sorted-desc")}else{if(c.hasClass("sorted-desc")){b="asc";c.removeClass("sorted-desc").addClass("sorted-asc")}}}adminTable.update_rows({orderby:d,order:b},true);return false});a(".search-box :submit").click(function(){adminTable.change_search(a(this).parent(".search-box").find(":text").val());return false});a(".search-box :text").keypress(function(b){if(13!=b.keyCode){return}adminTable.change_search(a(this).val());return false});a("#post-query-submit").click(function(){var c,d,b={};a(this).parents(".actions").find('select[name!="action"]').each(function(){var e=a(this);b[e.attr("name")]=e.val()});adminTable.update_rows(b,true);return false});a(".view-switch a").click(function(){var b=a(this);adminTable.update_rows({mode:a.query.load(b.attr("href")).get("mode")},false,function(){a(".view-switch .current").removeClass("current");b.addClass("current")});return false})});
|
|
@ -214,7 +214,7 @@ setCommentsList = function() {
|
|||
var args = $.query.get();
|
||||
args.number = 1;
|
||||
args.paged++;
|
||||
adminTable.fetch_list(args, function(response) {
|
||||
listTable.fetch_list(args, function(response) {
|
||||
theExtraList.get(0).wpList.add( response.rows );
|
||||
});
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
window.adminTable = {
|
||||
window.listTable = {
|
||||
|
||||
init: function() {
|
||||
this.loading = false;
|
||||
|
@ -16,7 +16,7 @@ window.adminTable = {
|
|||
this.$tbody = $('#the-list, #the-comment-list');
|
||||
|
||||
this.$overlay = $('<div id="loading-items>')
|
||||
.html(adminTableL10n.loading)
|
||||
.html(listTableL10n.loading)
|
||||
.hide()
|
||||
.prependTo($('body'));
|
||||
},
|
||||
|
@ -43,7 +43,7 @@ window.adminTable = {
|
|||
$('h2 .subtitle').remove();
|
||||
|
||||
if ( s )
|
||||
$('h2').eq(0).append($('<span class="subtitle">').html(adminTableL10n.search.replace('%s', this.htmlencode(s))));
|
||||
$('h2').eq(0).append($('<span class="subtitle">').html(listTableL10n.search.replace('%s', this.htmlencode(s))));
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -124,7 +124,7 @@ window.adminTable = {
|
|||
handle_error: function() {
|
||||
this.hide_overlay();
|
||||
|
||||
$('h2').after('<div class="error ajax below-h2"><p>' + adminTableL10n.error + '</p></div>');
|
||||
$('h2').after('<div class="error ajax below-h2"><p>' + listTableL10n.error + '</p></div>');
|
||||
},
|
||||
|
||||
show_overlay: function() {
|
||||
|
@ -147,7 +147,7 @@ window.adminTable = {
|
|||
}
|
||||
}
|
||||
|
||||
adminTable.init();
|
||||
listTable.init();
|
||||
|
||||
// Ajaxify various UI elements
|
||||
|
||||
|
@ -166,11 +166,11 @@ adminTable.init();
|
|||
paged += 1;
|
||||
break;
|
||||
case 'last-page':
|
||||
paged = adminTable.get_total_pages();
|
||||
paged = listTable.get_total_pages();
|
||||
break;
|
||||
}
|
||||
|
||||
adminTable.change_page(paged);
|
||||
listTable.change_page(paged);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -179,7 +179,7 @@ adminTable.init();
|
|||
if ( 13 != e.keyCode )
|
||||
return;
|
||||
|
||||
adminTable.change_page(parseInt($(this).val()));
|
||||
listTable.change_page(parseInt($(this).val()));
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -210,14 +210,14 @@ adminTable.init();
|
|||
$th.removeClass('sorted-desc').addClass('sorted-asc');
|
||||
}
|
||||
|
||||
adminTable.update_rows({'orderby': orderby, 'order': order}, true);
|
||||
listTable.update_rows({'orderby': orderby, 'order': order}, true);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// searchbox
|
||||
$('.search-box :submit').click(function() {
|
||||
adminTable.change_search($(this).parent('.search-box').find(':text').val());
|
||||
listTable.change_search($(this).parent('.search-box').find(':text').val());
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -226,7 +226,7 @@ adminTable.init();
|
|||
if ( 13 != e.keyCode )
|
||||
return;
|
||||
|
||||
adminTable.change_search($(this).val());
|
||||
listTable.change_search($(this).val());
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -241,7 +241,7 @@ adminTable.init();
|
|||
args[$el.attr('name')] = $el.val();
|
||||
});
|
||||
|
||||
adminTable.update_rows(args, true);
|
||||
listTable.update_rows(args, true);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -250,7 +250,7 @@ adminTable.init();
|
|||
$('.view-switch a').click(function() {
|
||||
var $this = $(this);
|
||||
|
||||
adminTable.update_rows({'mode': $.query.load($this.attr('href')).get('mode')}, false, function() {
|
||||
listTable.update_rows({'mode': $.query.load($this.attr('href')).get('mode')}, false, function() {
|
||||
$('.view-switch .current').removeClass('current');
|
||||
$this.addClass('current');
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
jQuery(document).ready(function(a){window.listTable={init:function(){this.loading=false;a("form").each(function(){this.reset()});if(""==a.query.GET("paged")){a.query.SET("paged",1)}this.set_total_pages();this.$tbody=a("#the-list, #the-comment-list");this.$overlay=a('<div id="loading-items>').html(listTableL10n.loading).hide().prependTo(a("body"))},set_total_pages:function(){this.total_pages=parseInt(a(".total-pages").eq(0).text())},get_total_pages:function(){return this.total_pages},change_page:function(b){if(b<1||b>this.total_pages){return false}this.update_rows({paged:b})},change_search:function(b){this.update_rows({s:b},true,function(){a("h2 .subtitle").remove();if(b){a("h2").eq(0).append(a('<span class="subtitle">').html(listTableL10n.search.replace("%s",this.htmlencode(b))))}})},htmlencode:function(b){return a("<div/>").text(b).html()},update_rows:function(c,b,f){if(this.loading){return false}var e=false;a.each(c,function(g,h){if(h!=a.query.GET(g)){a.query.SET(g,h);e=true}});if(!e){return false}this.show_overlay();if(b){a.query.SET("paged",1)}var d=a.query.get();this._callback=f;this.fetch_list(d,a.proxy(this,"handle_success"),a.proxy(this,"handle_error"));return true},fetch_list:function(c,d,b){c=a.extend(c,{action:"fetch-list",list_args:list_args,});a.ajax({url:ajaxurl,global:false,dataType:"json",data:c,success:d,error:b,})},handle_success:function(b){if("object"!=typeof b){this.handle_error()}else{this.hide_overlay();this.$tbody.html(b.rows);a(".displaying-num").html(b.total_items);a(".total-pages").html(b.total_pages);this.set_total_pages();a(".current-page").val(a.query.GET("paged"));if(this._callback){this._callback()}}},handle_error:function(){this.hide_overlay();a("h2").after('<div class="error ajax below-h2"><p>'+listTableL10n.error+"</p></div>")},show_overlay:function(){this.loading=true;a(".error.ajax").remove();this.$overlay.css({width:this.$tbody.width()+"px",height:this.$tbody.height()-20+"px"}).css(this.$tbody.offset()).show()},hide_overlay:function(){this.loading=false;this.$overlay.hide()}};listTable.init();a(".tablenav-pages a").click(function(){var b=a.query.GET("paged");switch(a(this).attr("class")){case"first-page":b=1;break;case"prev-page":b-=1;break;case"next-page":b+=1;break;case"last-page":b=listTable.get_total_pages();break}listTable.change_page(b);return false});a(".current-page").keypress(function(b){if(13!=b.keyCode){return}listTable.change_page(parseInt(a(this).val()));return false});a("th a").click(function(){var d=a.query.GET("orderby"),b=a.query.GET("order"),c=a(this).parent("th");if(c.hasClass("sortable")){d=a.query.load(a(this).attr("href")).get("orderby");b="asc";a("th.sorted-desc, th.sorted-asc").removeClass("sorted-asc").removeClass("sorted-desc").addClass("sortable");c.removeClass("sortable").addClass("sorted-asc")}else{if(c.hasClass("sorted-asc")){b="desc";c.removeClass("sorted-asc").addClass("sorted-desc")}else{if(c.hasClass("sorted-desc")){b="asc";c.removeClass("sorted-desc").addClass("sorted-asc")}}}listTable.update_rows({orderby:d,order:b},true);return false});a(".search-box :submit").click(function(){listTable.change_search(a(this).parent(".search-box").find(":text").val());return false});a(".search-box :text").keypress(function(b){if(13!=b.keyCode){return}listTable.change_search(a(this).val());return false});a("#post-query-submit").click(function(){var c,d,b={};a(this).parents(".actions").find('select[name!="action"]').each(function(){var e=a(this);b[e.attr("name")]=e.val()});listTable.update_rows(b,true);return false});a(".view-switch a").click(function(){var b=a(this);listTable.update_rows({mode:a.query.load(b.attr("href")).get("mode")},false,function(){a(".view-switch .current").removeClass("current");b.addClass("current")});return false})});
|
|
@ -265,7 +265,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20100301' );
|
||||
$scripts->add_data( 'user-profile', 'group', 1 );
|
||||
|
||||
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'admin-table', 'jquery-ui-resizable', 'quicktags'), '20100818' );
|
||||
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'list-table', 'jquery-ui-resizable', 'quicktags'), '20100818' );
|
||||
$scripts->add_data( 'admin-comments', 'group', 1 );
|
||||
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
|
||||
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
||||
|
@ -338,9 +338,9 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
|
||||
$scripts->add_data( 'theme-preview', 'group', 1 );
|
||||
|
||||
$scripts->add( 'admin-table', "/wp-admin/js/admin-table$suffix.js", array( 'jquery', 'jquery-query' ), '20100818' );
|
||||
$scripts->add_data( 'admin-table', 'group', 1 );
|
||||
$scripts->localize( 'admin-table', 'adminTableL10n', array(
|
||||
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery', 'jquery-query' ), '20100818' );
|
||||
$scripts->add_data( 'list-table', 'group', 1 );
|
||||
$scripts->localize( 'list-table', 'listTableL10n', array(
|
||||
'loading' => __('Loading...'),
|
||||
'error' => __('An error has occured while loading the items.'),
|
||||
'search' => __('Search results for “%s”')
|
||||
|
|
Loading…
Reference in New Issue