Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added check to ensure get / set options only handle one pagination el…

…ement.

Also updated various file permissions.
  • Loading branch information...
commit b4b4e6bdbf4b4f05568374ea7575dda81cb67b23 1 parent 04ddd27
@beneverard authored
View
0  js/jquery-1.6.2.min.js 100644 → 100755
File mode changed
View
12 js/jquery.jqpagination.js 100644 → 100755
@@ -307,14 +307,22 @@
$.fn.jqPagination = function () {
// get any function parameters
- var args = Array.prototype.slice.call(arguments),
- $plugin = $(this).data('jqPagination');
+ var args = Array.prototype.slice.call(arguments);
// if the first arg is the string 'option' we want to get or set an option
// note: we can only do this to a single element, and not a collection of elements
if (args[0] === 'option') {
+
+ // if we're dealing with multiple elements, set this to the first element
+ if (this.length > 1) {
+ this = this.eq(0);
+ }
+
+ var $plugin = $(this).data('jqPagination');
+
return $plugin.option(args[1], args[2]);
+
}
// if we're not dealing with a get / set option, initialise plugin
View
3  js/jquery.jqpagination.min.js
@@ -18,5 +18,4 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- */
-(function(a){a.jqPagination=function(c,b){var d=this;d.$el=a(c);d.el=c;d.$input=d.$el.find("input");d.$el.data("jqPagination",d);d.init=function(){d.options=a.extend({},a.jqPagination.defaultOptions,b);if(d.options.max_page===null){if(d.$input.data("max-page")!==undefined){d.options.max_page=d.$input.data("max-page")}else{d.options.max_page=1}}if(d.$input.data("current-page")!==undefined&&d.isNumber(d.$input.data("current-page"))){d.options.current_page=d.$input.data("current-page")}d.$input.removeAttr("readonly");d.updateInput();d.$input.live("focus mouseup",function(e){if(e.type==="focusin"){var f=a(this);f.val(f.data("current-page")).select()}if(e.type==="mouseup"){return false}});d.$input.live("blur keydown",function(e){var g=a(this),f=parseInt(d.options.current_page,10);if(e.keyCode===27){g.val(f);g.blur()}if(e.keyCode===13){g.blur()}if(e.type==="focusout"){d.setPage(g.val())}});d.$el.find("a").live("click",function(e){if(!e.metaKey&&!e.ctrlKey){e.preventDefault();d.setPage(a(this).data("action"))}})};d.setPage=function(f){if(f===undefined){return d.options.current_page}var g=parseInt(d.options.current_page,10),e=parseInt(d.options.max_page,10);if(isNaN(parseInt(f,10))){switch(f){case"first":f=1;break;case"prev":case"previous":f=g-1;break;case"next":f=g+1;break;case"last":f=e;break}}f=parseInt(f,10);if(isNaN(f)||f<1||f>e||f===g){d.setInputValue(g);return false}d.options.current_page=f;d.$input.data("current-page",f);d.updateInput()};d.setMaxPage=function(e){if(e===undefined){return d.options.max_page}if(!d.isNumber(e)){console.error("jqPagination: max_page is not a number");return false}if(e<d.options.current_page){console.error("jqPagination: max_page lower than current_page");return false}d.options.max_page=e;d.$input.data("max-page",e);d.updateInput()};d.updateInput=function(){var e=parseInt(d.options.current_page,10);d.setInputValue(e);d.setLinks(e);d.options.paged(e)};d.setInputValue=function(f){var g=d.options.page_string,e=d.options.max_page;g=g.replace("{current_page}",f).replace("{max_page}",e);d.$input.val(g)};d.isNumber=function(e){return !isNaN(parseFloat(e))&&isFinite(e)};d.setLinks=function(h){var j=d.options.link_string,i=parseInt(d.options.current_page,10),e=parseInt(d.options.max_page,10);if(j!==""){var g=i-1;if(g<1){g=1}var f=i+1;if(f>e){f=e}d.$el.find("a.first").attr("href",j.replace("{page_number}","1"));d.$el.find("a.prev, a.previous").attr("href",j.replace("{page_number}",g));d.$el.find("a.next").attr("href",j.replace("{page_number}",f));d.$el.find("a.last").attr("href",j.replace("{page_number}",e))}};d.option=function(e,f){switch(e.toLowerCase()){case"current_page":return d.setPage(f);case"max_page":return d.setMaxPage(f)}console.error("jqPagination: cannot get / set option "+e);return false};d.init()};a.jqPagination.defaultOptions={current_page:1,link_string:"",max_page:null,page_string:"Page {current_page} of {max_page}",paged:function(){}};a.fn.jqPagination=function(){var b=Array.prototype.slice.call(arguments),c=a(this).data("jqPagination");if(b[0]==="option"){return c.option(b[1],b[2])}this.each(function(){(new a.jqPagination(this,b[0]))})}})(jQuery);
+ */(function(a){"use strict";a.jqPagination=function(b,c){var d=this;d.$el=a(b);d.el=b;d.$input=d.$el.find("input");d.$el.data("jqPagination",d);d.init=function(){d.options=a.extend({},a.jqPagination.defaultOptions,c);d.options.max_page===null&&(d.$input.data("max-page")!==undefined?d.options.max_page=d.$input.data("max-page"):d.options.max_page=1);d.$input.data("current-page")!==undefined&&d.isNumber(d.$input.data("current-page"))&&(d.options.current_page=d.$input.data("current-page"));d.$input.removeAttr("readonly");d.updateInput();d.$input.live("focus mouseup",function(b){if(b.type==="focusin"){var c=a(this);c.val(c.data("current-page")).select()}if(b.type==="mouseup")return!1});d.$input.live("blur keydown",function(b){var c=a(this),e=parseInt(d.options.current_page,10);if(b.keyCode===27){c.val(e);c.blur()}b.keyCode===13&&c.blur();b.type==="focusout"&&d.setPage(c.val())});d.$el.find("a").live("click",function(b){if(!b.metaKey&&!b.ctrlKey){b.preventDefault();d.setPage(a(this).data("action"))}})};d.setPage=function(a){if(a===undefined)return d.options.current_page;var b=parseInt(d.options.current_page,10),c=parseInt(d.options.max_page,10);if(isNaN(parseInt(a,10)))switch(a){case"first":a=1;break;case"prev":case"previous":a=b-1;break;case"next":a=b+1;break;case"last":a=c}a=parseInt(a,10);if(isNaN(a)||a<1||a>c||a===b){d.setInputValue(b);return!1}d.options.current_page=a;d.$input.data("current-page",a);d.updateInput()};d.setMaxPage=function(a){if(a===undefined)return d.options.max_page;if(!d.isNumber(a)){console.error("jqPagination: max_page is not a number");return!1}if(a<d.options.current_page){console.error("jqPagination: max_page lower than current_page");return!1}d.options.max_page=a;d.$input.data("max-page",a);d.updateInput()};d.updateInput=function(){var a=parseInt(d.options.current_page,10);d.setInputValue(a);d.setLinks(a);d.options.paged(a)};d.setInputValue=function(a){var b=d.options.page_string,c=d.options.max_page;b=b.replace("{current_page}",a).replace("{max_page}",c);d.$input.val(b)};d.isNumber=function(a){return!isNaN(parseFloat(a))&&isFinite(a)};d.setLinks=function(a){var b=d.options.link_string,c=parseInt(d.options.current_page,10),e=parseInt(d.options.max_page,10);if(b!==""){var f=c-1;f<1&&(f=1);var g=c+1;g>e&&(g=e);d.$el.find("a.first").attr("href",b.replace("{page_number}","1"));d.$el.find("a.prev, a.previous").attr("href",b.replace("{page_number}",f));d.$el.find("a.next").attr("href",b.replace("{page_number}",g));d.$el.find("a.last").attr("href",b.replace("{page_number}",e))}};d.option=function(a,b){switch(a.toLowerCase()){case"current_page":return d.setPage(b);case"max_page":return d.setMaxPage(b)}console.error("jqPagination: cannot get / set option "+a);return!1};d.init()};a.jqPagination.defaultOptions={current_page:1,link_string:"",max_page:null,page_string:"Page {current_page} of {max_page}",paged:function(){}};a.fn.jqPagination=function(){var b=Array.prototype.slice.call(arguments);if(b[0]==="option"){this.length>1&&(this=this.eq(0));var c=a(this).data("jqPagination");return c.option(b[1],b[2])}this.each(function(){new a.jqPagination(this,b[0])})}})(jQuery);
View
0  js/scripts.js 100644 → 100755
File mode changed
Please sign in to comment.
Something went wrong with that request. Please try again.