backgrid-paginator
Advanced tools
Comparing version 0.3.8 to 0.3.9
@@ -12,3 +12,3 @@ /* | ||
if (typeof exports == "object") { | ||
module.exports = factory(require("lodash"), | ||
module.exports = factory(require("underscore"), | ||
require("backbone"), | ||
@@ -19,4 +19,4 @@ require("backgrid"), | ||
// AMD. Register as an anonymous module. | ||
else if (typeof define === 'function' && define.amd) { | ||
define(['lodash', 'backbone', 'backgrid', 'backbone.paginator'], factory); | ||
else if (typeof define == "function" && define.amd) { | ||
define(["underscore", "backbone", "backgrid", "backbone.paginator"], factory); | ||
} | ||
@@ -202,6 +202,6 @@ // Browser | ||
if (!$el.hasClass("active") && !$el.hasClass("disabled")) { | ||
if (this.isRewind) col.getFirstPage(); | ||
else if (this.isBack) col.getPreviousPage(); | ||
else if (this.isForward) col.getNextPage(); | ||
else if (this.isFastForward) col.getLastPage(); | ||
if (this.isRewind) col.getFirstPage({reset: true}); | ||
else if (this.isBack) col.getPreviousPage({reset: true}); | ||
else if (this.isForward) col.getNextPage({reset: true}); | ||
else if (this.isFastForward) col.getLastPage({reset: true}); | ||
else col.getPage(this.pageIndex, {reset: true}); | ||
@@ -275,2 +275,9 @@ } | ||
/** | ||
@property renderMultiplePagesOnly. Determines if the paginator | ||
should show in cases where the collection has more than one page. | ||
Default is false for backwards compatibility. | ||
*/ | ||
renderMultiplePagesOnly: false, | ||
/** | ||
@property {Backgrid.Extension.PageHandle} pageHandle. The PageHandle | ||
@@ -292,2 +299,3 @@ class to use for rendering individual handles | ||
@param {boolean} [options.goBackFirstOnSort=true] | ||
@param {boolean} [options.renderMultiplePagesOnly=false] | ||
*/ | ||
@@ -301,3 +309,4 @@ initialize: function (options) { | ||
"slideScale", "goBackFirstOnSort", | ||
"renderIndexedPageHandles")); | ||
"renderIndexedPageHandles", | ||
"renderMultiplePagesOnly")); | ||
@@ -309,3 +318,3 @@ var col = self.collection; | ||
self.listenTo(col, "backgrid:sorted", function () { | ||
if (self.goBackFirstOnSort) col.getFirstPage({reset: true}); | ||
if (self.goBackFirstOnSort && col.state.currentPage !== col.state.firstPage) col.getFirstPage({reset: true}); | ||
}); | ||
@@ -420,2 +429,9 @@ }, | ||
var totalPages = this.collection.state.totalPages; | ||
// Don't render if collection is empty | ||
if(this.renderMultiplePagesOnly && totalPages <= 1) { | ||
return this; | ||
} | ||
if (this.handles) { | ||
@@ -422,0 +438,0 @@ for (var i = 0, l = this.handles.length; i < l; i++) { |
@@ -8,2 +8,174 @@ /* | ||
*/ | ||
!function(a,b){"object"==typeof exports&&(module.exports=b(require("underscore"),require("backbone"),require("backgrid"),require("backbone.paginator"))),"function"==typeof define&&define.amd?define(["underscore","backbone","backgrid","backbone.paginator"],b):b(a._,a.Backbone,a.Backgrid)}(this,function(a,b,c){"use strict";var d=c.Extension.PageHandle=b.View.extend({tagName:"li",events:{"click a":"changePage"},title:function(a){return"Page "+a.label},isRewind:!1,isBack:!1,isForward:!1,isFastForward:!1,initialize:function(b){var c=this.collection,d=c.state,e=d.currentPage,f=d.firstPage,g=d.lastPage;a.extend(this,a.pick(b,["isRewind","isBack","isForward","isFastForward"]));var h;this.isRewind?h=f:this.isBack?h=Math.max(f,e-1):this.isForward?h=Math.min(g,e+1):this.isFastForward?h=g:(h=+b.pageIndex,h=f?h+1:h),this.pageIndex=h,this.label=(b.label||(f?h:h+1))+"";var i=b.title||this.title;this.title=a.isFunction(i)?i({label:this.label}):i},render:function(){this.$el.empty();var a=document.createElement("a");a.href="#",this.title&&(a.title=this.title),a.innerHTML=this.label,this.el.appendChild(a);var b=this.collection,c=b.state,d=c.currentPage,e=this.pageIndex;return this.isRewind&&d==c.firstPage||this.isBack&&!b.hasPreviousPage()||this.isForward&&!b.hasNextPage()||this.isFastForward&&(d==c.lastPage||c.totalPages<1)?this.$el.addClass("disabled"):this.isRewind||this.isBack||this.isForward||this.isFastForward||c.currentPage!=e||this.$el.addClass("active"),this.delegateEvents(),this},changePage:function(a){a.preventDefault();var b=this.$el,c=this.collection;return b.hasClass("active")||b.hasClass("disabled")||(this.isRewind?c.getFirstPage():this.isBack?c.getPreviousPage():this.isForward?c.getNextPage():this.isFastForward?c.getLastPage():c.getPage(this.pageIndex,{reset:!0})),this}}),e=c.Extension.Paginator=b.View.extend({className:"backgrid-paginator",windowSize:10,slideScale:.5,controls:{rewind:{label:"《",title:"First"},back:{label:"〈",title:"Previous"},forward:{label:"〉",title:"Next"},fastForward:{label:"》",title:"Last"}},renderIndexedPageHandles:!0,pageHandle:d,goBackFirstOnSort:!0,initialize:function(b){var c=this;c.controls=a.defaults(b.controls||{},c.controls,e.prototype.controls),a.extend(c,a.pick(b||{},"windowSize","pageHandle","slideScale","goBackFirstOnSort","renderIndexedPageHandles"));var d=c.collection;c.listenTo(d,"add",c.render),c.listenTo(d,"remove",c.render),c.listenTo(d,"reset",c.render),c.listenTo(d,"backgrid:sorted",function(){c.goBackFirstOnSort&&d.getFirstPage({reset:!0})})},slideMaybe:function(a,b,c,d){return Math.round(c%d/d)},slideThisMuch:function(a,b,c,d,e){return~~(d*e)},_calculateWindow:function(){var a=this.collection,b=a.state,c=b.firstPage,d=+b.lastPage;d=Math.max(0,c?d-1:d);var e=Math.max(b.currentPage,b.firstPage);e=c?e-1:e;var f=this.windowSize,g=this.slideScale,h=Math.floor(e/f)*f;e<=d-this.slideThisMuch()&&(h+=this.slideMaybe(c,d,e,f,g)*this.slideThisMuch(c,d,e,f,g));var i=Math.min(d+1,h+f);return[h,i]},makeHandles:function(){var b=[],c=this.collection,d=this._calculateWindow(),e=d[0],f=d[1];if(this.renderIndexedPageHandles)for(var g=e;f>g;g++)b.push(new this.pageHandle({collection:c,pageIndex:g}));var h=this.controls;return a.each(["back","rewind","forward","fastForward"],function(a){var d=h[a];if(d){var e={collection:c,title:d.title,label:d.label};e["is"+a.slice(0,1).toUpperCase()+a.slice(1)]=!0;var f=new this.pageHandle(e);"rewind"==a||"back"==a?b.unshift(f):b.push(f)}},this),b},render:function(){if(this.$el.empty(),this.handles)for(var a=0,b=this.handles.length;b>a;a++)this.handles[a].remove();for(var c=this.handles=this.makeHandles(),d=document.createElement("ul"),a=0;a<c.length;a++)d.appendChild(c[a].render().el);return this.el.appendChild(d),this}})}); | ||
!function(a,b){ | ||
// CommonJS | ||
"object"==typeof exports?module.exports=b(require("underscore"),require("backbone"),require("backgrid"),require("backbone.paginator")):"function"==typeof define&&define.amd?define(["underscore","backbone","backgrid","backbone.paginator"],b):b(a._,a.Backbone,a.Backgrid)}(this,function(a,b,c){"use strict";/** | ||
PageHandle is a class that renders the actual page handles and reacts to | ||
click events for pagination. | ||
This class acts in two modes - control or discrete page handle modes. If | ||
one of the `is*` flags is `true`, an instance of this class is under | ||
control page handle mode. Setting a `pageIndex` to an instance of this | ||
class under control mode has no effect and the correct page index will | ||
always be inferred from the `is*` flag. Only one of the `is*` flags should | ||
be set to `true` at a time. For example, an instance of this class cannot | ||
simultaneously be a rewind control and a fast forward control. A `label` | ||
and a `title` function or a string are required to be passed to the | ||
constuctor under this mode. If a `title` function is provided, it __MUST__ | ||
accept a hash parameter `data`, which contains a key `label`. Its result | ||
will be used to render the generated anchor's title attribute. | ||
If all of the `is*` flags is set to `false`, which is the default, an | ||
instance of this class will be in discrete page handle mode. An instance | ||
under this mode requires the `pageIndex` to be passed from the constructor | ||
as an option and it __MUST__ be a 0-based index of the list of page numbers | ||
to render. The constuctor will normalize the base to the same base the | ||
underlying PageableCollection collection instance uses. A `label` is not | ||
required under this mode, which will default to the equivalent 1-based page | ||
index calculated from `pageIndex` and the underlying PageableCollection | ||
instance. A provided `label` will still be honored however. The `title` | ||
parameter is also not required under this mode, in which case the default | ||
`title` function will be used. You are encouraged to provide your own | ||
`title` function however if you wish to localize the title strings. | ||
If this page handle represents the current page, an `active` class will be | ||
placed on the root list element. | ||
If this page handle is at the border of the list of pages, a `disabled` | ||
class will be placed on the root list element. | ||
Only page handles that are neither `active` nor `disabled` will respond to | ||
click events and triggers pagination. | ||
@class Backgrid.Extension.PageHandle | ||
*/ | ||
var d=c.Extension.PageHandle=b.View.extend({/** @property */ | ||
tagName:"li",/** @property */ | ||
events:{"click a":"changePage"},/** | ||
@property {string|function(Object.<string, string>): string} title | ||
The title to use for the `title` attribute of the generated page handle | ||
anchor elements. It can be a string or a function that takes a `data` | ||
parameter, which contains a mandatory `label` key which provides the | ||
label value to be displayed. | ||
*/ | ||
title:function(a){return"Page "+a.label},/** | ||
@property {boolean} isRewind Whether this handle represents a rewind | ||
control | ||
*/ | ||
isRewind:!1,/** | ||
@property {boolean} isBack Whether this handle represents a back | ||
control | ||
*/ | ||
isBack:!1,/** | ||
@property {boolean} isForward Whether this handle represents a forward | ||
control | ||
*/ | ||
isForward:!1,/** | ||
@property {boolean} isFastForward Whether this handle represents a fast | ||
forward control | ||
*/ | ||
isFastForward:!1,/** | ||
Initializer. | ||
@param {Object} options | ||
@param {Backbone.Collection} options.collection | ||
@param {number} pageIndex 0-based index of the page number this handle | ||
handles. This parameter will be normalized to the base the underlying | ||
PageableCollection uses. | ||
@param {string} [options.label] If provided it is used to render the | ||
anchor text, otherwise the normalized pageIndex will be used | ||
instead. Required if any of the `is*` flags is set to `true`. | ||
@param {string} [options.title] | ||
@param {boolean} [options.isRewind=false] | ||
@param {boolean} [options.isBack=false] | ||
@param {boolean} [options.isForward=false] | ||
@param {boolean} [options.isFastForward=false] | ||
*/ | ||
initialize:function(b){var c=this.collection,d=c.state,e=d.currentPage,f=d.firstPage,g=d.lastPage;a.extend(this,a.pick(b,["isRewind","isBack","isForward","isFastForward"]));var h;this.isRewind?h=f:this.isBack?h=Math.max(f,e-1):this.isForward?h=Math.min(g,e+1):this.isFastForward?h=g:(h=+b.pageIndex,h=f?h+1:h),this.pageIndex=h,this.label=(b.label||(f?h:h+1))+"";var i=b.title||this.title;this.title=a.isFunction(i)?i({label:this.label}):i},/** | ||
Renders a clickable anchor element under a list item. | ||
*/ | ||
render:function(){this.$el.empty();var a=document.createElement("a");a.href="#",this.title&&(a.title=this.title),a.innerHTML=this.label,this.el.appendChild(a);var b=this.collection,c=b.state,d=c.currentPage,e=this.pageIndex;return this.isRewind&&d==c.firstPage||this.isBack&&!b.hasPreviousPage()||this.isForward&&!b.hasNextPage()||this.isFastForward&&(d==c.lastPage||c.totalPages<1)?this.$el.addClass("disabled"):this.isRewind||this.isBack||this.isForward||this.isFastForward||c.currentPage!=e||this.$el.addClass("active"),this.delegateEvents(),this},/** | ||
jQuery click event handler. Goes to the page this PageHandle instance | ||
represents. No-op if this page handle is currently active or disabled. | ||
*/ | ||
changePage:function(a){a.preventDefault();var b=this.$el,c=this.collection;return b.hasClass("active")||b.hasClass("disabled")||(this.isRewind?c.getFirstPage({reset:!0}):this.isBack?c.getPreviousPage({reset:!0}):this.isForward?c.getNextPage({reset:!0}):this.isFastForward?c.getLastPage({reset:!0}):c.getPage(this.pageIndex,{reset:!0})),this}}),e=c.Extension.Paginator=b.View.extend({/** @property */ | ||
className:"backgrid-paginator",/** @property */ | ||
windowSize:10,/** | ||
@property {number} slideScale the number used by #slideHowMuch to scale | ||
`windowSize` to yield the number of pages to slide. For example, the | ||
default windowSize(10) * slideScale(0.5) yields 5, which means the window | ||
will slide forward 5 pages as soon as you've reached page 6. The smaller | ||
the scale factor the less pages to slide, and vice versa. | ||
Also See: | ||
- #slideMaybe | ||
- #slideHowMuch | ||
*/ | ||
slideScale:.5,/** | ||
@property {Object.<string, Object.<string, string>>} controls You can | ||
disable specific control handles by setting the keys in question to | ||
null. The defaults will be merged with your controls object, with your | ||
changes taking precedent. | ||
*/ | ||
controls:{rewind:{label:"《",title:"First"},back:{label:"〈",title:"Previous"},forward:{label:"〉",title:"Next"},fastForward:{label:"》",title:"Last"}},/** @property */ | ||
renderIndexedPageHandles:!0,/** | ||
@property renderMultiplePagesOnly. Determines if the paginator | ||
should show in cases where the collection has more than one page. | ||
Default is false for backwards compatibility. | ||
*/ | ||
renderMultiplePagesOnly:!1,/** | ||
@property {Backgrid.Extension.PageHandle} pageHandle. The PageHandle | ||
class to use for rendering individual handles | ||
*/ | ||
pageHandle:d,/** @property */ | ||
goBackFirstOnSort:!0,/** | ||
Initializer. | ||
@param {Object} options | ||
@param {Backbone.Collection} options.collection | ||
@param {boolean} [options.controls] | ||
@param {boolean} [options.pageHandle=Backgrid.Extension.PageHandle] | ||
@param {boolean} [options.goBackFirstOnSort=true] | ||
@param {boolean} [options.renderMultiplePagesOnly=false] | ||
*/ | ||
initialize:function(b){var c=this;c.controls=a.defaults(b.controls||{},c.controls,e.prototype.controls),a.extend(c,a.pick(b||{},"windowSize","pageHandle","slideScale","goBackFirstOnSort","renderIndexedPageHandles","renderMultiplePagesOnly"));var d=c.collection;c.listenTo(d,"add",c.render),c.listenTo(d,"remove",c.render),c.listenTo(d,"reset",c.render),c.listenTo(d,"backgrid:sorted",function(){c.goBackFirstOnSort&&d.state.currentPage!==d.state.firstPage&&d.getFirstPage({reset:!0})})},/** | ||
Decides whether the window should slide. This method should return 1 if | ||
sliding should occur and 0 otherwise. The default is sliding should occur | ||
if half of the pages in a window has been reached. | ||
__Note__: All the parameters have been normalized to be 0-based. | ||
@param {number} firstPage | ||
@param {number} lastPage | ||
@param {number} currentPage | ||
@param {number} windowSize | ||
@param {number} slideScale | ||
@return {0|1} | ||
*/ | ||
slideMaybe:function(a,b,c,d,e){return Math.round(c%d/d)},/** | ||
Decides how many pages to slide when sliding should occur. The default | ||
simply scales the `windowSize` to arrive at a fraction of the `windowSize` | ||
to increment. | ||
__Note__: All the parameters have been normalized to be 0-based. | ||
@param {number} firstPage | ||
@param {number} lastPage | ||
@param {number} currentPage | ||
@param {number} windowSize | ||
@param {number} slideScale | ||
@return {number} | ||
*/ | ||
slideThisMuch:function(a,b,c,d,e){return~~(d*e)},_calculateWindow:function(){var a=this.collection,b=a.state,c=b.firstPage,d=+b.lastPage;d=Math.max(0,c?d-1:d);var e=Math.max(b.currentPage,b.firstPage);e=c?e-1:e;var f=this.windowSize,g=this.slideScale,h=Math.floor(e/f)*f;e<=d-this.slideThisMuch()&&(h+=this.slideMaybe(c,d,e,f,g)*this.slideThisMuch(c,d,e,f,g));var i=Math.min(d+1,h+f);return[h,i]},/** | ||
Creates a list of page handle objects for rendering. | ||
@return {Array.<Object>} an array of page handle objects hashes | ||
*/ | ||
makeHandles:function(){var b=[],c=this.collection,d=this._calculateWindow(),e=d[0],f=d[1];if(this.renderIndexedPageHandles)for(var g=e;f>g;g++)b.push(new this.pageHandle({collection:c,pageIndex:g}));var h=this.controls;return a.each(["back","rewind","forward","fastForward"],function(a){var d=h[a];if(d){var e={collection:c,title:d.title,label:d.label};e["is"+a.slice(0,1).toUpperCase()+a.slice(1)]=!0;var f=new this.pageHandle(e);"rewind"==a||"back"==a?b.unshift(f):b.push(f)}},this),b},/** | ||
Render the paginator handles inside an unordered list. | ||
*/ | ||
render:function(){this.$el.empty();var a=this.collection.state.totalPages; | ||
// Don't render if collection is empty | ||
if(this.renderMultiplePagesOnly&&1>=a)return this;if(this.handles)for(var b=0,c=this.handles.length;c>b;b++)this.handles[b].remove();for(var d=this.handles=this.makeHandles(),e=document.createElement("ul"),b=0;b<d.length;b++)e.appendChild(d[b].render().el);return this.el.appendChild(e),this}})}); |
@@ -7,3 +7,2 @@ { | ||
], | ||
"version": "0.3.5", | ||
"description": "Backgrid.js extension for pagination.", | ||
@@ -21,13 +20,11 @@ "homepage": "https://github.com/wyuenho/backgrid-paginator", | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
"api" | ||
], | ||
"dependencies": { | ||
"backbone.paginator": "^2.0.0", | ||
"backbone": "^1.1.2", | ||
"backgrid": "~0.3.5", | ||
"underscore": "^1.5.0" | ||
"backbone": "1.1.2 || 1.2.3 || ~1.3.2", | ||
"backbone.paginator": "^2.0.5", | ||
"backgrid": "~0.3.7", | ||
"underscore": "^1.8.0" | ||
} | ||
} |
@@ -31,32 +31,10 @@ /* | ||
}, | ||
jasmine: { | ||
test: { | ||
version: "1.3.1", | ||
src: [ | ||
"backgrid-paginator.js" | ||
], | ||
options: { | ||
specs: [ | ||
"test/p*.js" | ||
], | ||
template: require("grunt-template-jasmine-istanbul"), | ||
templateOptions: { | ||
coverage: "test/coverage/coverage.json", | ||
report: { | ||
type: "html", | ||
options: { | ||
dir: "test/coverage" | ||
} | ||
} | ||
}, | ||
vendor: [ | ||
"test/vendor/js/jquery.js", | ||
"test/vendor/js/underscore.js", | ||
"test/vendor/js/backbone.js", | ||
"test/vendor/js/backgrid.js", | ||
'test/vendor/js/backbone.paginator.js' | ||
] | ||
} | ||
karma: { | ||
unit: { | ||
configFile: 'karma.conf.js', | ||
singleRun: true | ||
} | ||
}, | ||
jsduck: { | ||
@@ -71,3 +49,2 @@ main: { | ||
"categories": "categories.json", | ||
"warnings": "-no_doc", | ||
"pretty-json": true | ||
@@ -77,2 +54,3 @@ } | ||
}, | ||
recess: { | ||
@@ -96,2 +74,3 @@ csslint: { | ||
}, | ||
uglify: { | ||
@@ -115,6 +94,6 @@ options: { | ||
grunt.loadNpmTasks("grunt-jsduck"); | ||
grunt.loadNpmTasks("grunt-contrib-jasmine"); | ||
grunt.loadNpmTasks("grunt-karma"); | ||
grunt.registerTask("dist", ["uglify", "recess"]); | ||
grunt.registerTask("default", ["clean", "jsduck", "dist", "jasmine"]); | ||
grunt.registerTask("default", ["clean", "jsduck", "dist", "karma"]); | ||
}; |
{ | ||
"name": "backgrid-paginator", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"description": "Backgrid.js extension for pagination.", | ||
"main": "backgrid-paginator.js", | ||
"style": "backgrid-paginator.css", | ||
"scripts": { | ||
@@ -24,17 +25,28 @@ "test": "grunt jasmine" | ||
"dependencies": { | ||
"backbone": "^1.1.2", | ||
"backbone.paginator": "^2.0.2", | ||
"backgrid": "^0.3.5", | ||
"lodash": "^3.3.1" | ||
"backbone": "1.1.2 || 1.2.3 || ~1.3.2", | ||
"backbone.paginator": "^2.0.5", | ||
"backgrid": "~0.3.7", | ||
"underscore": "^1.8.0" | ||
}, | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-cli": "~0.1.9", | ||
"grunt-contrib-clean": "~0.4.1", | ||
"grunt-contrib-jasmine": "~0.5.1", | ||
"grunt-contrib-uglify": "~0.2.2", | ||
"grunt-jsduck": "~0.1.4", | ||
"grunt-recess": "~0.3.3", | ||
"grunt-template-jasmine-istanbul": "~0.2.4" | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-concat": "^1.0.0", | ||
"grunt-contrib-connect": "^0.11.2", | ||
"grunt-contrib-uglify": "^1.0.0", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-jsduck": "^1.0.1", | ||
"grunt-karma": "^0.12.1", | ||
"grunt-recess": "^1.0.1", | ||
"jasmine-core": "^2.4.1", | ||
"jquery": "2.1.0", | ||
"karma": "^0.13.22", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-coverage": "^0.5.5", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.8", | ||
"karma-jasmine-html-reporter": "^0.2.0", | ||
"karma-safari-launcher": "^0.1.1" | ||
} | ||
} |
@@ -741,2 +741,8 @@ /* | ||
it("does not refetch if already on first page when sorting", function () { | ||
spyOn(collection, "getFirstPage").and.stub(); | ||
collection.trigger("backgrid:sorted"); | ||
expect(collection.getFirstPage.calls.count()).toEqual(0); | ||
}); | ||
}); | ||
@@ -800,2 +806,65 @@ | ||
describe("hiding paginator when <= 1 total pages", function() { | ||
it("renders 0 handles when the collection has 1 page", function () { | ||
paginator = new Backgrid.Extension.Paginator({ | ||
collection: new Backbone.PageableCollection([], { | ||
state: { | ||
pageSize: 2 | ||
}, | ||
mode: "client" | ||
}), | ||
renderMultiplePagesOnly: true | ||
}); | ||
paginator.render(); | ||
expect(paginator.$el.find("a").length).toBe(0); | ||
paginator = new Backgrid.Extension.Paginator({ | ||
collection: new Backbone.PageableCollection([{id: 1}], { | ||
state: { | ||
pageSize: 2 | ||
}, | ||
mode: "client" | ||
}), | ||
renderMultiplePagesOnly: true | ||
}); | ||
paginator.render(); | ||
expect(paginator.$el.find("a").length).toBe(0); | ||
paginator = new Backgrid.Extension.Paginator({ | ||
collection: new Backbone.PageableCollection([{id: 1}, {id: 2}], { | ||
state: { | ||
pageSize: 2 | ||
}, | ||
mode: "client" | ||
}), | ||
renderMultiplePagesOnly: true | ||
}); | ||
paginator.render(); | ||
expect(paginator.$el.find("a").length).toBe(0); | ||
paginator = new Backgrid.Extension.Paginator({ | ||
collection: new Backbone.PageableCollection([{id: 1}, {id: 2}, {id: 3}], { | ||
state: { | ||
pageSize: 2 | ||
}, | ||
mode: "client" | ||
}), | ||
renderMultiplePagesOnly: true | ||
}); | ||
paginator.render(); | ||
expect(paginator.$el.find("a").length).toBe(6); | ||
expect(paginator.$el.find("a[title='Page 1']").length).toBe(1); | ||
expect(paginator.$el.find("a[title='Page 2']").length).toBe(1); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
0
100
306896
19
47
2750
2
+ Addedunderscore@^1.8.0
- Removedlodash@^3.3.1
- Removedbackbone@1.6.0(transitive)
- Removedlodash@3.10.1(transitive)
Updatedbackbone.paginator@^2.0.5
Updatedbackgrid@~0.3.7