New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

backbone-base-view

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-base-view - npm Package Compare versions

Comparing version 2.0.0-beta.4 to 2.0.0-beta.5

2

bower.json
{
"name": "backboneBaseView",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"description": "Baseview is a extended backbone view with convenient methods for manipulating subviews and events.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/dbrekalo/backbone-base-view",

@@ -125,3 +125,3 @@ (function(root, factory) {

this.listenTo(view, 'afterRemove', function() {
this.listenToOnce(view, 'afterRemove detachView', function() {

@@ -144,2 +144,29 @@ delete this.views[view.cid];

getGroupViews: function(groupName) {
return this.viewsGroups && this.viewsGroups[groupName] ? _.values(this.viewsGroups[groupName]) : [];
},
hasView: function(view) {
return this.views && !!this.views[view.cid];
},
detachView: function() {
this.trigger('detachView');
return this;
},
attachToView: function(view, group) {
this.detachView();
view.addView(this, group);
return this;
},
removeViews: function(group) {

@@ -146,0 +173,0 @@

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

!function(a,b){"function"==typeof define&&define.amd?define(["jquery","backbone","underscore"],b):"object"==typeof module&&module.exports?module.exports=b(require("jquery"),require("backbone"),require("underscore")):a.BaseView=b(a.jQuery,a.Backbone,a._)}(this,function(a,b,c){var d=this,e=/{{(\S+)}}/g,f=function(a,b){return a.replace(e,function(a,c){var e=0===c.indexOf("this."),f=e?b:d,g=(e?c.slice(5):c).split(".");for(var h in g)if(f=f[g[h]],"undefined"==typeof f)throw new Error("Undefined variable in event string");return f})},g=b.View.extend({constructor:function(){b.View.apply(this,arguments),this.events&&this.setupEvents()},delegatedEvents:!0,setupEvents:function(b){var e=this.ens=this.ens||"."+this.cid,g=b||this.events,h=this,i={window:d,document:d.document};return c.each("function"==typeof g?g.call(this):g,function(b,c){c=f(c,h);var d=0===c.indexOf("one:"),g=(d?c.slice(4):c).split(" "),j=g[0]+e,k=g.slice(1).join(" "),l=h.$el;i[k]?(l=h["$"+k]=h["$"+k]||a(i[k]),k=void 0):h.delegatedEvents||((h.elementsWithBoundEvents=h.elementsWithBoundEvents||[]).push(l=l.find(k)),k=void 0),l[d?"one":"on"](j,k,function(){("function"==typeof b?b:h[b]).apply(h,arguments)})}),this},removeEvents:function(){var a=this.ens;return a&&(this.$el&&this.$el.off(a),this.$document&&this.$document.off(a),this.$window&&this.$window.off(a),this.elementsWithBoundEvents&&(c.each(this.elementsWithBoundEvents,function(b){b.off(a)}),this.elementsWithBoundEvents=null)),this},addView:function(a,b){return this.views=this.views||{},this.views[a.cid]=a,a.model&&(this.viewsWithModel=this.viewsWithModel||{},this.viewsWithModel[a.model.cid]=a),b&&(this.viewsGroups=this.viewsGroups||{},this.viewsGroups[b]=this.viewsGroups[b]||{},this.viewsGroups[b][a.cid]=a),this.listenTo(a,"afterRemove",function(){delete this.views[a.cid],a.model&&this.viewsWithModel&&delete this.viewsWithModel[a.model.cid],b&&this.viewsGroups&&this.viewsGroups[b]&&delete this.viewsGroups[b][a.cid]}),a},removeViews:function(a){return a?this.viewsGroups&&this.viewsGroups[a]&&(c.invoke(this.viewsGroups[a],"remove"),delete this.viewsGroups[a]):(this.views&&c.invoke(this.views,"remove"),delete this.views,delete this.viewsWithModel,delete this.viewsGroups),this},getViewByModel:function(a){return this.viewsWithModel&&this.viewsWithModel[a.cid]},removeViewByModel:function(a){return this.viewsWithModel&&this.viewsWithModel[a.cid]&&this.viewsWithModel[a.cid].remove(),this},addDeferred:function(a){return this.deferreds=this.deferreds||[],c.indexOf(this.deferreds,a)<0&&this.deferreds.push(a),a},abortDeferreds:function(){return this.deferreds&&c.each(this.deferreds,function(a){"object"==typeof a&&a.state&&"pending"===a.state()&&(a.abort?a.abort():a.reject())}),delete this.deferreds,this},when:function(b,e,f){c.each(b=c.isArray(b)?b:[b],function(a){this.addDeferred(a)},this);var g=a.when.apply(d,b);return e&&g.done(c.bind(e,this)),f&&g.fail(c.bind(f,this)),g},remove:function(){return this.trigger("beforeRemove"),this.removeEvents().abortDeferreds().removeViews(),b.View.prototype.remove.call(this),this.trigger("afterRemove"),this},setElement:function(a){return this._setElement(a),this}});return g.prototype.undelegateEvents=g.prototype.removeEvents,g.prototype.delegateEvents=g.prototype.setupEvents,g});
!function(a,b){"function"==typeof define&&define.amd?define(["jquery","backbone","underscore"],b):"object"==typeof module&&module.exports?module.exports=b(require("jquery"),require("backbone"),require("underscore")):a.BaseView=b(a.jQuery,a.Backbone,a._)}(this,function(a,b,c){var d=this,e=/{{(\S+)}}/g,f=function(a,b){return a.replace(e,function(a,c){var e=0===c.indexOf("this."),f=e?b:d,g=(e?c.slice(5):c).split(".");for(var h in g)if(f=f[g[h]],"undefined"==typeof f)throw new Error("Undefined variable in event string");return f})},g=b.View.extend({constructor:function(){b.View.apply(this,arguments),this.events&&this.setupEvents()},delegatedEvents:!0,setupEvents:function(b){var e=this.ens=this.ens||"."+this.cid,g=b||this.events,h=this,i={window:d,document:d.document};return c.each("function"==typeof g?g.call(this):g,function(b,c){c=f(c,h);var d=0===c.indexOf("one:"),g=(d?c.slice(4):c).split(" "),j=g[0]+e,k=g.slice(1).join(" "),l=h.$el;i[k]?(l=h["$"+k]=h["$"+k]||a(i[k]),k=void 0):h.delegatedEvents||((h.elementsWithBoundEvents=h.elementsWithBoundEvents||[]).push(l=l.find(k)),k=void 0),l[d?"one":"on"](j,k,function(){("function"==typeof b?b:h[b]).apply(h,arguments)})}),this},removeEvents:function(){var a=this.ens;return a&&(this.$el&&this.$el.off(a),this.$document&&this.$document.off(a),this.$window&&this.$window.off(a),this.elementsWithBoundEvents&&(c.each(this.elementsWithBoundEvents,function(b){b.off(a)}),this.elementsWithBoundEvents=null)),this},addView:function(a,b){return this.views=this.views||{},this.views[a.cid]=a,a.model&&(this.viewsWithModel=this.viewsWithModel||{},this.viewsWithModel[a.model.cid]=a),b&&(this.viewsGroups=this.viewsGroups||{},this.viewsGroups[b]=this.viewsGroups[b]||{},this.viewsGroups[b][a.cid]=a),this.listenToOnce(a,"afterRemove detachView",function(){delete this.views[a.cid],a.model&&this.viewsWithModel&&delete this.viewsWithModel[a.model.cid],b&&this.viewsGroups&&this.viewsGroups[b]&&delete this.viewsGroups[b][a.cid]}),a},getGroupViews:function(a){return this.viewsGroups&&this.viewsGroups[a]?c.values(this.viewsGroups[a]):[]},hasView:function(a){return this.views&&!!this.views[a.cid]},detachView:function(){return this.trigger("detachView"),this},attachToView:function(a,b){return this.detachView(),a.addView(this,b),this},removeViews:function(a){return a?this.viewsGroups&&this.viewsGroups[a]&&(c.invoke(this.viewsGroups[a],"remove"),delete this.viewsGroups[a]):(this.views&&c.invoke(this.views,"remove"),delete this.views,delete this.viewsWithModel,delete this.viewsGroups),this},getViewByModel:function(a){return this.viewsWithModel&&this.viewsWithModel[a.cid]},removeViewByModel:function(a){return this.viewsWithModel&&this.viewsWithModel[a.cid]&&this.viewsWithModel[a.cid].remove(),this},addDeferred:function(a){return this.deferreds=this.deferreds||[],c.indexOf(this.deferreds,a)<0&&this.deferreds.push(a),a},abortDeferreds:function(){return this.deferreds&&c.each(this.deferreds,function(a){"object"==typeof a&&a.state&&"pending"===a.state()&&(a.abort?a.abort():a.reject())}),delete this.deferreds,this},when:function(b,e,f){c.each(b=c.isArray(b)?b:[b],function(a){this.addDeferred(a)},this);var g=a.when.apply(d,b);return e&&g.done(c.bind(e,this)),f&&g.fail(c.bind(f,this)),g},remove:function(){return this.trigger("beforeRemove"),this.removeEvents().abortDeferreds().removeViews(),b.View.prototype.remove.call(this),this.trigger("afterRemove"),this},setElement:function(a){return this._setElement(a),this}});return g.prototype.undelegateEvents=g.prototype.removeEvents,g.prototype.delegateEvents=g.prototype.setupEvents,g});
{
"name": "backbone-base-view",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"description": "Baseview is a extended backbone view with convenient methods for manipulating subviews and events.",

@@ -5,0 +5,0 @@ "main": "src/baseView.js",

@@ -17,6 +17,30 @@ #Backbone base view

```javascript
addSubview(view, group)
addView(view, group)
```
Adds subview to current view. If optional group parameter is provided adds view to subview group.
Adds target view to current view. If optional group is provided adds view to subview group.
###hasView
```javascript
hasView(view)
```
Check if target view is subview.
###getGroupViews
```javascript
getGroupViews(group)
```
Get group subviews as array
###detachView
```javascript
detachView()
```
Detach view from parent registry
###attachToView
```javascript
attachToView(view, group)
```
Detach view from parent registry and attach to another view.
###removeViews

@@ -26,9 +50,9 @@ ```javascript

```
Removes all view subviews recursively. If group is specified removes only views which belong to subview group.
Removes all subviews recursively. If group is specified removes only views which belong to subview group.
###removeViewByModel
###remove
```javascript
removeViewByModel(model)
remove()
```
Close subview by providing it's model instance.
Does extended cleanup and triggers "beforeRemove" and "afterRemove" events.

@@ -41,2 +65,8 @@ ###getViewByModel

###removeViewByModel
```javascript
removeViewByModel(model)
```
Close subview by providing it's model instance.
###when

@@ -43,0 +73,0 @@ ```javascript

@@ -125,3 +125,3 @@ (function(root, factory) {

this.listenTo(view, 'afterRemove', function() {
this.listenToOnce(view, 'afterRemove detachView', function() {

@@ -144,2 +144,29 @@ delete this.views[view.cid];

getGroupViews: function(groupName) {
return this.viewsGroups && this.viewsGroups[groupName] ? _.values(this.viewsGroups[groupName]) : [];
},
hasView: function(view) {
return this.views && !!this.views[view.cid];
},
detachView: function() {
this.trigger('detachView');
return this;
},
attachToView: function(view, group) {
this.detachView();
view.addView(this, group);
return this;
},
removeViews: function(group) {

@@ -146,0 +173,0 @@

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