From e8b1bc2ad9d2ff8c901e21be4cb01bb7e0958e69 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 18 Jul 2013 19:09:54 -0700 Subject: [PATCH] Cleanup --- js/crm.backbone.js | 15 +++++++++------ tests/qunit/crm-backbone/test.js | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/js/crm.backbone.js b/js/crm.backbone.js index 96b70c0124..e84089476c 100644 --- a/js/crm.backbone.js +++ b/js/crm.backbone.js @@ -11,6 +11,7 @@ * @param method * @param model * @param options + * @see tests/qunit/crm-backbone */ CRM.Backbone.sync = function(method, model, options) { var isCollection = _.isArray(model.models); @@ -95,6 +96,7 @@ * * @param Class ModelClass * @param string crmEntityName APIv3 entity name, such as "Contact" or "CustomField" + * @see tests/qunit/crm-backbone */ CRM.Backbone.extendModel = function(ModelClass, crmEntityName) { // Defaults - if specified in ModelClass, preserve @@ -133,6 +135,7 @@ * @endcode * * @param Class CollectionClass + * @see tests/qunit/crm-backbone */ CRM.Backbone.extendCollection = function(CollectionClass) { var origInit = CollectionClass.prototype.initialize; @@ -168,8 +171,8 @@ toStrictJSON: function() { var schema = this.schema; var result = this.toJSON(); - _.each(result, function(value, key){ - if (! schema[key]) { + _.each(result, function(value, key) { + if (!schema[key]) { delete result[key]; } }); @@ -179,7 +182,7 @@ this.rels = this.rels || {}; if (this.rels[key] != value) { this.rels[key] = value; - this.trigger("rel:"+key, value); + this.trigger("rel:" + key, value); } }, getRel: function(key) { @@ -203,12 +206,12 @@ }, _copyToChildren: function() { var collection = this; - collection.each(function(model){ + collection.each(function(model) { collection._copyToChild(model); }); }, _copyToChild: function(model) { - _.each(this.rels, function(relValue, relKey){ + _.each(this.rels, function(relValue, relKey) { model.setRel(relKey, relValue, {silent: true}); }); }, @@ -216,7 +219,7 @@ this.rels = this.rels || {}; if (this.rels[key] != value) { this.rels[key] = value; - this.trigger("rel:"+key, value); + this.trigger("rel:" + key, value); } }, getRel: function(key) { diff --git a/tests/qunit/crm-backbone/test.js b/tests/qunit/crm-backbone/test.js index 659d7ceaeb..ed870c23d6 100644 --- a/tests/qunit/crm-backbone/test.js +++ b/tests/qunit/crm-backbone/test.js @@ -72,7 +72,7 @@ asyncTest("create/read/delete/read (ok)", function() { c1.save({}, { error: onUnexpectedError, success: function() { - equal(c1.get("first_name"), "George"+TOKEN, "save() should return new first name"); + equal(c1.get("first_name"), "George" + TOKEN, "save() should return new first name"); // Fetch the newly created contact var c2 = new ContactModel({id: c1.get('id')}); -- 2.25.1