Make date columns first sort in descending order. See #15580
git-svn-id: http://svn.automattic.com/wordpress/trunk@16593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00ef2437c5
commit
3014920524
File diff suppressed because one or more lines are too long
|
@ -1365,19 +1365,23 @@ table.fixed {
|
|||
height: 4px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
th.sortable a, th.sorted-asc a, th.sorted-desc a {
|
||||
th.sortable a,
|
||||
th.sorted a {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
th.sortable a span, th.sorted-asc a span, th.sorted-desc a span {
|
||||
th.sortable a span,
|
||||
th.sorted a span {
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
th.sorted-asc .sorting-indicator, th.sorted-desc:hover .sorting-indicator, th.sortable:hover .sorting-indicator {
|
||||
th.sorted.asc .sorting-indicator,
|
||||
th.desc:hover span.sorting-indicator {
|
||||
display: block;
|
||||
background: url(../images/sort_asc.gif) no-repeat scroll 0 0;
|
||||
}
|
||||
th.sorted-desc .sorting-indicator, th.sorted-asc:hover .sorting-indicator {
|
||||
th.sorted.desc .sorting-indicator,
|
||||
th.asc:hover span.sorting-indicator {
|
||||
display: block;
|
||||
background: url(../images/sort_desc.gif) no-repeat scroll 0 0;
|
||||
}
|
||||
|
|
|
@ -515,7 +515,12 @@ class WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a list of sortable columns. The format is internal_name => orderby
|
||||
* Get a list of sortable columns. The format is:
|
||||
* 'internal-name' => 'orderby'
|
||||
* or
|
||||
* 'internal-name' => array( 'orderby', true )
|
||||
*
|
||||
* The second format will make the first sorting order be descending
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
|
@ -535,16 +540,30 @@ class WP_List_Table {
|
|||
* @return array
|
||||
*/
|
||||
function get_column_info() {
|
||||
if ( !isset( $this->_column_headers ) ) {
|
||||
$screen = get_current_screen();
|
||||
if ( isset( $this->_column_headers ) )
|
||||
return $this->_column_headers;
|
||||
|
||||
$columns = get_column_headers( $screen );
|
||||
$hidden = get_hidden_columns( $screen );
|
||||
$sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
|
||||
$screen = get_current_screen();
|
||||
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
$columns = get_column_headers( $screen );
|
||||
$hidden = get_hidden_columns( $screen );
|
||||
|
||||
$_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
|
||||
|
||||
$sortable = array();
|
||||
foreach ( $_sortable as $id => $data ) {
|
||||
if ( empty( $data ) )
|
||||
continue;
|
||||
|
||||
$data = (array) $data;
|
||||
if ( !isset( $data[1] ) )
|
||||
$data[1] = false;
|
||||
|
||||
$sortable[$id] = $data;
|
||||
}
|
||||
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
|
||||
return $this->_column_headers;
|
||||
}
|
||||
|
||||
|
@ -602,14 +621,18 @@ class WP_List_Table {
|
|||
$class[] = 'num';
|
||||
|
||||
if ( isset( $sortable[$column_key] ) ) {
|
||||
$orderby = $sortable[$column_key];
|
||||
list( $orderby, $desc_first ) = $sortable[$column_key];
|
||||
|
||||
if ( $current_orderby == $orderby ) {
|
||||
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
||||
$class[] = "sorted-$current_order";
|
||||
$class[] = 'sorted';
|
||||
$class[] = $current_order;
|
||||
} else {
|
||||
$order = 'asc';
|
||||
$order = $desc_first ? 'desc' : 'asc';
|
||||
$class[] = 'sortable';
|
||||
$class[] = $desc_first ? 'asc' : 'desc';
|
||||
}
|
||||
|
||||
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
'author' => 'author',
|
||||
'parent' => 'parent',
|
||||
'comments' => 'comment_count',
|
||||
'date' => 'date',
|
||||
'date' => array( 'date', true ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
'author' => 'author',
|
||||
'parent' => 'parent',
|
||||
'comments' => 'comment_count',
|
||||
'date' => 'date',
|
||||
'date' => array( 'date', true )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -185,31 +185,37 @@ listTable.init();
|
|||
});
|
||||
|
||||
// sortable columns
|
||||
$('th a').click(function() {
|
||||
var orderby = $.query.GET('orderby'),
|
||||
order = $.query.GET('order'),
|
||||
$th = $(this).parent('th');
|
||||
$('th.sortable a, th.sorted a').click(function() {
|
||||
|
||||
if ( $th.hasClass('sortable') ) {
|
||||
orderby = $.query.load($(this).attr('href')).get('orderby');
|
||||
order = 'asc';
|
||||
function get_initial_order($el) {
|
||||
return $.query.load( $el.find('a').attr('href') ).get('order');
|
||||
}
|
||||
|
||||
$('th.sorted-desc, th.sorted-asc')
|
||||
.removeClass('sorted-asc')
|
||||
.removeClass('sorted-desc')
|
||||
.addClass('sortable');
|
||||
var $link = $(this),
|
||||
$th = $link.parent('th'),
|
||||
orderby = $.query.load( $link.attr('href') ).get('orderby'),
|
||||
order;
|
||||
|
||||
$th.removeClass('sortable').addClass('sorted-asc');
|
||||
}
|
||||
else if ( $th.hasClass('sorted-asc') ) {
|
||||
order = 'desc';
|
||||
$th.removeClass('sorted-asc').addClass('sorted-desc');
|
||||
}
|
||||
else if ( $th.hasClass('sorted-desc') ) {
|
||||
order = 'asc';
|
||||
$th.removeClass('sorted-desc').addClass('sorted-asc');
|
||||
if ( orderby == $.query.get('orderby') ) {
|
||||
// changing the direction
|
||||
order = ( 'asc' == $.query.get('order') ) ? 'desc' : 'asc';
|
||||
} else {
|
||||
// changing the parameter
|
||||
order = get_initial_order($th);
|
||||
|
||||
var $old_th = $('th.sorted');
|
||||
if ( $old_th.length ) {
|
||||
$old_th.removeClass('sorted').addClass('sortable');
|
||||
$old_th.removeClass('desc').removeClass('asc').addClass(
|
||||
'asc' == get_initial_order( $old_th ) ? 'desc' : 'asc'
|
||||
);
|
||||
}
|
||||
|
||||
$th.removeClass('sortable').addClass('sorted');
|
||||
}
|
||||
|
||||
$th.removeClass('desc').removeClass('asc').addClass(order);
|
||||
|
||||
listTable.update_rows({'orderby': orderby, 'order': order}, true);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1 +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(d){var c=a(".last-page").attr("href");if(c){this.total_pages=d||a.query.load(c).get("paged")}},get_total_pages:function(){return this.total_pages},change_page:function(c){if(c<1||c>this.total_pages){return false}this.update_rows({paged:c})},htmlencode:function(c){return a("<div/>").text(c).html()},update_rows:function(d,c,g){if(this.loading){return false}var f=false,e={};a.each(d,function(h,i){if(i!=a.query.GET(h)){a.query.SET(h,i);f=true}});if(!f){return false}this.show_overlay();if(c){a.query.SET("paged",1)}a.each(a.query.get(),function(h,i){if(true===i){e[h]=""}else{e[h]=i}});this._callback=g;this.fetch_list(e,a.proxy(this,"handle_success"),a.proxy(this,"handle_error"));return true},fetch_list:function(d,e,c){d=a.extend(d,{action:"fetch-list",list_args:list_args});a.ajax({url:ajaxurl,global:false,dataType:"json",data:d,success:e,error:c})},handle_success:function(c){if("object"!=typeof c){this.handle_error()}else{this.hide_overlay();this.$tbody.html(c.rows);a(".displaying-num").html(c.total_items_i18n);a(".total-pages").html(c.total_pages_i18n);this.set_total_pages(c.total_pages);a(".current-page").val(a.query.GET("paged"));a("th.column-cb :input").attr("checked",false);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 c=a.query.GET("paged");switch(a(this).attr("class")){case"first-page":c=1;break;case"prev-page":c-=1;break;case"next-page":c+=1;break;case"last-page":c=listTable.get_total_pages();break}listTable.change_page(c);return false});a(".current-page").keypress(function(c){if(13!=c.keyCode){return}listTable.change_page(parseInt(a(this).val()));return false});a("th a").click(function(){var e=a.query.GET("orderby"),c=a.query.GET("order"),d=a(this).parent("th");if(d.hasClass("sortable")){e=a.query.load(a(this).attr("href")).get("orderby");c="asc";a("th.sorted-desc, th.sorted-asc").removeClass("sorted-asc").removeClass("sorted-desc").addClass("sortable");d.removeClass("sortable").addClass("sorted-asc")}else{if(d.hasClass("sorted-asc")){c="desc";d.removeClass("sorted-asc").addClass("sorted-desc")}else{if(d.hasClass("sorted-desc")){c="asc";d.removeClass("sorted-desc").addClass("sorted-asc")}}}listTable.update_rows({orderby:e,order:c},true);return false});function b(c){if("keypress"==c.type&&13!=c.keyCode){return}c.preventDefault();c.stopImmediatePropagation();var d=a(this).parent(".search-box").find(":input").serializeObject();listTable.update_rows(d,true,function(){if(a("h2.nav-tab-wrapper").length){return}a("h2 .subtitle").remove();if(d.s){a("h2").append(a('<span class="subtitle">').html(listTableL10n.search.replace("%s",this.htmlencode(d.s))))}})}a(".search-box :submit").click(b);a(".search-box :text").keypress(b);a("#post-query-submit").click(function(){var c={};a(this).parents(".actions").find('select[name!="action"]').each(function(){var d=a(this);c[d.attr("name")]=d.val()});listTable.update_rows(c,true);return false});a(".view-switch a").click(function(){var c=a(this);listTable.update_rows({mode:a.query.load(c.attr("href")).get("mode")},false,function(){a(".view-switch .current").removeClass("current");c.addClass("current")});return false})});
|
||||
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(d){var c=a(".last-page").attr("href");if(c){this.total_pages=d||a.query.load(c).get("paged")}},get_total_pages:function(){return this.total_pages},change_page:function(c){if(c<1||c>this.total_pages){return false}this.update_rows({paged:c})},htmlencode:function(c){return a("<div/>").text(c).html()},update_rows:function(d,c,g){if(this.loading){return false}var f=false,e={};a.each(d,function(h,i){if(i!=a.query.GET(h)){a.query.SET(h,i);f=true}});if(!f){return false}this.show_overlay();if(c){a.query.SET("paged",1)}a.each(a.query.get(),function(h,i){if(true===i){e[h]=""}else{e[h]=i}});this._callback=g;this.fetch_list(e,a.proxy(this,"handle_success"),a.proxy(this,"handle_error"));return true},fetch_list:function(d,e,c){d=a.extend(d,{action:"fetch-list",list_args:list_args});a.ajax({url:ajaxurl,global:false,dataType:"json",data:d,success:e,error:c})},handle_success:function(c){if("object"!=typeof c){this.handle_error()}else{this.hide_overlay();this.$tbody.html(c.rows);a(".displaying-num").html(c.total_items_i18n);a(".total-pages").html(c.total_pages_i18n);this.set_total_pages(c.total_pages);a(".current-page").val(a.query.GET("paged"));a("th.column-cb :input").attr("checked",false);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 c=a.query.GET("paged");switch(a(this).attr("class")){case"first-page":c=1;break;case"prev-page":c-=1;break;case"next-page":c+=1;break;case"last-page":c=listTable.get_total_pages();break}listTable.change_page(c);return false});a(".current-page").keypress(function(c){if(13!=c.keyCode){return}listTable.change_page(parseInt(a(this).val()));return false});a("th.sortable a, th.sorted a").click(function(){function g(i){return a.query.load(i.find("a").attr("href")).get("order")}var e=a(this),f=e.parent("th"),h=a.query.load(e.attr("href")).get("orderby"),d;if(h==a.query.get("orderby")){d=("asc"==a.query.get("order"))?"desc":"asc"}else{d=g(f);var c=a("th.sorted");if(c.length){c.removeClass("sorted").addClass("sortable");c.removeClass("desc").removeClass("asc").addClass("asc"==g(c)?"desc":"asc")}f.removeClass("sortable").addClass("sorted")}f.removeClass("desc").removeClass("asc").addClass(d);listTable.update_rows({orderby:h,order:d},true);return false});function b(c){if("keypress"==c.type&&13!=c.keyCode){return}c.preventDefault();c.stopImmediatePropagation();var d=a(this).parent(".search-box").find(":input").serializeObject();listTable.update_rows(d,true,function(){if(a("h2.nav-tab-wrapper").length){return}a("h2 .subtitle").remove();if(d.s){a("h2").append(a('<span class="subtitle">').html(listTableL10n.search.replace("%s",this.htmlencode(d.s))))}})}a(".search-box :submit").click(b);a(".search-box :text").keypress(b);a("#post-query-submit").click(function(){var c={};a(this).parents(".actions").find('select[name!="action"]').each(function(){var d=a(this);c[d.attr("name")]=d.val()});listTable.update_rows(c,true);return false});a(".view-switch a").click(function(){var c=a(this);listTable.update_rows({mode:a.query.load(c.attr("href")).get("mode")},false,function(){a(".view-switch .current").removeClass("current");c.addClass("current")});return false})});
|
|
@ -304,7 +304,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
|
||||
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
|
||||
|
||||
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20101121' );
|
||||
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20101126' );
|
||||
$scripts->add_data( 'list-table', 'group', 1 );
|
||||
$scripts->localize( 'list-table', 'listTableL10n', array(
|
||||
'loading' => __('Loading...'),
|
||||
|
@ -485,7 +485,7 @@ function wp_default_styles( &$styles ) {
|
|||
// Any rtl stylesheets that don't have a .dev version for ltr
|
||||
$no_suffix = array( 'farbtastic' );
|
||||
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20101118' );
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20101126' );
|
||||
|
||||
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
|
|
Loading…
Reference in New Issue