ampersand-view
Advanced tools
Comparing version 7.2.0 to 7.2.1
@@ -5,3 +5,12 @@ /*$AMPERSAND_VERSION*/ | ||
var domify = require('domify'); | ||
var _ = require('underscore'); | ||
var uniqueId = require("lodash.uniqueid"); | ||
var pick = require("lodash.pick"); | ||
var assign = require("lodash.assign"); | ||
var forEach = require("lodash.foreach"); | ||
var result = require("lodash.result"); | ||
var last = require("lodash.last"); | ||
var isString = require("lodash.isstring"); | ||
var bind = require("lodash.bind"); | ||
var flatten = require("lodash.flatten"); | ||
var invoke = require("lodash.invoke"); | ||
var events = require('events-mixin'); | ||
@@ -14,3 +23,3 @@ var matches = require('matches-selector'); | ||
function View(attrs) { | ||
this.cid = _.uniqueId('view'); | ||
this.cid = uniqueId('view'); | ||
attrs || (attrs = {}); | ||
@@ -29,3 +38,3 @@ var parent = attrs.parent; | ||
this.initialize.apply(this, arguments); | ||
this.set(_.pick(attrs, viewOptions)); | ||
this.set(pick(attrs, viewOptions)); | ||
if (this.autoRender && this.template) { | ||
@@ -91,3 +100,3 @@ this.render(); | ||
// Set up all inheritable properties and methods. | ||
_.extend(View.prototype, { | ||
assign(View.prototype, { | ||
// ## query | ||
@@ -144,3 +153,3 @@ // Get an single element based on CSS selector scoped to this.el | ||
if (this.el && this.el.parentNode) this.el.parentNode.removeChild(this.el); | ||
if (this._subviews) _.chain(this._subviews).flatten().invoke('remove'); | ||
if (this._subviews) invoke(flatten(this._subviews), 'remove'); | ||
this.stopListening(); | ||
@@ -150,4 +159,4 @@ // TODO: Not sure if this is actually necessary. | ||
// amount of generated functions to avoid memory leaks. | ||
_.each(parsedBindings, function (properties, modelName) { | ||
_.each(properties, function (value, key) { | ||
forEach(parsedBindings, function (properties, modelName) { | ||
forEach(properties, function (value, key) { | ||
delete parsedBindings[modelName][key]; | ||
@@ -187,3 +196,3 @@ }); | ||
delegateEvents: function (events) { | ||
if (!(events || (events = _.result(this, 'events')))) return this; | ||
if (!(events || (events = result(this, 'events')))) return this; | ||
this.undelegateEvents(); | ||
@@ -237,3 +246,3 @@ for (var key in events) { | ||
fns[item].forEach(function (fn) { | ||
fn(this.el, getPath(this, item), _.last(item.split('.'))); | ||
fn(this.el, getPath(this, item), last(item.split('.'))); | ||
}, this); | ||
@@ -302,4 +311,4 @@ } | ||
if (!template) throw new Error('Template string or function needed.'); | ||
var newDom = _.isString(template) ? template : template.call(this, context || this); | ||
if (_.isString(newDom)) newDom = domify(newDom); | ||
var newDom = isString(template) ? template : template.call(this, context || this); | ||
if (isString(newDom)) newDom = domify(newDom); | ||
var parent = this.el && this.el.parentNode; | ||
@@ -342,3 +351,3 @@ if (parent) parent.replaceChild(newDom, this.el); | ||
listenToAndRun: function (object, events, handler) { | ||
var bound = _.bind(handler, this); | ||
var bound = bind(handler, this); | ||
this.listenTo(object, events, bound); | ||
@@ -362,3 +371,3 @@ bound(); | ||
var containerEl = (typeof container === 'string') ? this.query(container) : container; | ||
var config = _.extend({ | ||
var config = assign({ | ||
collection: collection, | ||
@@ -365,0 +374,0 @@ el: containerEl || this.el, |
{ | ||
"name": "ampersand-view", | ||
"description": "A smart base view for Backbone apps, to make it easy to bind collections and properties to the DOM.", | ||
"version": "7.2.0", | ||
"version": "7.2.1", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -14,3 +14,3 @@ "browser": "./ampersand-view.js", | ||
"dependencies": { | ||
"ampersand-collection-view": "^1.0.0", | ||
"ampersand-collection-view": "^1.3.0", | ||
"ampersand-dom-bindings": "^3.3.3", | ||
@@ -21,6 +21,15 @@ "ampersand-state": "^4.2.7", | ||
"domify": "^1.0.0", | ||
"events-mixin": "^1.1.0", | ||
"events-mixin": "^1.2.0", | ||
"get-object-path": "^0.0.2", | ||
"matches-selector": "^1.0.0", | ||
"underscore": "1.6.0" | ||
"lodash.assign": "^3.0.0", | ||
"lodash.bind": "^3.1.0", | ||
"lodash.flatten": "^3.0.2", | ||
"lodash.foreach": "^3.0.2", | ||
"lodash.invoke": "^3.1.0", | ||
"lodash.isstring": "^3.0.1", | ||
"lodash.last": "^3.0.0", | ||
"lodash.pick": "^3.1.0", | ||
"lodash.result": "^3.0.0", | ||
"lodash.uniqueid": "^3.0.0", | ||
"matches-selector": "^1.0.0" | ||
}, | ||
@@ -27,0 +36,0 @@ "devDependencies": { |
@@ -33,3 +33,3 @@ # ampersand-view | ||
Note that this is a fork of Backbone's view so most of the public methods/properties here still exist: [http://backbonejs.org/#View](http://backbonejs.org/#View). | ||
Note that this is a fork of Backbone's view so most of the public methods/properties here still exist: [http://backbonejs.org/#View](http://backbonejs.org/#View).`AmpersandView` extends [`AmpersandState`](https://github.com/ampersandjs/ampersand-state) so it can have it's own `props` values for example and can be bound directly to the template without a backing model object. | ||
@@ -36,0 +36,0 @@ ### extend `AmpersandView.extend([properties])` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69558
1215
19
+ Addedlodash.assign@^3.0.0
+ Addedlodash.bind@^3.1.0
+ Addedlodash.flatten@^3.0.2
+ Addedlodash.foreach@^3.0.2
+ Addedlodash.invoke@^3.1.0
+ Addedlodash.isstring@^3.0.1
+ Addedlodash.last@^3.0.0
+ Addedlodash.pick@^3.1.0
+ Addedlodash.result@^3.0.0
+ Addedlodash.uniqueid@^3.0.0
+ Addedlodash.flatten@3.0.2(transitive)
+ Addedlodash.last@3.0.0(transitive)
- Removedunderscore@1.6.0
- Removedunderscore@1.6.0(transitive)
Updatedevents-mixin@^1.2.0