8c9d9371 by Adam Heath

Fix jshint issues.

1 parent 8f9ef904
1 /* global Backbone */
1 define(['rivets', 'bootstrap'], function(rivets) { 2 define(['rivets', 'bootstrap'], function(rivets) {
3 'use strict';
2 var rivetsBinderCall = function(binding, binderName, methodName, args) { 4 var rivetsBinderCall = function(binding, binderName, methodName, args) {
3 var binder = rivets.binders[binderName]; 5 var binder = rivets.binders[binderName];
4 if (binder instanceof Function) { 6 if (binder instanceof Function) {
5 if (methodName == 'routine') { 7 if (methodName === 'routine') {
6 binder.apply(binding, args); 8 binder.apply(binding, args);
7 }; 9 }
8 } else if (binder) { 10 } else if (binder) {
9 if (binder[methodName]) { 11 if (binder[methodName]) {
10 binder[methodName].apply(binding, args); 12 binder[methodName].apply(binding, args);
11 } 13 }
12 } 14 }
13 } 15 };
14 16
15 var diveIntoObject = function(obj, keypath, callback) { 17 var diveIntoObject = function(obj, keypath, callback) {
16 if (!keypath) { 18 if (!keypath) {
...@@ -21,7 +23,7 @@ define(['rivets', 'bootstrap'], function(rivets) { ...@@ -21,7 +23,7 @@ define(['rivets', 'bootstrap'], function(rivets) {
21 //console.log('diveIntoObject(keyparts):', obj, keyparts); 23 //console.log('diveIntoObject(keyparts):', obj, keyparts);
22 while (keyparts.length > 1) { 24 while (keyparts.length > 1) {
23 var part = keyparts.shift(); 25 var part = keyparts.shift();
24 if (part.length == 0) { 26 if (part.length === 0) {
25 continue; 27 continue;
26 } 28 }
27 //console.log('diveIntoObject:', obj, part); 29 //console.log('diveIntoObject:', obj, part);
...@@ -32,30 +34,37 @@ define(['rivets', 'bootstrap'], function(rivets) { ...@@ -32,30 +34,37 @@ define(['rivets', 'bootstrap'], function(rivets) {
32 }; 34 };
33 35
34 var doObjectRead = function(obj, id) { 36 var doObjectRead = function(obj, id) {
35 if (obj === null) return obj; 37 if (obj === null) {
36 if (!id) return obj; 38 return obj;
39 }
40 if (!id) {
41 return obj;
42 }
37 //console.log('doObjectRead:', obj, id, obj instanceof Backbone.Model, obj instanceof Backbone.Collection); 43 //console.log('doObjectRead:', obj, id, obj instanceof Backbone.Model, obj instanceof Backbone.Collection);
38 if (obj instanceof Backbone.Model) { 44 if (obj instanceof Backbone.Model) {
39 return obj.get(id); 45 return obj.get(id);
40 } else if (obj instanceof Backbone.Collection) { 46 } else if (obj instanceof Backbone.Collection) {
41 return obj.at(id); 47 return obj.at(id);
42 } else if (obj != null) { 48 } else if (obj !== null) {
43 return obj[id]; 49 return obj[id];
44 } 50 }
45 }; 51 };
46 52
47 rivets.binders['error-*'] = { 53 rivets.binders['error-*'] = {
48 bind: function(el) { 54 bind: function(el) {
49 var self = this;
50 var holder = this.validationHolder = { 55 var holder = this.validationHolder = {
51 //marker: el.parentNode.insertBefore(document.createComment(" rivets: " + this.type + " "), el), 56 //marker: el.parentNode.insertBefore(document.createComment(" rivets: " + this.type + " "), el),
52 focus: function() { 57 focus: function() {
53 $(holder.container).removeClass('focused'); 58 $(holder.container).removeClass('focused');
54 }, 59 },
55 blur: function() { 60 blur: function() {
56 if (holder.lastObj) holder.lastObj.seen(holder.lastId, true); 61 if (holder.lastObj) {
62 holder.lastObj.seen(holder.lastId, true);
63 }
57 $(holder.container).addClass('focused'); 64 $(holder.container).addClass('focused');
58 if (holder.lastObj) holder.lastObj.validate(); 65 if (holder.lastObj) {
66 holder.lastObj.validate();
67 }
59 }, 68 },
60 validated: function(isValid, model, errors) { 69 validated: function(isValid, model, errors) {
61 var errorList = errors[holder.lastId]; 70 var errorList = errors[holder.lastId];
...@@ -76,13 +85,13 @@ define(['rivets', 'bootstrap'], function(rivets) { ...@@ -76,13 +85,13 @@ define(['rivets', 'bootstrap'], function(rivets) {
76 var holder = this.validationHolder; 85 var holder = this.validationHolder;
77 $(this.validationHolder.marker).after(el).remove(); 86 $(this.validationHolder.marker).after(el).remove();
78 $(el).off('focus', holder.focus).off('blur', holder.blur); 87 $(el).off('focus', holder.focus).off('blur', holder.blur);
79 diveIntoObject(this.model, this.keypath, function(obj, id) { 88 diveIntoObject(this.model, this.keypath, function(obj) {
80 obj.off('validated', holder.validated); 89 obj.off('validated', holder.validated);
81 }); 90 });
82 delete this.validationHolder; 91 delete this.validationHolder;
83 rivetsBinderCall(this, this.args[0], 'unbind', arguments); 92 rivetsBinderCall(this, this.args[0], 'unbind', arguments);
84 }, 93 },
85 routine: function(el, value) { 94 routine: function() {
86 var holder = this.validationHolder; 95 var holder = this.validationHolder;
87 if (holder.lastObj) { 96 if (holder.lastObj) {
88 holder.lastObj.off('validated', holder.validated); 97 holder.lastObj.off('validated', holder.validated);
......