client/js/models.js
changeset 293 fba23fde14ba
parent 282 12ee99b182cd
child 298 2f35c2ae7de8
--- a/client/js/models.js	Fri May 16 12:37:51 2014 +0200
+++ b/client/js/models.js	Fri May 16 14:09:57 2014 +0200
@@ -1,31 +1,31 @@
 (function() {
     "use strict";
     var root = this;
-    
+
     var Backbone = root.Backbone;
-    
+
     var Models = root.Rkns.Models = {};
-    
-    
+
+
     Models.getUID = function(obj) {
         var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
-            var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+            var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
             return v.toString(16);
         });
-        return obj.type + "-" + guid; 
+        return obj.type + "-" + guid;
     };
-    
-    
+
+
     var RenkanModel = Backbone.RelationalModel.extend({
         idAttribute : "_id",
         constructor: function(options) {
-            
+
             if (typeof options !== "undefined") {
                 options._id = options._id || options.id || Models.getUID(this);
                 options.title = options.title || "";
                 options.description = options.description || "";
                 options.uri = options.uri || "";
-                
+
                 if(typeof this.prepare === "function") {
                     options = this.prepare(options);
                 }
@@ -47,7 +47,7 @@
             }
         }
     });
-        
+
     // USER
     var User = Models.User = RenkanModel.extend({
         type: "user",
@@ -65,7 +65,7 @@
             };
         }
     });
-    
+
     // NODE
     var Node = Models.Node = RenkanModel.extend({
         type: "node",
@@ -95,7 +95,7 @@
             };
         }
     });
-    
+
     // EDGE
     var Edge = Models.Edge = RenkanModel.extend({
         type: "edge",
@@ -136,7 +136,7 @@
             };
         }
     });
-    
+
     // View
     var View = Models.View = RenkanModel.extend({
         type: "view",
@@ -160,7 +160,7 @@
             };
         }
     });
-        
+
     // PROJECT
     var Project = Models.Project = RenkanModel.extend({
         type: "project",
@@ -209,7 +209,7 @@
             return _user;
         },
         addNode: function(_props, _options) {
-            _props.project = this;            
+            _props.project = this;
             var _node = Node.findOrCreate(_props);
             this.get("nodes").push(_node, _options);
             return _node;
@@ -258,19 +258,19 @@
             this.on("remove:nodes", function(_node) {
                 _this.get("edges").remove(
                     _this.get("edges").filter(function(_edge) {
-                        return _edge.get("from") == _node || _edge.get("to") == _node;
+                        return _edge.get("from") === _node || _edge.get("to") === _node;
                     })
                 );
             });
         }
     });
-    
+
     var RosterUser = Models.RosterUser = Backbone.Model.extend({
         type: "roster_user",
         idAttribute : "_id",
-        
+
         constructor: function(options) {
-            
+
             if (typeof options !== "undefined") {
                 options._id = options._id || options.id || Models.getUID(this);
                 options.title = options.title || "(untitled " + this.type + ")";
@@ -278,25 +278,25 @@
                 options.uri = options.uri || "";
                 options.project = options.project || null;
                 options.site_id = options.site_id || 0;
-                
+
                 if(typeof this.prepare === "function") {
                     options = this.prepare(options);
                 }
             }
             Backbone.Model.prototype.constructor.call(this, options);
         },
-        
+
         validate: function() {
             if(!this.type) {
                 return "object has no type";
             }
         },
-        
+
         prepare: function(options) {
             options.color = options.color || "#666666";
             return options;
         },
-        
+
         toJSON: function() {
             return {
                 _id: this.get("_id"),
@@ -309,11 +309,10 @@
             };
         }
     });
-    
+
     var UsersList = Models.UsersList = Backbone.Collection.extend({
         model: RosterUser
     });
-    
+
 
 }).call(window);
-