(function(){var t,u,v,w,x,y,z,c=function(c,a){return function(){return c.apply(a,arguments)}},A={}.hasOwnProperty,f=function(c,a){function g(){this.constructor=c}for(var b in a)A.call(a,b)&&(c[b]=a[b]);g.prototype=a.prototype;c.prototype=new g;c.__super__=a.prototype;return c},r=[].slice;Backbone.TableView=function(e){function a(){this.hideLoading=c(this.hideLoading,this);this.showLoadingNow=c(this.showLoadingNow,this);this.showLoading=c(this.showLoading,this);this.render=c(this.render,this);this.toggleSort= c(this.toggleSort,this);this.nextPage=c(this.nextPage,this);this.prevPage=c(this.prevPage,this);this.toPage=c(this.toPage,this);this.changeSize=c(this.changeSize,this);this.renderData=c(this.renderData,this);this.refreshPagination=c(this.refreshPagination,this);this.update=c(this.update,this);this.updateUrl=c(this.updateUrl,this);this.updateSearch=c(this.updateSearch,this);this.createFilter=c(this.createFilter,this);this.setData=c(this.setData,this);return t=a.__super__.constructor.apply(this,arguments)} f(a,e);a.prototype.tagName="div";a.prototype.titleTemplate=_.template('
\n

"><%= model.name || model %>

\n
');a.prototype.filtersTemplate=_.template('
');a.prototype.searchTemplate=_.template('
\n ">\n
'); a.prototype.paginationTemplate=_.template('
\n
\n
Showing <%= from %> to <%= to %><%= total %>
\n
\n
\n \n \n
\n
'); a.prototype.emptyTemplate=_.template('<%= text %>');a.prototype.columnsTemplate=_.template('<% _.each(model, function (col, key) { %>\n <% if (!col.noshow) { %>\n <%= ((key || col) == data.sort_col) ? "tableview-sorting-" + data.sort_dir : "" %> <%= col.className || "" %>">\n <%= col.header || key %>\n \n <% } %>\n<% }) %>'); a.prototype.template=_.template('
\n
\n <%= title %>\n\n <%= filters %>\n\n <%= search %>\n
\n\n
\n Loading...\n \n \n \n <%= columns %>\n \n \n \n
\n
\n\n
\n
'); a.prototype.search=!1;a.prototype.pagination=!1;a.prototype.loading=!0;a.prototype.fetch=!0;a.prototype.myEvents={"change .search-query":"updateSearch","click th":"toggleSort","click .pager-size:not(.active)":"changeSize","click .pager-page:not(.active)":"toPage","click .pager-prev:not(.disabled)":"prevPage","click .pager-next:not(.disabled)":"nextPage"};a.prototype.initialize=function(a){var b,d,c,h;for(b in a)d=a[b],this[b]=d;this.filterClasses=_.extend({option:Backbone.TableView.ButtonOptionFilter, dropdown:Backbone.TableView.DropdownFilter,input:Backbone.TableView.InputFilter,button:Backbone.TableView.ButtonFilter,buttongroup:Backbone.TableView.ButtonGroupFilter},this.filterClasses);this.events=_.extend(_.clone(this.myEvents),this.events);this.data=_.extend({},this.initialData);this.router&&(this.data=_.extend(this.data,this.parseQueryString(Backbone.history.fragment)),this.on("updating",this.updateUrl));this.pagination&&(this.data.page=null!=(c=parseInt(this.data.page)||this.page)?c:1,this.data.size= null!=(h=parseInt(this.data.size)||this.size)?h:10,this.on("updated",this.refreshPagination));this.loading&&(this.listenTo(this.collection,"request",this.showLoading),this.listenTo(this.collection,"sync",this.hideLoading));this.listenTo(this.collection,"sync",this.renderData);return this};a.prototype.prettyName=function(a){return a.charAt(0).toUpperCase()+a.substring(1).replace(/_(\w)/g,function(a,g){return" "+g.toUpperCase()})};a.prototype.parseQueryString=function(a){var b,d,c,h;c={};if(a&&0<=(b= a.indexOf("?")))for(a=a.substring(b+1),h=/([^&=]+)=?([^&]*)/g,b=function(a){return decodeURIComponent(a.replace(/\+/g," "))};d=h.exec(a);)c[b(d[1])]=b(d[2]);return c};a.prototype.applyTemplate=function(a,b,d){null==d&&(d=12);return b&&d&&a({data:this.data,model:b,classSize:"span"+d+" col-lg-"+d,self:this})||""};a.prototype.setData=function(){var a,b,d;a=1<=arguments.length?r.call(arguments,0):[];this.pagination&&(this.data.page=1);for(;1d?(c=1,e=h=this.data.page,l=""):(c=Math.ceil(d/this.data.size)||1,h=_.max([1,this.data.page-2-_.max([0,2+this.data.page-c])]),e=_.min([c,this.data.page+2+_.max([0,3-this.data.page])]),l=" of "+d+" entries");c=function(){var a,d,c,g;c=_.range(h,e+1);g=[];a=0;for(d=c.length;a");n=this.columns;for(e in n)d=n[e],d.noshow||(b=$("").addClass(d.className).addClass(d.tdClass),null!=d.draw?b.html(d.draw(c,this)):b.text(null!=(p=c.get(e))?p:""),f.append(b));a.append(null!=(q="function"===typeof this.rowTransformer?this.rowTransformer(f,c):void 0)?q:f)}this.trigger("updated");return this};a.prototype.changeSize=function(a){return this.setData("size",parseInt(a.currentTarget.childNodes[0].text))};a.prototype.toPage=function(a){return this.setData("page", parseInt(a.currentTarget.childNodes[0].text))};a.prototype.prevPage=function(){if(1<%= name %>');a.prototype.className="input-group col-lg-3 input-prepend pull-left tableview-filterbox";a.prototype.events={"change .filter":"update"};a.prototype.update=function(a){return this.extraId?this.setData(this.id,this.options.get(a.currentTarget.value),this.extraId,this.options.getExtraId(a.currentTarget.value)):this.setData(this.id,this.options.get(a.currentTarget.value))}; return a}(Backbone.TableView.Filter);Backbone.TableView.ButtonFilter=function(e){function a(){this.update=c(this.update,this);return w=a.__super__.constructor.apply(this,arguments)}f(a,e);a.prototype.template=_.template('');a.prototype.events={"click .filter":"update"};a.prototype.initialize=function(){a.__super__.initialize.apply(this,arguments);this.values=[this.options.off,this.options.on]; return this.current=this.options.init===this.options.on?1:0};a.prototype.update=function(a){this.$(a.currentTarget).toggleClass("active");this.current=1-this.current;return this.setData(this.id,this.values[this.current])};return a}(Backbone.TableView.Filter);Backbone.TableView.ButtonGroupFilter=function(e){function a(){this.update=c(this.update,this);return x=a.__super__.constructor.apply(this,arguments)}f(a,e);a.prototype.template=_.template('<% _.each(options, function (el, i) { %>\n \n<% }) %>'); a.prototype.className="btn-group pull-left tableview-filterbox";a.prototype.events={"click .btn":"update"};a.prototype.update=function(a){var b=this;this.$(a.currentTarget).toggleClass("active");a=_.compact(_.map(this.$(".btn"),function(a){return b.$(a).hasClass("active")?b.$(a).attr("value"):null}));return this.setData(this.id,this.options.get(a))};return a}(Backbone.TableView.Filter);Backbone.TableView.ButtonOptionFilter=function(e){function a(){this.update=c(this.update,this);return y=a.__super__.constructor.apply(this, arguments)}f(a,e);a.prototype.template=_.template('<% _.each(options, function (el, i) { %>\n \n<% }) %>');a.prototype.className="btn-group pull-left tableview-filterbox";a.prototype.events={"click .btn":"update"};a.prototype.update=function(a){this.$(".btn").removeClass("active");this.$(a.currentTarget).addClass("active");return this.setData(this.id,this.options.get(a.currentTarget.value))}; return a}(Backbone.TableView.Filter);Backbone.TableView.DropdownFilter=function(e){function a(){this.update=c(this.update,this);return z=a.__super__.constructor.apply(this,arguments)}f(a,e);a.prototype.template=_.template('');a.prototype.events={"change .filter":"update"}; a.prototype.update=function(a){return this.setData(this.id,this.options.get(a.currentTarget.value))};return a}(Backbone.TableView.Filter)}).call(this);