Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone.collectionview

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.collectionview - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

component.json
{
"name": "backbone.collectionview",
"version": "0.1.0",
"version": "0.1.1",
"main": "./dist/backbone.collectionview.min.js",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -1,2 +0,2 @@

/*! backbone.collectionview - v0.1.0 - 2012-09-14
/*! backbone.collectionview - v0.1.1 - 2012-09-14
* https://github.com/anthonyshort/backbone.collectionview

@@ -3,0 +3,0 @@ * Copyright (c) 2012 Anthony Short; Licensed MIT */

@@ -1,4 +0,4 @@

/*! backbone.collectionview - v0.1.0 - 2012-09-14
/*! backbone.collectionview - v0.1.1 - 2012-09-14
* https://github.com/anthonyshort/backbone.collectionview
* Copyright (c) 2012 Anthony Short; Licensed MIT */
(function(){var e=function(e,t){return function(){return e.apply(t,arguments)}},t={}.hasOwnProperty,n=function(e,n){function i(){this.constructor=e}for(var r in n)t.call(n,r)&&(e[r]=n[r]);return i.prototype=n.prototype,e.prototype=new i,e.__super__=n.prototype,e};Backbone.CollectionView=function(r){function i(t){t==null&&(t={}),this.onReset=e(this.onReset,this),this.onRemove=e(this.onRemove,this),this.onAdd=e(this.onAdd,this),this.onReady=e(this.onReady,this),this.onLoad=e(this.onLoad,this),i.__super__.constructor.apply(this,arguments);if(!t.collection)throw"Backbone.CollectionView requires a collection";_(t).defaults({render:!1,renderItems:!1}),this.viewsByCid={},this.collectionEvents||(this.collectionEvents={}),this.addCollectionListeners(t.collection),this.viewEvents||(this.viewEvents={}),this.itemView=t.itemView||this.itemView,t.render&&this.render(),t.renderItems&&this.renderAllItems()}return n(i,r),i.extend=Backbone.Model.extend,i.prototype.itemView=null,i.prototype.emptyClass="is-empty",i.prototype.loadingClass="is-loading",i.prototype.itemSelector=null,i.prototype.listSelector=null,i.prototype.list=null,i.prototype.viewsByCid=null,i.prototype.addCollectionListeners=function(e){var t,n,r;e.on("add",this.onAdd,this),e.on("remove",this.onRemove,this),e.on("reset",this.onReset,this),e.on("loading",this.onLoad,this),e.on("ready",this.onReady,this),r=this.collectionEvents;for(n in r)t=r[n],e.on(n,this[t],this);return e},i.prototype.addViewListeners=function(e){var t,n,r;r=this.viewEvents;for(n in r)t=r[n],e.on(n,this[t],this);return e},i.prototype.onLoad=function(){return this.$el.addClass(this.loadingClass)},i.prototype.onReady=function(){return this.$el.removeClass(this.loadingClass),this.initFallback()},i.prototype.onAdd=function(e){return this.addModelView(e)},i.prototype.onRemove=function(e){return this.removeModelView(e)},i.prototype.onReset=function(){return this.renderAllItems()},i.prototype.add=function(e,t){var n;return e==null&&(e={}),t==null&&(t={}),n=new this.collection.model(e),this.collection.add(n,t),this.getViewByModel(n)},i.prototype.render=function(){return i.__super__.render.apply(this,arguments),this.list=this.listSelector?this.$(this.listSelector):this.$el,this.initFallback()},i.prototype.initFallback=function(){return this.collection.length===0?this.$el.addClass(this.emptyClass):this.$el.removeClass(this.emptyClass)},i.prototype.renderAllItems=function(){var e=this;return this.render(),this.clear(),this.collection.each(function(t){return e.addModelView(t)})},i.prototype.clear=function(){var e,n,r,i,s;this.list.empty(),i=this.viewsByCid,s=[];for(e in i){if(!t.call(i,e))continue;r=i[e],n=this.collection.get(e),n?s.push(this.removeModelView(n)):s.push(void 0)}return s},i.prototype.getItemView=function(e){if(!this.itemView)throw"Backbone.CollectionView needs an itemView property set. Alternatively override the getItemView method";return new this.itemView({model:e,collection:this.collection})},i.prototype.addModelView=function(e){var t;return t=this.getItemView(e),this.addViewListeners(t),t.render(),this.viewsByCid[e.cid]=t,this.initFallback(),this.renderItem(t,e),t},i.prototype.getViewByModel=function(e){return this.viewsByCid[e.cid]},i.prototype.removeModelView=function(e){var t;t=this.viewsByCid[e.cid];if(!t)return;return t.remove(),delete this.viewsByCid[e.cid],this.initFallback()},i.prototype.renderItem=function(e,t){var n,r;return n=this.list.children(this.itemSelector),r=this.collection.indexOf(t),r===0?this.list.prepend(e.$el):r<n.length?n.eq(r).before(e.$el):this.list.append(e.$el),this.afterRenderItem(e,t)},i.prototype.afterRenderItem=function(e,t){},i.prototype.dispose=function(){var e,t,n,r,s;i.__super__.dispose.apply(this,arguments),r=["list","viewsByCid","collection"],s=[];for(t=0,n=r.length;t<n;t++)e=r[t],s.push(delete this[e]);return s},i}(Backbone.View),typeof module!="undefined"&&module!==null&&(module.exports=Backbone.CollectionView)}).call(this);
{
"name": "backbone.collectionview",
"description": "A view optimized for rendering collections",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/anthonyshort/backbone.collectionview",

@@ -37,2 +37,2 @@ "author": {

"keywords": []
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc