<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16433] trunk/wp-admin/js: Don'
t set total_pages unless there are pagination links.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16433">16433</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-11-17 17:26:39 +0000 (Wed, 17 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Don't set total_pages unless there are pagination links. See <a href="http://trac.wordpress.org/ticket/14579">#14579</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjslisttabledevjs">trunk/wp-admin/js/list-table.dev.js</a></li>
<li><a href="#trunkwpadminjslisttablejs">trunk/wp-admin/js/list-table.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjslisttabledevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/list-table.dev.js (16432 => 16433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/list-table.dev.js        2010-11-17 17:21:45 UTC (rev 16432)
+++ trunk/wp-admin/js/list-table.dev.js        2010-11-17 17:26:39 UTC (rev 16433)
</span><span class="lines">@@ -23,7 +23,10 @@
</span><span class="cx">
</span><span class="cx">         // paging
</span><span class="cx">         set_total_pages: function(num) {
</span><del>-                this.total_pages = num || $.query.load( $('.last-page').attr('href') ).get('paged');
</del><ins>+                var last_page_url = $('.last-page').attr('href');
+
+                if ( last_page_url )
+                        this.total_pages = num || $.query.load( last_page_url ).get('paged');
</ins><span class="cx">         },
</span><span class="cx">
</span><span class="cx">         get_total_pages: function() {
</span></span></pre></div>
<a id="trunkwpadminjslisttablejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/list-table.js (16432 => 16433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/list-table.js        2010-11-17 17:21:45 UTC (rev 16432)
+++ trunk/wp-admin/js/list-table.js        2010-11-17 17:26:39 UTC (rev 16433)
</span><span class="lines">@@ -1 +1 @@
</span><del>-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(c){this.total_pages=c||a.query.load(a(".last-page").attr("href")).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(){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})});
</del><span class="cx">\ No newline at end of file
</span><ins>+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(){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})});
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>