diff --git a/api/index.html b/api/index.html index 16d8c6c..344b036 100644 --- a/api/index.html +++ b/api/index.html @@ -45,7 +45,7 @@

Paginator

- + diff --git a/api/output/Backgrid.Extension.Paginator.js b/api/output/Backgrid.Extension.Paginator.js index 2011460..0f53137 100644 --- a/api/output/Backgrid.Extension.Paginator.js +++ b/api/output/Backgrid.Extension.Paginator.js @@ -140,7 +140,7 @@ Ext.data.JsonP.Backgrid_Extension_Paginator({ ] }, - "linenr": 196, + "linenr": 205, "files": [ { "filename": "backgrid-paginator.js", diff --git a/backgrid-paginator.min.js b/backgrid-paginator.min.js index 30ac8f6..8f9fd39 100644 --- a/backgrid-paginator.min.js +++ b/backgrid-paginator.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -!function(a,b){"object"==typeof exports?module.exports=b(require("underscore"),require("backbone"),require("backgrid"),require("backbone-pageable")):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:a.template("Page <%- label %>",null,{variable:null}),isRewind:!1,isBack:!1,isForward:!1,isFastForward:!1,initialize:function(c){b.View.prototype.initialize.apply(this,arguments);var d=this.collection,e=d.state,f=e.currentPage,g=e.firstPage,h=e.lastPage;a.extend(this,a.pick(c,["isRewind","isBack","isForward","isFastForward"]));var i;this.isRewind?i=g:this.isBack?i=Math.max(g,f-1):this.isForward?i=Math.min(h,f+1):this.isFastForward?i=h:(i=+c.pageIndex,i=g?i+1:i),this.pageIndex=i,(this.isRewind||this.isBack)&&f==g||(this.isForward||this.isFastForward)&&(f==h||d.state.totalPages<1)?this.$el.addClass("disabled"):this.isRewind||this.isBack||this.isForward||this.isFastForward||f!=i||this.$el.addClass("active"),this.label=(c.label||(g?i:i+1))+"";var j=c.title||this.title;this.title=a.isFunction(j)?j({label:this.label}):j},render:function(){this.$el.empty();var a=document.createElement("a");return a.href="#",this.title&&(a.title=this.title),a.innerHTML=this.label,this.el.appendChild(a),this.delegateEvents(),this},changePage:function(a){a.preventDefault();var b=this.$el;return b.hasClass("active")||b.hasClass("disabled")||this.collection.getPage(this.pageIndex),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(this,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:sort",function(){c.goBackFirstOnSort&&d.getFirstPage()})},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",null,{variable:null}),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.hasPrevious()||this.isForward&&!b.hasNext()||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;aCode coverage report for backgrid-paginator.js

- Statements: 99% (99 / 100)      + Statements: 99.1% (110 / 111)      - Branches: 90.77% (59 / 65)      + Branches: 92% (69 / 75)      Functions: 100% (13 / 13)      - Lines: 98.92% (92 / 93)      + Lines: 99% (99 / 100)     

All files » ./ » ckgrid-paginator.js
@@ -617,7 +617,16 @@

416 417 418 -419  +419 +420 +421 +422 +423 +424 +425 +426 +427 +428        @@ -743,58 +752,63 @@

      -535 +493 +493 +493 +493 +493   -535 -535 -535 -535 -535 +493   -535   +493 +493 +416 +339 +261   -535 -535 -452 -369 -285 +183 +183   -201 -201 +493   -535 +493 +493 +493   -535     -150   -385     +493 +493 +493 +493 +493 +493   +493 +493 +493 +493   -83 +493     -535 -535 -535   +144   +349         -535 -535 -535 -535 -535 -535 -535 -535 +77 +  +  +493 +493       @@ -806,6 +820,10 @@

19 19 19 +16 +13 +11 +8   19   @@ -924,7 +942,7 @@

      -85 +79       @@ -943,28 +961,28 @@

      -170 +158       -85 -85 +79 +79     -85 -85 -85 -85 -85 -85 -85 -85 -85 -85 +79 +79 +79 +79 +79 +79 +79 +79 +79 +79     -85 -85 +79 +79       @@ -974,62 +992,62 @@

      -80 -80 +74 +74   -80 -80 +74 +74   -80 -77 -193 +74 +71 +175             -80 -80 -320 -320 -320 +74 +74 +296 +296 +296         -320 -320 -320 -160 +296 +296 +296 +148       -80 +74             -80 +74   -80 -46 -306 +74 +40 +264       -80 +74   -80 -80 -513 +74 +74 +471     -80 +74   -80 +74       @@ -1161,8 +1179,6 @@

@param {boolean} [options.isFastForward=false] */ initialize: function (options) { - Backbone.View.prototype.initialize.apply(this, arguments); -  var collection = this.collection; var state = collection.state; var currentPage = state.currentPage; @@ -1182,19 +1198,6 @@

pageIndex = (firstPage ? pageIndex + 1 : pageIndex); } this.pageIndex = pageIndex; -  - if (((this.isRewind || this.isBack) && currentPage == firstPage) || - ((this.isForward || this.isFastForward) && - (currentPage == lastPage || collection.state.totalPages < 1))) { - this.$el.addClass("disabled"); - } - else if (!(this.isRewind || - this.isBack || - this.isForward || - this.isFastForward) && - currentPage == pageIndex) { - this.$el.addClass("active"); - }   this.label = (options.label || (firstPage ? pageIndex : pageIndex + 1)) + ''; var title = options.title || this.title; @@ -1211,6 +1214,26 @@

Eif (this.title) anchor.title = this.title; anchor.innerHTML = this.label; this.el.appendChild(anchor); +  + var collection = this.collection; + var state = collection.state; + var currentPage = state.currentPage; + var pageIndex = this.pageIndex; +  + if (this.isRewind && currentPage == state.firstPage || + this.isBack && !collection.hasPrevious() || + this.isForward && !collection.hasNext() || + this.isFastForward && (currentPage == state.lastPage || state.totalPages < 1)) { + this.$el.addClass("disabled"); + } + else if (!(this.isRewind || + this.isBack || + this.isForward || + this.isFastForward) && + state.currentPage == pageIndex) { + this.$el.addClass("active"); + } +  this.delegateEvents(); return this; }, @@ -1221,9 +1244,13 @@

*/ changePage: function (e) { e.preventDefault(); - var $el = this.$el; + var $el = this.$el, col = this.collection; Eif (!$el.hasClass("active") && !$el.hasClass("disabled")) { - this.collection.getPage(this.pageIndex); + if (this.isRewind) col.getFirstPage(); + else if (this.isBack) col.getPreviousPage(); + else if (this.isForward) col.getNextPage(); + else if (this.isFastForward) col.getLastPage(); + else col.getPage(this.pageIndex, {reset: true}); } return this; } @@ -1313,16 +1340,16 @@

self.controls = _.defaults(options.controls || {}, self.controls, Paginator.prototype.controls);   - _.extend(this, _.pick(options || {}, "windowSize", "pageHandle", + _.extend(self, _.pick(options || {}, "windowSize", "pageHandle", "slideScale", "goBackFirstOnSort", "renderIndexedPageHandles"));   - var collection = self.collection; - self.listenTo(collection, "add", self.render); - self.listenTo(collection, "remove", self.render); - self.listenTo(collection, "reset", self.render); - self.listenTo(collection, "backgrid:sort", function () { - if (self.goBackFirstOnSort) collection.getFirstPage(); + var col = self.collection; + self.listenTo(col, "add", self.render); + self.listenTo(col, "remove", self.render); + self.listenTo(col, "reset", self.render); + self.listenTo(col, "backgrid:sorted", function () { + if (self.goBackFirstOnSort) col.getFirstPage({reset: true}); }); },   @@ -1458,7 +1485,7 @@

diff --git a/test/coverage/coverage.json b/test/coverage/coverage.json index 3991224..9936f54 100644 --- a/test/coverage/coverage.json +++ b/test/coverage/coverage.json @@ -1 +1 @@ -{"backgrid-paginator.js":{"path":"backgrid-paginator.js","s":{"1":1,"2":1,"3":0,"4":1,"5":1,"6":535,"7":535,"8":535,"9":535,"10":535,"11":535,"12":535,"13":535,"14":535,"15":83,"16":452,"17":83,"18":369,"19":84,"20":285,"21":84,"22":201,"23":201,"24":535,"25":535,"26":150,"27":385,"28":83,"29":535,"30":535,"31":535,"32":535,"33":535,"34":535,"35":535,"36":535,"37":535,"38":535,"39":535,"40":535,"41":19,"42":19,"43":19,"44":19,"45":19,"46":1,"47":37,"48":37,"49":37,"50":37,"51":37,"52":37,"53":37,"54":37,"55":2,"56":1,"57":85,"58":170,"59":85,"60":85,"61":85,"62":85,"63":85,"64":85,"65":85,"66":85,"67":85,"68":85,"69":85,"70":85,"71":85,"72":85,"73":80,"74":80,"75":80,"76":80,"77":80,"78":77,"79":193,"80":80,"81":80,"82":320,"83":320,"84":320,"85":320,"86":320,"87":320,"88":160,"89":160,"90":80,"91":80,"92":80,"93":46,"94":306,"95":80,"96":80,"97":80,"98":513,"99":80,"100":80},"b":{"1":[0,1],"2":[83,452],"3":[83,369],"4":[84,285],"5":[84,201],"6":[141,60],"7":[150,385],"8":[535,452,166,413,329,168,148],"9":[83,302],"10":[385,201],"11":[385,363,341,271],"12":[535,202],"13":[142,60],"14":[535,201],"15":[202,333],"16":[535,0],"17":[19,0],"18":[19,19],"19":[37,37],"20":[37,0],"21":[1,1],"22":[65,20],"23":[65,20],"24":[85,0],"25":[77,3],"26":[320,0],"27":[160,160],"28":[320,240],"29":[46,34]},"f":{"1":1,"2":1,"3":535,"4":535,"5":19,"6":37,"7":2,"8":85,"9":170,"10":85,"11":80,"12":320,"13":80},"fnMap":{"1":{"name":"(anonymous_1)","line":8,"loc":{"start":{"line":8,"column":1},"end":{"line":8,"column":26}}},"2":{"name":"(anonymous_2)","line":22,"loc":{"start":{"line":22,"column":8},"end":{"line":22,"column":41}}},"3":{"name":"(anonymous_3)","line":126,"loc":{"start":{"line":126,"column":16},"end":{"line":126,"column":35}}},"4":{"name":"(anonymous_4)","line":170,"loc":{"start":{"line":170,"column":12},"end":{"line":170,"column":24}}},"5":{"name":"(anonymous_5)","line":185,"loc":{"start":{"line":185,"column":16},"end":{"line":185,"column":29}}},"6":{"name":"(anonymous_6)","line":274,"loc":{"start":{"line":274,"column":16},"end":{"line":274,"column":35}}},"7":{"name":"(anonymous_7)","line":287,"loc":{"start":{"line":287,"column":49},"end":{"line":287,"column":61}}},"8":{"name":"(anonymous_8)","line":307,"loc":{"start":{"line":307,"column":16},"end":{"line":307,"column":84}}},"9":{"name":"(anonymous_9)","line":326,"loc":{"start":{"line":326,"column":19},"end":{"line":326,"column":87}}},"10":{"name":"(anonymous_10)","line":330,"loc":{"start":{"line":330,"column":22},"end":{"line":330,"column":34}}},"11":{"name":"(anonymous_11)","line":356,"loc":{"start":{"line":356,"column":17},"end":{"line":356,"column":29}}},"12":{"name":"(anonymous_12)","line":374,"loc":{"start":{"line":374,"column":59},"end":{"line":374,"column":74}}},"13":{"name":"(anonymous_13)","line":395,"loc":{"start":{"line":395,"column":12},"end":{"line":395,"column":24}}}},"statementMap":{"1":{"start":{"line":8,"column":0},"end":{"line":418,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":20,"column":3}},"3":{"start":{"line":12,"column":4},"end":{"line":15,"column":59}},"4":{"start":{"line":19,"column":4},"end":{"line":19,"column":50}},"5":{"start":{"line":67,"column":2},"end":{"line":194,"column":5}},"6":{"start":{"line":127,"column":6},"end":{"line":127,"column":64}},"7":{"start":{"line":129,"column":6},"end":{"line":129,"column":39}},"8":{"start":{"line":130,"column":6},"end":{"line":130,"column":35}},"9":{"start":{"line":131,"column":6},"end":{"line":131,"column":42}},"10":{"start":{"line":132,"column":6},"end":{"line":132,"column":38}},"11":{"start":{"line":133,"column":6},"end":{"line":133,"column":36}},"12":{"start":{"line":135,"column":6},"end":{"line":136,"column":83}},"13":{"start":{"line":138,"column":6},"end":{"line":138,"column":20}},"14":{"start":{"line":139,"column":6},"end":{"line":146,"column":7}},"15":{"start":{"line":139,"column":25},"end":{"line":139,"column":47}},"16":{"start":{"line":140,"column":11},"end":{"line":146,"column":7}},"17":{"start":{"line":140,"column":28},"end":{"line":140,"column":77}},"18":{"start":{"line":141,"column":11},"end":{"line":146,"column":7}},"19":{"start":{"line":141,"column":31},"end":{"line":141,"column":79}},"20":{"start":{"line":142,"column":11},"end":{"line":146,"column":7}},"21":{"start":{"line":142,"column":35},"end":{"line":142,"column":56}},"22":{"start":{"line":144,"column":8},"end":{"line":144,"column":39}},"23":{"start":{"line":145,"column":8},"end":{"line":145,"column":60}},"24":{"start":{"line":147,"column":6},"end":{"line":147,"column":33}},"25":{"start":{"line":149,"column":6},"end":{"line":160,"column":7}},"26":{"start":{"line":152,"column":8},"end":{"line":152,"column":38}},"27":{"start":{"line":154,"column":11},"end":{"line":160,"column":7}},"28":{"start":{"line":159,"column":8},"end":{"line":159,"column":36}},"29":{"start":{"line":162,"column":6},"end":{"line":162,"column":83}},"30":{"start":{"line":163,"column":6},"end":{"line":163,"column":46}},"31":{"start":{"line":164,"column":6},"end":{"line":164,"column":76}},"32":{"start":{"line":171,"column":6},"end":{"line":171,"column":23}},"33":{"start":{"line":172,"column":6},"end":{"line":172,"column":47}},"34":{"start":{"line":173,"column":6},"end":{"line":173,"column":24}},"35":{"start":{"line":174,"column":6},"end":{"line":174,"column":48}},"36":{"start":{"line":174,"column":22},"end":{"line":174,"column":48}},"37":{"start":{"line":175,"column":6},"end":{"line":175,"column":36}},"38":{"start":{"line":176,"column":6},"end":{"line":176,"column":34}},"39":{"start":{"line":177,"column":6},"end":{"line":177,"column":28}},"40":{"start":{"line":178,"column":6},"end":{"line":178,"column":18}},"41":{"start":{"line":186,"column":6},"end":{"line":186,"column":25}},"42":{"start":{"line":187,"column":6},"end":{"line":187,"column":25}},"43":{"start":{"line":188,"column":6},"end":{"line":190,"column":7}},"44":{"start":{"line":189,"column":8},"end":{"line":189,"column":48}},"45":{"start":{"line":191,"column":6},"end":{"line":191,"column":18}},"46":{"start":{"line":206,"column":2},"end":{"line":416,"column":5}},"47":{"start":{"line":275,"column":6},"end":{"line":275,"column":22}},"48":{"start":{"line":276,"column":6},"end":{"line":277,"column":63}},"49":{"start":{"line":279,"column":6},"end":{"line":281,"column":57}},"50":{"start":{"line":283,"column":6},"end":{"line":283,"column":39}},"51":{"start":{"line":284,"column":6},"end":{"line":284,"column":52}},"52":{"start":{"line":285,"column":6},"end":{"line":285,"column":55}},"53":{"start":{"line":286,"column":6},"end":{"line":286,"column":54}},"54":{"start":{"line":287,"column":6},"end":{"line":289,"column":9}},"55":{"start":{"line":288,"column":8},"end":{"line":288,"column":62}},"56":{"start":{"line":288,"column":36},"end":{"line":288,"column":62}},"57":{"start":{"line":308,"column":6},"end":{"line":308,"column":63}},"58":{"start":{"line":327,"column":6},"end":{"line":327,"column":41}},"59":{"start":{"line":331,"column":6},"end":{"line":331,"column":39}},"60":{"start":{"line":332,"column":6},"end":{"line":332,"column":35}},"61":{"start":{"line":335,"column":6},"end":{"line":335,"column":38}},"62":{"start":{"line":336,"column":6},"end":{"line":336,"column":37}},"63":{"start":{"line":337,"column":6},"end":{"line":337,"column":66}},"64":{"start":{"line":338,"column":6},"end":{"line":338,"column":69}},"65":{"start":{"line":339,"column":6},"end":{"line":339,"column":62}},"66":{"start":{"line":340,"column":6},"end":{"line":340,"column":39}},"67":{"start":{"line":341,"column":6},"end":{"line":341,"column":39}},"68":{"start":{"line":342,"column":6},"end":{"line":342,"column":74}},"69":{"start":{"line":343,"column":6},"end":{"line":346,"column":7}},"70":{"start":{"line":344,"column":8},"end":{"line":345,"column":102}},"71":{"start":{"line":347,"column":6},"end":{"line":347,"column":71}},"72":{"start":{"line":348,"column":6},"end":{"line":348,"column":38}},"73":{"start":{"line":358,"column":6},"end":{"line":358,"column":23}},"74":{"start":{"line":359,"column":6},"end":{"line":359,"column":39}},"75":{"start":{"line":361,"column":6},"end":{"line":361,"column":43}},"76":{"start":{"line":362,"column":6},"end":{"line":362,"column":51}},"77":{"start":{"line":364,"column":6},"end":{"line":371,"column":7}},"78":{"start":{"line":365,"column":8},"end":{"line":370,"column":9}},"79":{"start":{"line":366,"column":10},"end":{"line":369,"column":14}},"80":{"start":{"line":373,"column":6},"end":{"line":373,"column":35}},"81":{"start":{"line":374,"column":6},"end":{"line":387,"column":15}},"82":{"start":{"line":375,"column":8},"end":{"line":375,"column":34}},"83":{"start":{"line":376,"column":8},"end":{"line":386,"column":9}},"84":{"start":{"line":377,"column":10},"end":{"line":381,"column":12}},"85":{"start":{"line":382,"column":10},"end":{"line":382,"column":85}},"86":{"start":{"line":383,"column":10},"end":{"line":383,"column":59}},"87":{"start":{"line":384,"column":10},"end":{"line":385,"column":36}},"88":{"start":{"line":384,"column":48},"end":{"line":384,"column":72}},"89":{"start":{"line":385,"column":15},"end":{"line":385,"column":36}},"90":{"start":{"line":389,"column":6},"end":{"line":389,"column":21}},"91":{"start":{"line":396,"column":6},"end":{"line":396,"column":23}},"92":{"start":{"line":398,"column":6},"end":{"line":402,"column":7}},"93":{"start":{"line":399,"column":8},"end":{"line":401,"column":9}},"94":{"start":{"line":400,"column":10},"end":{"line":400,"column":35}},"95":{"start":{"line":404,"column":6},"end":{"line":404,"column":54}},"96":{"start":{"line":406,"column":6},"end":{"line":406,"column":44}},"97":{"start":{"line":407,"column":6},"end":{"line":409,"column":7}},"98":{"start":{"line":408,"column":8},"end":{"line":408,"column":47}},"99":{"start":{"line":411,"column":6},"end":{"line":411,"column":30}},"100":{"start":{"line":413,"column":6},"end":{"line":413,"column":18}}},"branchMap":{"1":{"line":11,"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":11,"column":2}},{"start":{"line":11,"column":2},"end":{"line":11,"column":2}}]},"2":{"line":139,"type":"if","locations":[{"start":{"line":139,"column":6},"end":{"line":139,"column":6}},{"start":{"line":139,"column":6},"end":{"line":139,"column":6}}]},"3":{"line":140,"type":"if","locations":[{"start":{"line":140,"column":11},"end":{"line":140,"column":11}},{"start":{"line":140,"column":11},"end":{"line":140,"column":11}}]},"4":{"line":141,"type":"if","locations":[{"start":{"line":141,"column":11},"end":{"line":141,"column":11}},{"start":{"line":141,"column":11},"end":{"line":141,"column":11}}]},"5":{"line":142,"type":"if","locations":[{"start":{"line":142,"column":11},"end":{"line":142,"column":11}},{"start":{"line":142,"column":11},"end":{"line":142,"column":11}}]},"6":{"line":145,"type":"cond-expr","locations":[{"start":{"line":145,"column":33},"end":{"line":145,"column":46}},{"start":{"line":145,"column":49},"end":{"line":145,"column":58}}]},"7":{"line":149,"type":"if","locations":[{"start":{"line":149,"column":6},"end":{"line":149,"column":6}},{"start":{"line":149,"column":6},"end":{"line":149,"column":6}}]},"8":{"line":149,"type":"binary-expr","locations":[{"start":{"line":149,"column":12},"end":{"line":149,"column":25}},{"start":{"line":149,"column":29},"end":{"line":149,"column":40}},{"start":{"line":149,"column":45},"end":{"line":149,"column":69}},{"start":{"line":150,"column":12},"end":{"line":150,"column":26}},{"start":{"line":150,"column":30},"end":{"line":150,"column":48}},{"start":{"line":151,"column":12},"end":{"line":151,"column":35}},{"start":{"line":151,"column":39},"end":{"line":151,"column":70}}]},"9":{"line":154,"type":"if","locations":[{"start":{"line":154,"column":11},"end":{"line":154,"column":11}},{"start":{"line":154,"column":11},"end":{"line":154,"column":11}}]},"10":{"line":154,"type":"binary-expr","locations":[{"start":{"line":154,"column":15},"end":{"line":157,"column":36}},{"start":{"line":158,"column":15},"end":{"line":158,"column":39}}]},"11":{"line":154,"type":"binary-expr","locations":[{"start":{"line":154,"column":17},"end":{"line":154,"column":30}},{"start":{"line":155,"column":17},"end":{"line":155,"column":28}},{"start":{"line":156,"column":17},"end":{"line":156,"column":31}},{"start":{"line":157,"column":17},"end":{"line":157,"column":35}}]},"12":{"line":162,"type":"binary-expr","locations":[{"start":{"line":162,"column":20},"end":{"line":162,"column":33}},{"start":{"line":162,"column":38},"end":{"line":162,"column":75}}]},"13":{"line":162,"type":"cond-expr","locations":[{"start":{"line":162,"column":50},"end":{"line":162,"column":59}},{"start":{"line":162,"column":62},"end":{"line":162,"column":75}}]},"14":{"line":163,"type":"binary-expr","locations":[{"start":{"line":163,"column":18},"end":{"line":163,"column":31}},{"start":{"line":163,"column":35},"end":{"line":163,"column":45}}]},"15":{"line":164,"type":"cond-expr","locations":[{"start":{"line":164,"column":41},"end":{"line":164,"column":67}},{"start":{"line":164,"column":70},"end":{"line":164,"column":75}}]},"16":{"line":174,"type":"if","locations":[{"start":{"line":174,"column":6},"end":{"line":174,"column":6}},{"start":{"line":174,"column":6},"end":{"line":174,"column":6}}]},"17":{"line":188,"type":"if","locations":[{"start":{"line":188,"column":6},"end":{"line":188,"column":6}},{"start":{"line":188,"column":6},"end":{"line":188,"column":6}}]},"18":{"line":188,"type":"binary-expr","locations":[{"start":{"line":188,"column":10},"end":{"line":188,"column":33}},{"start":{"line":188,"column":37},"end":{"line":188,"column":62}}]},"19":{"line":276,"type":"binary-expr","locations":[{"start":{"line":276,"column":33},"end":{"line":276,"column":49}},{"start":{"line":276,"column":53},"end":{"line":276,"column":55}}]},"20":{"line":279,"type":"binary-expr","locations":[{"start":{"line":279,"column":28},"end":{"line":279,"column":35}},{"start":{"line":279,"column":39},"end":{"line":279,"column":41}}]},"21":{"line":288,"type":"if","locations":[{"start":{"line":288,"column":8},"end":{"line":288,"column":8}},{"start":{"line":288,"column":8},"end":{"line":288,"column":8}}]},"22":{"line":337,"type":"cond-expr","locations":[{"start":{"line":337,"column":41},"end":{"line":337,"column":53}},{"start":{"line":337,"column":56},"end":{"line":337,"column":64}}]},"23":{"line":339,"type":"cond-expr","locations":[{"start":{"line":339,"column":32},"end":{"line":339,"column":47}},{"start":{"line":339,"column":50},"end":{"line":339,"column":61}}]},"24":{"line":343,"type":"if","locations":[{"start":{"line":343,"column":6},"end":{"line":343,"column":6}},{"start":{"line":343,"column":6},"end":{"line":343,"column":6}}]},"25":{"line":364,"type":"if","locations":[{"start":{"line":364,"column":6},"end":{"line":364,"column":6}},{"start":{"line":364,"column":6},"end":{"line":364,"column":6}}]},"26":{"line":376,"type":"if","locations":[{"start":{"line":376,"column":8},"end":{"line":376,"column":8}},{"start":{"line":376,"column":8},"end":{"line":376,"column":8}}]},"27":{"line":384,"type":"if","locations":[{"start":{"line":384,"column":10},"end":{"line":384,"column":10}},{"start":{"line":384,"column":10},"end":{"line":384,"column":10}}]},"28":{"line":384,"type":"binary-expr","locations":[{"start":{"line":384,"column":14},"end":{"line":384,"column":29}},{"start":{"line":384,"column":33},"end":{"line":384,"column":46}}]},"29":{"line":398,"type":"if","locations":[{"start":{"line":398,"column":6},"end":{"line":398,"column":6}},{"start":{"line":398,"column":6},"end":{"line":398,"column":6}}]}}}} \ No newline at end of file +{"backgrid-paginator.js":{"path":"backgrid-paginator.js","s":{"1":1,"2":1,"3":0,"4":1,"5":1,"6":493,"7":493,"8":493,"9":493,"10":493,"11":493,"12":493,"13":493,"14":77,"15":416,"16":77,"17":339,"18":78,"19":261,"20":78,"21":183,"22":183,"23":493,"24":493,"25":493,"26":493,"27":493,"28":493,"29":493,"30":493,"31":493,"32":493,"33":493,"34":493,"35":493,"36":493,"37":493,"38":493,"39":144,"40":349,"41":77,"42":493,"43":493,"44":19,"45":19,"46":19,"47":19,"48":3,"49":16,"50":3,"51":13,"52":2,"53":11,"54":3,"55":8,"56":19,"57":1,"58":37,"59":37,"60":37,"61":37,"62":37,"63":37,"64":37,"65":37,"66":2,"67":1,"68":79,"69":158,"70":79,"71":79,"72":79,"73":79,"74":79,"75":79,"76":79,"77":79,"78":79,"79":79,"80":79,"81":79,"82":79,"83":79,"84":74,"85":74,"86":74,"87":74,"88":74,"89":71,"90":175,"91":74,"92":74,"93":296,"94":296,"95":296,"96":296,"97":296,"98":296,"99":148,"100":148,"101":74,"102":74,"103":74,"104":40,"105":264,"106":74,"107":74,"108":74,"109":471,"110":74,"111":74},"b":{"1":[0,1],"2":[77,416],"3":[77,339],"4":[78,261],"5":[78,183],"6":[141,42],"7":[493,184],"8":[142,42],"9":[493,183],"10":[184,309],"11":[493,0],"12":[144,349],"13":[493,77,435,77,377,78,363,78,68],"14":[77,272],"15":[349,183],"16":[349,330,311,247],"17":[19,0],"18":[19,19],"19":[3,16],"20":[3,13],"21":[2,11],"22":[3,8],"23":[37,37],"24":[37,0],"25":[1,1],"26":[65,14],"27":[65,14],"28":[79,0],"29":[71,3],"30":[296,0],"31":[148,148],"32":[296,222],"33":[40,34]},"f":{"1":1,"2":1,"3":493,"4":493,"5":19,"6":37,"7":2,"8":79,"9":158,"10":79,"11":74,"12":296,"13":74},"fnMap":{"1":{"name":"(anonymous_1)","line":8,"loc":{"start":{"line":8,"column":1},"end":{"line":8,"column":26}}},"2":{"name":"(anonymous_2)","line":22,"loc":{"start":{"line":22,"column":8},"end":{"line":22,"column":41}}},"3":{"name":"(anonymous_3)","line":126,"loc":{"start":{"line":126,"column":16},"end":{"line":126,"column":35}}},"4":{"name":"(anonymous_4)","line":155,"loc":{"start":{"line":155,"column":12},"end":{"line":155,"column":24}}},"5":{"name":"(anonymous_5)","line":190,"loc":{"start":{"line":190,"column":16},"end":{"line":190,"column":29}}},"6":{"name":"(anonymous_6)","line":283,"loc":{"start":{"line":283,"column":16},"end":{"line":283,"column":35}}},"7":{"name":"(anonymous_7)","line":296,"loc":{"start":{"line":296,"column":44},"end":{"line":296,"column":56}}},"8":{"name":"(anonymous_8)","line":316,"loc":{"start":{"line":316,"column":16},"end":{"line":316,"column":84}}},"9":{"name":"(anonymous_9)","line":335,"loc":{"start":{"line":335,"column":19},"end":{"line":335,"column":87}}},"10":{"name":"(anonymous_10)","line":339,"loc":{"start":{"line":339,"column":22},"end":{"line":339,"column":34}}},"11":{"name":"(anonymous_11)","line":365,"loc":{"start":{"line":365,"column":17},"end":{"line":365,"column":29}}},"12":{"name":"(anonymous_12)","line":383,"loc":{"start":{"line":383,"column":59},"end":{"line":383,"column":74}}},"13":{"name":"(anonymous_13)","line":404,"loc":{"start":{"line":404,"column":12},"end":{"line":404,"column":24}}}},"statementMap":{"1":{"start":{"line":8,"column":0},"end":{"line":427,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":20,"column":3}},"3":{"start":{"line":12,"column":4},"end":{"line":15,"column":59}},"4":{"start":{"line":19,"column":4},"end":{"line":19,"column":50}},"5":{"start":{"line":67,"column":2},"end":{"line":203,"column":5}},"6":{"start":{"line":127,"column":6},"end":{"line":127,"column":39}},"7":{"start":{"line":128,"column":6},"end":{"line":128,"column":35}},"8":{"start":{"line":129,"column":6},"end":{"line":129,"column":42}},"9":{"start":{"line":130,"column":6},"end":{"line":130,"column":38}},"10":{"start":{"line":131,"column":6},"end":{"line":131,"column":36}},"11":{"start":{"line":133,"column":6},"end":{"line":134,"column":83}},"12":{"start":{"line":136,"column":6},"end":{"line":136,"column":20}},"13":{"start":{"line":137,"column":6},"end":{"line":144,"column":7}},"14":{"start":{"line":137,"column":25},"end":{"line":137,"column":47}},"15":{"start":{"line":138,"column":11},"end":{"line":144,"column":7}},"16":{"start":{"line":138,"column":28},"end":{"line":138,"column":77}},"17":{"start":{"line":139,"column":11},"end":{"line":144,"column":7}},"18":{"start":{"line":139,"column":31},"end":{"line":139,"column":79}},"19":{"start":{"line":140,"column":11},"end":{"line":144,"column":7}},"20":{"start":{"line":140,"column":35},"end":{"line":140,"column":56}},"21":{"start":{"line":142,"column":8},"end":{"line":142,"column":39}},"22":{"start":{"line":143,"column":8},"end":{"line":143,"column":60}},"23":{"start":{"line":145,"column":6},"end":{"line":145,"column":33}},"24":{"start":{"line":147,"column":6},"end":{"line":147,"column":83}},"25":{"start":{"line":148,"column":6},"end":{"line":148,"column":46}},"26":{"start":{"line":149,"column":6},"end":{"line":149,"column":76}},"27":{"start":{"line":156,"column":6},"end":{"line":156,"column":23}},"28":{"start":{"line":157,"column":6},"end":{"line":157,"column":47}},"29":{"start":{"line":158,"column":6},"end":{"line":158,"column":24}},"30":{"start":{"line":159,"column":6},"end":{"line":159,"column":48}},"31":{"start":{"line":159,"column":22},"end":{"line":159,"column":48}},"32":{"start":{"line":160,"column":6},"end":{"line":160,"column":36}},"33":{"start":{"line":161,"column":6},"end":{"line":161,"column":34}},"34":{"start":{"line":163,"column":6},"end":{"line":163,"column":39}},"35":{"start":{"line":164,"column":6},"end":{"line":164,"column":35}},"36":{"start":{"line":165,"column":6},"end":{"line":165,"column":42}},"37":{"start":{"line":166,"column":6},"end":{"line":166,"column":37}},"38":{"start":{"line":168,"column":6},"end":{"line":180,"column":7}},"39":{"start":{"line":172,"column":8},"end":{"line":172,"column":38}},"40":{"start":{"line":174,"column":11},"end":{"line":180,"column":7}},"41":{"start":{"line":179,"column":8},"end":{"line":179,"column":36}},"42":{"start":{"line":182,"column":6},"end":{"line":182,"column":28}},"43":{"start":{"line":183,"column":6},"end":{"line":183,"column":18}},"44":{"start":{"line":191,"column":6},"end":{"line":191,"column":25}},"45":{"start":{"line":192,"column":6},"end":{"line":192,"column":48}},"46":{"start":{"line":193,"column":6},"end":{"line":199,"column":7}},"47":{"start":{"line":194,"column":8},"end":{"line":198,"column":56}},"48":{"start":{"line":194,"column":27},"end":{"line":194,"column":46}},"49":{"start":{"line":195,"column":13},"end":{"line":198,"column":56}},"50":{"start":{"line":195,"column":30},"end":{"line":195,"column":52}},"51":{"start":{"line":196,"column":13},"end":{"line":198,"column":56}},"52":{"start":{"line":196,"column":33},"end":{"line":196,"column":51}},"53":{"start":{"line":197,"column":13},"end":{"line":198,"column":56}},"54":{"start":{"line":197,"column":37},"end":{"line":197,"column":55}},"55":{"start":{"line":198,"column":13},"end":{"line":198,"column":56}},"56":{"start":{"line":200,"column":6},"end":{"line":200,"column":18}},"57":{"start":{"line":215,"column":2},"end":{"line":425,"column":5}},"58":{"start":{"line":284,"column":6},"end":{"line":284,"column":22}},"59":{"start":{"line":285,"column":6},"end":{"line":286,"column":63}},"60":{"start":{"line":288,"column":6},"end":{"line":290,"column":57}},"61":{"start":{"line":292,"column":6},"end":{"line":292,"column":32}},"62":{"start":{"line":293,"column":6},"end":{"line":293,"column":45}},"63":{"start":{"line":294,"column":6},"end":{"line":294,"column":48}},"64":{"start":{"line":295,"column":6},"end":{"line":295,"column":47}},"65":{"start":{"line":296,"column":6},"end":{"line":298,"column":9}},"66":{"start":{"line":297,"column":8},"end":{"line":297,"column":68}},"67":{"start":{"line":297,"column":36},"end":{"line":297,"column":68}},"68":{"start":{"line":317,"column":6},"end":{"line":317,"column":63}},"69":{"start":{"line":336,"column":6},"end":{"line":336,"column":41}},"70":{"start":{"line":340,"column":6},"end":{"line":340,"column":39}},"71":{"start":{"line":341,"column":6},"end":{"line":341,"column":35}},"72":{"start":{"line":344,"column":6},"end":{"line":344,"column":38}},"73":{"start":{"line":345,"column":6},"end":{"line":345,"column":37}},"74":{"start":{"line":346,"column":6},"end":{"line":346,"column":66}},"75":{"start":{"line":347,"column":6},"end":{"line":347,"column":69}},"76":{"start":{"line":348,"column":6},"end":{"line":348,"column":62}},"77":{"start":{"line":349,"column":6},"end":{"line":349,"column":39}},"78":{"start":{"line":350,"column":6},"end":{"line":350,"column":39}},"79":{"start":{"line":351,"column":6},"end":{"line":351,"column":74}},"80":{"start":{"line":352,"column":6},"end":{"line":355,"column":7}},"81":{"start":{"line":353,"column":8},"end":{"line":354,"column":102}},"82":{"start":{"line":356,"column":6},"end":{"line":356,"column":71}},"83":{"start":{"line":357,"column":6},"end":{"line":357,"column":38}},"84":{"start":{"line":367,"column":6},"end":{"line":367,"column":23}},"85":{"start":{"line":368,"column":6},"end":{"line":368,"column":39}},"86":{"start":{"line":370,"column":6},"end":{"line":370,"column":43}},"87":{"start":{"line":371,"column":6},"end":{"line":371,"column":51}},"88":{"start":{"line":373,"column":6},"end":{"line":380,"column":7}},"89":{"start":{"line":374,"column":8},"end":{"line":379,"column":9}},"90":{"start":{"line":375,"column":10},"end":{"line":378,"column":14}},"91":{"start":{"line":382,"column":6},"end":{"line":382,"column":35}},"92":{"start":{"line":383,"column":6},"end":{"line":396,"column":15}},"93":{"start":{"line":384,"column":8},"end":{"line":384,"column":34}},"94":{"start":{"line":385,"column":8},"end":{"line":395,"column":9}},"95":{"start":{"line":386,"column":10},"end":{"line":390,"column":12}},"96":{"start":{"line":391,"column":10},"end":{"line":391,"column":85}},"97":{"start":{"line":392,"column":10},"end":{"line":392,"column":59}},"98":{"start":{"line":393,"column":10},"end":{"line":394,"column":36}},"99":{"start":{"line":393,"column":48},"end":{"line":393,"column":72}},"100":{"start":{"line":394,"column":15},"end":{"line":394,"column":36}},"101":{"start":{"line":398,"column":6},"end":{"line":398,"column":21}},"102":{"start":{"line":405,"column":6},"end":{"line":405,"column":23}},"103":{"start":{"line":407,"column":6},"end":{"line":411,"column":7}},"104":{"start":{"line":408,"column":8},"end":{"line":410,"column":9}},"105":{"start":{"line":409,"column":10},"end":{"line":409,"column":35}},"106":{"start":{"line":413,"column":6},"end":{"line":413,"column":54}},"107":{"start":{"line":415,"column":6},"end":{"line":415,"column":44}},"108":{"start":{"line":416,"column":6},"end":{"line":418,"column":7}},"109":{"start":{"line":417,"column":8},"end":{"line":417,"column":47}},"110":{"start":{"line":420,"column":6},"end":{"line":420,"column":30}},"111":{"start":{"line":422,"column":6},"end":{"line":422,"column":18}}},"branchMap":{"1":{"line":11,"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":11,"column":2}},{"start":{"line":11,"column":2},"end":{"line":11,"column":2}}]},"2":{"line":137,"type":"if","locations":[{"start":{"line":137,"column":6},"end":{"line":137,"column":6}},{"start":{"line":137,"column":6},"end":{"line":137,"column":6}}]},"3":{"line":138,"type":"if","locations":[{"start":{"line":138,"column":11},"end":{"line":138,"column":11}},{"start":{"line":138,"column":11},"end":{"line":138,"column":11}}]},"4":{"line":139,"type":"if","locations":[{"start":{"line":139,"column":11},"end":{"line":139,"column":11}},{"start":{"line":139,"column":11},"end":{"line":139,"column":11}}]},"5":{"line":140,"type":"if","locations":[{"start":{"line":140,"column":11},"end":{"line":140,"column":11}},{"start":{"line":140,"column":11},"end":{"line":140,"column":11}}]},"6":{"line":143,"type":"cond-expr","locations":[{"start":{"line":143,"column":33},"end":{"line":143,"column":46}},{"start":{"line":143,"column":49},"end":{"line":143,"column":58}}]},"7":{"line":147,"type":"binary-expr","locations":[{"start":{"line":147,"column":20},"end":{"line":147,"column":33}},{"start":{"line":147,"column":38},"end":{"line":147,"column":75}}]},"8":{"line":147,"type":"cond-expr","locations":[{"start":{"line":147,"column":50},"end":{"line":147,"column":59}},{"start":{"line":147,"column":62},"end":{"line":147,"column":75}}]},"9":{"line":148,"type":"binary-expr","locations":[{"start":{"line":148,"column":18},"end":{"line":148,"column":31}},{"start":{"line":148,"column":35},"end":{"line":148,"column":45}}]},"10":{"line":149,"type":"cond-expr","locations":[{"start":{"line":149,"column":41},"end":{"line":149,"column":67}},{"start":{"line":149,"column":70},"end":{"line":149,"column":75}}]},"11":{"line":159,"type":"if","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":6}},{"start":{"line":159,"column":6},"end":{"line":159,"column":6}}]},"12":{"line":168,"type":"if","locations":[{"start":{"line":168,"column":6},"end":{"line":168,"column":6}},{"start":{"line":168,"column":6},"end":{"line":168,"column":6}}]},"13":{"line":168,"type":"binary-expr","locations":[{"start":{"line":168,"column":10},"end":{"line":168,"column":23}},{"start":{"line":168,"column":27},"end":{"line":168,"column":57}},{"start":{"line":169,"column":9},"end":{"line":169,"column":20}},{"start":{"line":169,"column":24},"end":{"line":169,"column":49}},{"start":{"line":170,"column":9},"end":{"line":170,"column":23}},{"start":{"line":170,"column":27},"end":{"line":170,"column":48}},{"start":{"line":171,"column":9},"end":{"line":171,"column":27}},{"start":{"line":171,"column":32},"end":{"line":171,"column":61}},{"start":{"line":171,"column":65},"end":{"line":171,"column":85}}]},"14":{"line":174,"type":"if","locations":[{"start":{"line":174,"column":11},"end":{"line":174,"column":11}},{"start":{"line":174,"column":11},"end":{"line":174,"column":11}}]},"15":{"line":174,"type":"binary-expr","locations":[{"start":{"line":174,"column":15},"end":{"line":177,"column":36}},{"start":{"line":178,"column":15},"end":{"line":178,"column":45}}]},"16":{"line":174,"type":"binary-expr","locations":[{"start":{"line":174,"column":17},"end":{"line":174,"column":30}},{"start":{"line":175,"column":17},"end":{"line":175,"column":28}},{"start":{"line":176,"column":17},"end":{"line":176,"column":31}},{"start":{"line":177,"column":17},"end":{"line":177,"column":35}}]},"17":{"line":193,"type":"if","locations":[{"start":{"line":193,"column":6},"end":{"line":193,"column":6}},{"start":{"line":193,"column":6},"end":{"line":193,"column":6}}]},"18":{"line":193,"type":"binary-expr","locations":[{"start":{"line":193,"column":10},"end":{"line":193,"column":33}},{"start":{"line":193,"column":37},"end":{"line":193,"column":62}}]},"19":{"line":194,"type":"if","locations":[{"start":{"line":194,"column":8},"end":{"line":194,"column":8}},{"start":{"line":194,"column":8},"end":{"line":194,"column":8}}]},"20":{"line":195,"type":"if","locations":[{"start":{"line":195,"column":13},"end":{"line":195,"column":13}},{"start":{"line":195,"column":13},"end":{"line":195,"column":13}}]},"21":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":13},"end":{"line":196,"column":13}},{"start":{"line":196,"column":13},"end":{"line":196,"column":13}}]},"22":{"line":197,"type":"if","locations":[{"start":{"line":197,"column":13},"end":{"line":197,"column":13}},{"start":{"line":197,"column":13},"end":{"line":197,"column":13}}]},"23":{"line":285,"type":"binary-expr","locations":[{"start":{"line":285,"column":33},"end":{"line":285,"column":49}},{"start":{"line":285,"column":53},"end":{"line":285,"column":55}}]},"24":{"line":288,"type":"binary-expr","locations":[{"start":{"line":288,"column":28},"end":{"line":288,"column":35}},{"start":{"line":288,"column":39},"end":{"line":288,"column":41}}]},"25":{"line":297,"type":"if","locations":[{"start":{"line":297,"column":8},"end":{"line":297,"column":8}},{"start":{"line":297,"column":8},"end":{"line":297,"column":8}}]},"26":{"line":346,"type":"cond-expr","locations":[{"start":{"line":346,"column":41},"end":{"line":346,"column":53}},{"start":{"line":346,"column":56},"end":{"line":346,"column":64}}]},"27":{"line":348,"type":"cond-expr","locations":[{"start":{"line":348,"column":32},"end":{"line":348,"column":47}},{"start":{"line":348,"column":50},"end":{"line":348,"column":61}}]},"28":{"line":352,"type":"if","locations":[{"start":{"line":352,"column":6},"end":{"line":352,"column":6}},{"start":{"line":352,"column":6},"end":{"line":352,"column":6}}]},"29":{"line":373,"type":"if","locations":[{"start":{"line":373,"column":6},"end":{"line":373,"column":6}},{"start":{"line":373,"column":6},"end":{"line":373,"column":6}}]},"30":{"line":385,"type":"if","locations":[{"start":{"line":385,"column":8},"end":{"line":385,"column":8}},{"start":{"line":385,"column":8},"end":{"line":385,"column":8}}]},"31":{"line":393,"type":"if","locations":[{"start":{"line":393,"column":10},"end":{"line":393,"column":10}},{"start":{"line":393,"column":10},"end":{"line":393,"column":10}}]},"32":{"line":393,"type":"binary-expr","locations":[{"start":{"line":393,"column":14},"end":{"line":393,"column":29}},{"start":{"line":393,"column":33},"end":{"line":393,"column":46}}]},"33":{"line":407,"type":"if","locations":[{"start":{"line":407,"column":6},"end":{"line":407,"column":6}},{"start":{"line":407,"column":6},"end":{"line":407,"column":6}}]}}}} \ No newline at end of file diff --git a/test/coverage/index.html b/test/coverage/index.html index 591f4e4..d693d8b 100644 --- a/test/coverage/index.html +++ b/test/coverage/index.html @@ -183,16 +183,16 @@

Code coverage report for ./

- Statements: 99% (99 / 100)      + Statements: 99.1% (110 / 111)      - Branches: 90.77% (59 / 65)      + Branches: 92% (69 / 75)      Functions: 100% (13 / 13)      - Lines: 98.92% (92 / 93)      + Lines: 99% (99 / 100)     

All files » ./
@@ -216,15 +216,15 @@

ckgrid-paginator.js - - 99% - (99 / 100) - 90.77% - (59 / 65) + + 99.1% + (110 / 111) + 92% + (69 / 75) 100% (13 / 13) - 98.92% - (92 / 93) + 99% + (99 / 100) @@ -232,7 +232,7 @@

diff --git a/test/vendor/js/backgrid.js b/test/vendor/js/backgrid.js index bd9b466..6f8da79 100644 --- a/test/vendor/js/backgrid.js +++ b/test/vendor/js/backgrid.js @@ -169,219 +169,6 @@ _.extend(Command.prototype, { } }); -Backgrid.mount = function (childView, parentView, options) { - var el = parentView.el, children = el.childNodes; - options = _.defaults(options || {}, {at: children.length}); - childView.preRender(); - if (options.at >= children.length) el.appendChild(childView.render().el); - else el.insertBefore(childView, children[options.at]); - parentView.delegateEvents(); - childView.postRender(); -}; - -// Cross-platform `addEventListener`. -var addEventListener = function(obj, eventName, listener, useCapture) { - if (obj.addEventListener) return obj.addEventListener(eventName, listener, useCapture); - else return obj.attachEvent('on' + eventName, listener); -}; - -// Cross-platform `removeEventListener`. -var removeEventListener = function(obj, eventName, listener, useCapture) { - if (obj.removeEventListener) return obj.removeEventListener(eventName, listener, useCapture); - else return obj.detachEvent('on' + eventName, listener); -}; - -// Caches a local reference to `Element.prototype` for faster access. -var ElementProto = typeof Element != 'undefined' && Element.prototype; - -// Find the right `Element#matches` for IE>=9 and modern browsers. -var matchesSelector = ElementProto && ElementProto.matches || - ElementProto[_.find(['webkit', 'moz', 'ms', 'o'], function(prefix) { - return !!ElementProto[prefix + 'MatchesSelector']; - }) + 'MatchesSelector'] || - // Make our own `Element#matches` for IE8 - function(selector) { - // We'll use querySelectorAll to find all element matching the selector, - // then check if the given element is included in that list. - // Executing the query on the parentNode reduces the resulting nodeList, - // document doesn't have a parentNode, though. - var nodeList = (this.parentNode || document).querySelectorAll(selector) || []; - for (var i = 0, l = nodeList.length; i < l; i++) { - if (nodeList[i] == this) return true; - } - return false; - }; - -// Cached regex to split keys for `delegate`. -var delegateEventSplitter = /^(\S+)\s*(.*)$/; - -var View = Backgrid.View = Backbone.View.extend({ - - // Private list to hold all the DOM event delegation listeners. - _domEvents: [], - - preRender: function () { - return this; - }, - - postRender: function () { - return this; - }, - - show: function () { - delete this.el.style.display; - return this; - }, - - hide: function () { - this.el.style.display = "none"; - return this; - }, - - empty: function () { - var el = this.el; - while (el.firstChild) el.removeChild(el.firstChild); - return this; - }, - - // Remove this view by taking the element out of the DOM, remove all the DOM - // event listeners attached to it, and remove any applicable Backbone.Events - // listeners. - remove: function() { - this.undelegateEvents(); - var el = this.el; - var parentNode = el.parentNode; - if (parentNode) parentNode.removeChild(el); - this.stopListening(); - return this; - }, - - // Change the view's element (`this.el` property), including event - // re-delegation. If element is string, create or find that element and - // change this view's element to it. Otherwise, assume it is a DOM element - // and change this view's element to it. - setElement: function(element, delegate) { - if (this.el) this.undelegateEvents(); - if (typeof element == 'string') { - if (element[0].trim() == '<') { - var el = document.createElement('div'); - el.innerHTML = element; - this.el = el.firstChild; - } - else this.el = document.querySelector(element); - } - else this.el = element; - if (delegate !== false) this.delegateEvents(); - return this; - }, - - // Set callbacks, where `this.events` is a hash of - // - // *{"event selector": "callback"}* - // - // { - // 'mousedown .title': 'edit', - // 'click .button': 'save', - // 'click .open': function(e) { ... } - // } - // - // pairs. Callbacks will be bound to the view, with `this` set properly. - // Uses event delegation for efficiency. - // Omitting the selector binds the event to `this.el`. - // This only works for delegate-able events: not `focus`, `blur`, not - // `change`, `submit`, and `reset` in Internet Explorer, not `focusin` and - // `focusout` in Firefox, and not `mouseenter` and `mouseleave` for Chrome < - // 30 and Safari. - // - // Pass the event name, selector and the bound method to `_delegateEvents` - // for each mapping in `events`. - delegateEvents: function(events) { - if (!(events || (events = _.result(this, 'events')))) return this; - this.undelegateEvents(); - var _delegateEvents = this._delegateEvents; - for (var key in events) { - var method = events[key]; - if (typeof method != 'function') method = this[events[key]]; - if (!method) continue; - - var match = key.match(delegateEventSplitter); - var eventName = match[1], selector = match[2]; - method = method.bind && method.bind(this) || _.bind(method, this); - _delegateEvents.call(this, eventName, selector, method); - } - - return this; - }, - - // Make a event delegation handler for the given `eventName` and `selector` - // and attach it to `this.el`. - // If selector is empty, the method will be bound to `this.el`. If not, a - // new handler that will recursively traverse up the event target's DOM - // hierarchy looking for a node that matches the selector. If one is found, - // the event's `delegateTarget` property is set to it and the return the - // result of calling bound `method` with the parameters given to the - // handler. - _delegateEvents: function(eventName, selector, method) { - var root = this.el, domEvents = this._domEvents, handler; - if (!selector) handler = method; - else handler = function (e) { - var node = e.target || e.srcElement; - for (; node && node != root; node = node.parentNode) { - if (matchesSelector.call(node, selector)) { - e.delegateTarget = node; - return method.apply(this, arguments); - } - } - }; - - addEventListener(root, eventName, handler, false); - domEvents.push({eventName: eventName, handler: handler}); - }, - - // Delegates to `_undelegateEvents` so `BaseView` subclasses can override - // the default event undelegation routine. - undelegateEvents: function() { - this._undelegateEvents(); - return this; - }, - - // Clears all callbacks previously bound to the view with `delegateEvents`. - // You usually don't need to use this, but may wish to if you have multiple - // Backbone views attached to the same DOM element. - _undelegateEvents: function() { - var el = this.el, domEvents = this._domEvents, i, l, item; - if (el) { - for (i = 0, l = domEvents.length; i < l; i++) { - item = domEvents[i]; - removeEventListener(el, item.eventName, item.handler, false); - } - this._domEvents = []; - } - }, - - // Ensure that the View has a DOM element to render into. If `this.el` - // exists, it must be a string, a function or a DOM element. If it is a - // string or a DOM element, pass it through `setElement`. If it is a - // function, pass its result to `setElement`. Otherwise, create an element - // from the `id`, `className`, `tagName` and `attributes` properties, and - // pass it to `setElement`. - _ensureElement: function() { - if (!this.el) { - var el = document.createElement(_.result(this, 'tagName')); - var attrs = _.extend({}, _.result(this, 'attributes')); - if (this.id) attrs.id = _.result(this, 'id'); - if (this.className) attrs['class'] = _.result(this, 'className'); - for (var k in attrs) { - el.setAttribute(k, attrs[k]); - } - this.setElement(el, false); - } else { - this.setElement(_.result(this, 'el'), false); - } - } - -}); - /* backgrid http://github.com/wyuenho/backgrid @@ -841,9 +628,9 @@ _.extend(SelectFormatter.prototype, { @abstract @class Backgrid.CellEditor - @extends Backgrid.View + @extends Backbone.View */ -var CellEditor = Backgrid.CellEditor = Backgrid.View.extend({ +var CellEditor = Backgrid.CellEditor = Backbone.View.extend({ /** Initializer. @@ -873,7 +660,7 @@ var CellEditor = Backgrid.CellEditor = Backgrid.View.extend({ */ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.el.focus(); + this.$el.focus(); } return this; } @@ -918,7 +705,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ InputCellEditor.__super__.initialize.apply(this, arguments); if (options.placeholder) { - this.el.placeholder = options.placeholder; + this.$el.attr("placeholder", options.placeholder); } }, @@ -928,7 +715,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ */ render: function () { var model = this.model; - this.el.defaultValue = this.formatter.fromRaw(model.get(this.column.get("name")), model); + this.$el.val(this.formatter.fromRaw(model.get(this.column.get("name")), model)); return this; }, @@ -950,6 +737,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ @param {Event} e */ saveOrCancel: function (e) { + var formatter = this.formatter; var model = this.model; var column = this.column; @@ -957,13 +745,13 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ var command = new Command(e); var blurred = e.type === "blur"; - if (command.moveUp() || command.moveDown() || command.moveLeft() || - command.moveRight() || command.save() || blurred) { + if (command.moveUp() || command.moveDown() || command.moveLeft() || command.moveRight() || + command.save() || blurred) { e.preventDefault(); e.stopPropagation(); - var val = this.el.value; + var val = this.$el.val(); var newValue = formatter.toRaw(val, model); if (_.isUndefined(newValue)) { model.trigger("backgrid:error", model, column, val); @@ -984,18 +772,11 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { // move the cursor to the end on firefox if text is right aligned - var el = this.el, textAlign; - if (window.getComputedStyle) { - textAlign = window.getComputedStyle(el).textAlign; - } - else if (el.currentStyle) textAlign = el.currentStyle.textAlign; - if (textAlign === "right") { - var val = el.value; - el.focus(); - el.val = null; - el.val = val; + if (this.$el.css("text-align") === "right") { + var val = this.$el.val(); + this.$el.focus().val(null).val(val); } - else el.focus(); + else this.$el.focus(); } return this; } @@ -1012,9 +793,9 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ @abstract @class Backgrid.Cell - @extends Backgrid.View + @extends Backbone.View */ -var Cell = Backgrid.Cell = Backgrid.View.extend({ +var Cell = Backgrid.Cell = Backbone.View.extend({ /** @property */ tagName: "td", @@ -1054,7 +835,7 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ this.column = new Column(this.column); } - var column = this.column, model = this.model, classes = this.el.classList; + var column = this.column, model = this.model, $el = this.$el; var formatter = Backgrid.resolveNameToClass(column.get("formatter") || this.formatter, "Formatter"); @@ -1066,8 +847,9 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ this.formatter = formatter; this.editor = Backgrid.resolveNameToClass(this.editor, "CellEditor"); + this.listenTo(model, "change:" + column.get("name"), function () { - if (!classes.contains("editor")) this.render(); + if (!$el.hasClass("editor")) this.render(); }); this.listenTo(model, "backgrid:error", this.renderError); @@ -1077,15 +859,14 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ var changed = column.changedAttributes(); for (var key in changed) { if (changed.hasOwnProperty(key)) { - if (changed[key]) classes.add(key); - else classes.remove(key); + $el.toggleClass(key, changed[key]); } } }); - if (Backgrid.callByNeed(column.editable(), column, model)) classes.add("editable"); - if (Backgrid.callByNeed(column.sortable(), column, model)) classes.add("sortable"); - if (Backgrid.callByNeed(column.renderable(), column, model)) classes.add("renderable"); + if (Backgrid.callByNeed(column.editable(), column, model)) $el.addClass("editable"); + if (Backgrid.callByNeed(column.sortable(), column, model)) $el.addClass("sortable"); + if (Backgrid.callByNeed(column.renderable(), column, model)) $el.addClass("renderable"); }, /** @@ -1093,10 +874,9 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ model's raw value for this cell's column. */ render: function () { - this.empty(); + this.$el.empty(); var model = this.model; - this.el.appendChild(document.createTextNode( - this.formatter.fromRaw(model.get(this.column.get("name")), model))); + this.$el.text(this.formatter.fromRaw(model.get(this.column.get("name")), model)); this.delegateEvents(); return this; }, @@ -1137,10 +917,10 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ // Need to redundantly undelegate events for Firefox this.undelegateEvents(); - this.empty(); - this.el.appendChild(this.currentEditor.el); + this.$el.empty(); + this.$el.append(this.currentEditor.$el); this.currentEditor.render(); - this.el.classList.add("editor"); + this.$el.addClass("editor"); model.trigger("backgrid:editing", model, column, this, this.currentEditor); } @@ -1151,7 +931,7 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ */ renderError: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.el.classList.add("error"); + this.$el.addClass("error"); } }, @@ -1159,11 +939,11 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ Removes the editor and re-render in display mode. */ exitEditMode: function () { - this.el.classList.remove("error"); + this.$el.removeClass("error"); this.currentEditor.remove(); this.stopListening(this.currentEditor); delete this.currentEditor; - this.el.classList.remove("editor"); + this.$el.removeClass("editor"); this.render(); }, @@ -1232,17 +1012,15 @@ var UriCell = Backgrid.UriCell = Cell.extend({ }, render: function () { - this.empty(); - var model = this.model; - var rawValue = model.get(this.column.get("name")); - var formattedValue = this.formatter.fromRaw(rawValue, model); - var a = document.createElement("a"); - a.tabIndex = -1; - a.href = rawValue; - a.title = this.title || formattedValue; - a.target = this.target; - a.appendChild(document.createTextNode(formattedValue)); - this.el.appendChild(a); + this.$el.empty(); + var rawValue = this.model.get(this.column.get("name")); + var formattedValue = this.formatter.fromRaw(rawValue, this.model); + this.$el.append($("", { + tabIndex: -1, + href: rawValue, + title: this.title || formattedValue, + target: this.target + }).text(formattedValue)); this.delegateEvents(); return this; } @@ -1265,16 +1043,14 @@ var EmailCell = Backgrid.EmailCell = StringCell.extend({ formatter: EmailFormatter, render: function () { - this.empty(); + this.$el.empty(); var model = this.model; - var rawValue = model.get(this.column.get("name")); - var formattedValue = this.formatter.fromRaw(rawValue, model); - var a = document.createElement("a"); - a.tabIndex = -1; - a.href = "mailto:" + rawValue; - a.title = formattedValue; - a.appendChild(document.createTextNode(formattedValue)); - this.el.appendChild(a); + var formattedValue = this.formatter.fromRaw(model.get(this.column.get("name")), model); + this.$el.append($("", { + tabIndex: -1, + href: "mailto:" + formattedValue, + title: formattedValue + }).text(formattedValue)); this.delegateEvents(); return this; } @@ -1514,7 +1290,7 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ render: function () { var model = this.model; var val = this.formatter.fromRaw(model.get(this.column.get("name")), model); - this.el.defaultChecked = val; + this.$el.prop("checked", val); return this; }, @@ -1546,19 +1322,19 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ model.trigger("backgrid:edited", model, column, command); } - var el = this.el; + var $el = this.$el; if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() || command.moveDown()) { e.preventDefault(); e.stopPropagation(); - var val = formatter.toRaw(el.checked, model); + var val = formatter.toRaw($el.prop("checked"), model); model.set(column.get("name"), val); model.trigger("backgrid:edited", model, column, command); } else if (e.type == "change") { - var val = formatter.toRaw(el.checked, model); + var val = formatter.toRaw($el.prop("checked"), model); model.set(column.get("name"), val); - el.focus(); + $el.focus(); } } @@ -1589,15 +1365,15 @@ var BooleanCell = Backgrid.BooleanCell = Cell.extend({ uncheck otherwise. */ render: function () { - this.empty(); + this.$el.empty(); var model = this.model, column = this.column; var editable = Backgrid.callByNeed(column.editable(), column, model); - var input = document.createElement("input"); - input.tabIndex = -1; - input.type = "checkbox"; - input.checked = this.formatter.fromRaw(model.get(this.column.get("name")), model); - input.disabled = !editable; - this.el.appendChild(input); + this.$el.append($("", { + tabIndex: -1, + type: "checkbox", + checked: this.formatter.fromRaw(model.get(column.get("name")), model), + disabled: !editable + })); this.delegateEvents(); return this; } @@ -1632,13 +1408,12 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ setMultiple: function (multiple) { this.multiple = multiple; - this.el.multiple = multiple; + this.$el.prop("multiple", multiple); }, _renderOptions: function (nvps, selectedValues) { var options = ''; for (var i = 0; i < nvps.length; i++) { - var nvp = nvps[i]; options = options + this.template({ text: nvps[i][0], value: nvps[i][1], @@ -1656,7 +1431,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ parameter. */ render: function () { - this.empty(); + this.$el.empty(); var optionValues = _.result(this, "optionValues"); var model = this.model; @@ -1668,7 +1443,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ var optionText = null; var optionValue = null; var optgroupName = null; - var children = []; + var optgroup = null; for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -1677,7 +1452,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ optionText = optionValue[0]; optionValue = optionValue[1]; - children.push(this.template({ + this.$el.append(this.template({ text: optionText, value: optionValue, selected: _.indexOf(selectedValues, optionValue) > -1 @@ -1685,18 +1460,15 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ } else if (_.isObject(optionValue)) { optgroupName = optionValue.name; - var optgroup = document.createElement("optgroup"); - optgroup.label = optgroupName; - optgroup.innerHTML = this._renderOptions.call(this, optionValue.values, selectedValues); - children.push(optgroup.outerHTML); + optgroup = $("", { label: optgroupName }); + optgroup.append(this._renderOptions.call(this, optionValue.values, selectedValues)); + this.$el.append(optgroup); } else { throw new TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }"); } } - this.el.innerHTML = children.join(''); - this.delegateEvents(); return this; @@ -1708,20 +1480,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ save: function (e) { var model = this.model; var column = this.column; - - var values = null; - var options = this.el.options, option; - if (!this.multiple) values = this.el.value || null; - else if (this.multiple) { - values = []; - for (var i = 0, l = options.length; i < l; i++) { - option = options[i]; - if (option.selected) values.push(option.value); - } - if (values.length === 0) values = null; - } - - model.set(column.get("name"), this.formatter.toRaw(values, model)); + model.set(column.get("name"), this.formatter.toRaw(this.$el.val(), model)); }, /** @@ -1826,7 +1585,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ @throws {TypeError} If `optionValues` is malformed. */ render: function () { - this.empty(); + this.$el.empty(); var optionValues = _.result(this, "optionValues"); var model = this.model; @@ -1865,7 +1624,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ } } - this.el.appendChild(window.document.createTextNode(selectedText.join(this.delimiter))); + this.$el.append(selectedText.join(this.delimiter)); } catch (ex) { if (ex instanceof TypeError) { @@ -2115,9 +1874,9 @@ var Columns = Backgrid.Columns = Backbone.Collection.extend({ rendered, and apply the appropriate cell to each attribute. @class Backgrid.Row - @extends Backgrid.View + @extends Backbone.View */ -var Row = Backgrid.Row = Backgrid.View.extend({ +var Row = Backgrid.Row = Backbone.View.extend({ /** @property */ tagName: "tr", @@ -2148,15 +1907,15 @@ var Row = Backgrid.Row = Backgrid.View.extend({ var cell = this.makeCell(column, options); cells.splice(i, 0, cell); - var el = this.el, children = el.childNodes; + var $el = this.$el; if (i === 0) { - el.insertBefore(cell.render().el, el.firstChild); + $el.prepend(cell.render().$el); } else if (i === columns.length - 1) { - el.appendChild(cell.render().el); + $el.append(cell.render().$el); } else { - el.insertBefore(cell.render().el, children[i]); + $el.children().eq(i).before(cell.render().$el); } }); @@ -2188,7 +1947,7 @@ var Row = Backgrid.Row = Backgrid.View.extend({ Renders a row of cells for this row's model. */ render: function () { - this.empty(); + this.$el.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.cells.length; i++) { @@ -2212,7 +1971,7 @@ var Row = Backgrid.Row = Backgrid.View.extend({ var cell = this.cells[i]; cell.remove.apply(cell, arguments); } - return Row.__super__.remove.apply(this, arguments); + return Backbone.View.prototype.remove.apply(this, arguments); } }); @@ -2222,9 +1981,9 @@ var Row = Backgrid.Row = Backgrid.View.extend({ row with a single column. @class Backgrid.EmptyRow - @extends Backgrid.View + @extends Backbone.View */ -var EmptyRow = Backgrid.EmptyRow = Backgrid.View.extend({ +var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ /** @property */ tagName: "tr", @@ -2248,7 +2007,7 @@ var EmptyRow = Backgrid.EmptyRow = Backgrid.View.extend({ Renders an empty row. */ render: function () { - this.empty(); + this.$el.empty(); var td = document.createElement("td"); td.setAttribute("colspan", this.columns.length); @@ -2275,9 +2034,9 @@ var EmptyRow = Backgrid.EmptyRow = Backgrid.View.extend({ refresh after sorting. @class Backgrid.HeaderCell - @extends Backgrid.View + @extends Backbone.View */ -var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ +var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ /** @property */ tagName: "th", @@ -2301,27 +2060,23 @@ var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ this.column = new Column(this.column); } - var column = this.column - var collection = this.collection - var el = this.el; - var classes = el.classList; + var column = this.column, collection = this.collection, $el = this.$el; this.listenTo(column, "change:editable change:sortable change:renderable", function (column) { var changed = column.changedAttributes(); for (var key in changed) { if (changed.hasOwnProperty(key)) { - if (changed[key]) classes.add(key); - else classes.remove(key); + $el.toggleClass(key, changed[key]); } } }); this.listenTo(column, "change:direction", this.setCellDirection); this.listenTo(column, "change:name change:label", this.render); - if (Backgrid.callByNeed(column.editable(), column, collection)) classes.add("editable"); - if (Backgrid.callByNeed(column.sortable(), column, collection)) classes.add("sortable"); - if (Backgrid.callByNeed(column.renderable(), column, collection)) classes.add("renderable"); + if (Backgrid.callByNeed(column.editable(), column, collection)) $el.addClass("editable"); + if (Backgrid.callByNeed(column.sortable(), column, collection)) $el.addClass("sortable"); + if (Backgrid.callByNeed(column.renderable(), column, collection)) $el.addClass("renderable"); this.listenTo(collection.fullCollection || collection, "sort", this.removeCellDirection); }, @@ -2331,9 +2086,7 @@ var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ direction classes. */ removeCellDirection: function () { - var classes = this.el.classList; - classes.remove("ascending"); - classes.remove("descending"); + this.$el.removeClass("ascending").removeClass("descending"); this.column.set("direction", null); }, @@ -2344,10 +2097,8 @@ var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ otherwise. */ setCellDirection: function (column, direction) { - var classes = this.el.classList; - classes.remove("ascending"); - classes.remove("descending"); - if (column.cid == this.column.cid) classes.add(direction); + this.$el.removeClass("ascending").removeClass("descending"); + if (column.cid == this.column.cid) this.$el.addClass(direction); }, /** @@ -2386,29 +2137,19 @@ var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ column. */ render: function () { - this.empty(); - - var label; - + this.$el.empty(); var column = this.column; var sortable = Backgrid.callByNeed(column.sortable(), column, this.collection); - - if (sortable) { - label = document.createElement("a"); - label.appendChild(document.createTextNode(this.column.get("label"))); - var caret = document.createElement("b"); - caret.className = "sort-caret"; - label.appendChild(caret); + var label; + if(sortable){ + label = $("").text(column.get("label")).append(""); + } else { + label = document.createTextNode(column.get("label")); } - else label = document.createTextNode(column.get("label")); - this.el.appendChild(label); - - var classes = this.el.classList; - classes.add(column.get("name")); - - var direction = column.get("direction"); - if (direction) classes.add(direction); + this.$el.append(label); + this.$el.addClass(column.get("name")); + this.$el.addClass(column.get("direction")); this.delegateEvents(); return this; } @@ -2438,7 +2179,7 @@ var HeaderRow = Backgrid.HeaderRow = Backgrid.Row.extend({ @throws {TypeError} If options.columns or options.collection is undefined. */ initialize: function () { - HeaderRow.__super__.initialize.apply(this, arguments); + Backgrid.Row.prototype.initialize.apply(this, arguments); }, makeCell: function (column, options) { @@ -2457,9 +2198,9 @@ var HeaderRow = Backgrid.HeaderRow = Backgrid.Row.extend({ single row of header cells. @class Backgrid.Header - @extends Backgrid.View + @extends Backbone.View */ -var Header = Backgrid.Header = Backgrid.View.extend({ +var Header = Backgrid.Header = Backbone.View.extend({ /** @property */ tagName: "thead", @@ -2490,7 +2231,7 @@ var Header = Backgrid.Header = Backgrid.View.extend({ Renders this table head with a single row of header cells. */ render: function () { - this.el.appendChild(this.row.render().el); + this.$el.append(this.row.render().$el); this.delegateEvents(); return this; }, @@ -2502,7 +2243,7 @@ var Header = Backgrid.Header = Backgrid.View.extend({ */ remove: function () { this.row.remove.apply(this.row, arguments); - return Header.__super__.remove.apply(this, arguments); + return Backbone.View.prototype.remove.apply(this, arguments); } }); @@ -2520,9 +2261,9 @@ var Header = Backgrid.Header = Backgrid.View.extend({ responsible for refreshing the rows after sorting, insertion and removal. @class Backgrid.Body - @extends Backgrid.View + @extends Backbone.View */ -var Body = Backgrid.Body = Backgrid.View.extend({ +var Body = Backgrid.Body = Backbone.View.extend({ /** @property */ tagName: "tbody", @@ -2620,12 +2361,16 @@ var Body = Backgrid.Body = Backgrid.View.extend({ var index = collection.indexOf(model); this.rows.splice(index, 0, row); - var el = this.el; - var children = el.childNodes; - var rowEl = row.render().el; + var $el = this.$el; + var $children = $el.children(); + var $rowEl = row.render().$el; - if (index >= children.length) el.appendChild(rowEl); - else el.insertBefore(rowEl, children[index]); + if (index >= $children.length) { + $el.append($rowEl); + } + else { + $children.eq(index).before($rowEl); + } return this; }, @@ -2679,16 +2424,9 @@ var Body = Backgrid.Body = Backgrid.View.extend({ instance as its sole parameter when done. */ refresh: function () { - var parent = this.el.parentNode; - if (parent) parent.removeChild(this.el); - - // GC the damn rows in the background - var oldRows = [].slice.apply(this.rows); - setTimeout(function () { - for (var i = 0; i < oldRows.length; i++) { - oldRows[i].remove(); - } - }, 0); + for (var i = 0; i < this.rows.length; i++) { + this.rows[i].remove(); + } this.rows = this.collection.map(function (model) { var row = new this.row({ @@ -2698,13 +2436,10 @@ var Body = Backgrid.Body = Backgrid.View.extend({ return row; }, this); - this._unshiftEmptyRowMayBe(); this.render(); - if (parent) parent.appendChild(this.el); - this.collection.trigger("backgrid:refresh", this); return this; @@ -2716,7 +2451,7 @@ var Body = Backgrid.Body = Backgrid.View.extend({ row is rendered, otherwise no row is rendered. */ render: function () { - this.empty(); + this.$el.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.rows.length; i++) { @@ -2741,7 +2476,7 @@ var Body = Backgrid.Body = Backgrid.View.extend({ var row = this.rows[i]; row.remove.apply(row, arguments); } - return Body.__super__.remove.apply(this, arguments); + return Backbone.View.prototype.remove.apply(this, arguments); }, /** @@ -2912,9 +2647,9 @@ var Body = Backgrid.Body = Backgrid.View.extend({ @abstract @class Backgrid.Footer - @extends Backgrid.View + @extends Backbone.View */ -var Footer = Backgrid.Footer = Backgrid.View.extend({ +var Footer = Backgrid.Footer = Backbone.View.extend({ /** @property */ tagName: "tfoot", @@ -2952,7 +2687,7 @@ var Footer = Backgrid.Footer = Backgrid.View.extend({ By default, a Grid treats each model in a collection as a row, and each attribute in a model as a column. To render a grid you must provide a list of column metadata and a collection to the Grid constructor. Just like any - Backgrid.View class, the grid is rendered as a DOM node fragment when you + Backbone.View class, the grid is rendered as a DOM node fragment when you call render(). var grid = Backgrid.Grid({ @@ -2983,7 +2718,7 @@ var Footer = Backgrid.Footer = Backgrid.View.extend({ Row class. @class Backgrid.Grid - @extends Backgrid.View + @extends Backbone.View See: @@ -2993,7 +2728,7 @@ var Footer = Backgrid.Footer = Backgrid.View.extend({ - Backgrid.Row - Backgrid.Footer */ -var Grid = Backgrid.Grid = Backgrid.View.extend({ +var Grid = Backgrid.Grid = Backbone.View.extend({ /** @property */ tagName: "table", @@ -3112,17 +2847,17 @@ var Grid = Backgrid.Grid = Backgrid.View.extend({ the it has successfully been rendered. */ render: function () { - this.empty(); + this.$el.empty(); if (this.header) { - this.el.appendChild(this.header.render().el); + this.$el.append(this.header.render().$el); } if (this.footer) { - this.el.appendChild(this.footer.render().el); + this.$el.append(this.footer.render().$el); } - this.el.appendChild(this.body.render().el); + this.$el.append(this.body.render().$el); this.delegateEvents(); @@ -3140,7 +2875,7 @@ var Grid = Backgrid.Grid = Backgrid.View.extend({ this.header && this.header.remove.apply(this.header, arguments); this.body.remove.apply(this.body, arguments); this.footer && this.footer.remove.apply(this.footer, arguments); - return Grid.__super__.remove.apply(this, arguments); + return Backbone.View.prototype.remove.apply(this, arguments); } });