From 1b9c09f30e2be3d0b8ea078b492473ea0bd85050 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Thu, 11 Jun 2015 15:49:18 -0700
Subject: [PATCH] lattice subclass working

---
 js/lattice/CompositeEditorLattice.js | 3 ++-
 js/lattice/Lattice.js                | 8 +++++---
 js/lattice/LatticeBase.js            | 4 ++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/js/lattice/CompositeEditorLattice.js b/js/lattice/CompositeEditorLattice.js
index 1c9c0105..c4bc2800 100644
--- a/js/lattice/CompositeEditorLattice.js
+++ b/js/lattice/CompositeEditorLattice.js
@@ -19,12 +19,13 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             color: null
         }),
 
-        __initialize: function(options){
+        __initialize: function(options, callback){
             if (!options.id || options.id == "") this.set("id", this.cid);
             if (!options.color || options.color == "") this.set("color",  makeRandomColor(), {silent:true});
             this.set("numCells", 3);//todo remove this
             this.set("cellsMin", new THREE.Vector3(0,0,0));
             this.set("cellsMax", new THREE.Vector3(0,0,0));
+            if (callback) callback(this);
         },
 
         initLatticeSubclass: function(subclass){
diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index 90074f6d..cbf054b1 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -253,9 +253,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
                     console.warn("composite editor already allocated");
                     self.compositeEditor.destroy();
                 }
-                self.compositeEditor = new CompositeEditorLattice(_.extend({id:id}, data));
-                self.compositeEditor.initLatticeSubclass(self._getSubclassForLatticeType());
-                appState.set("currentNav", "navComposite");
+                self.compositeEditor = new CompositeEditorLattice(_.extend({id:id}, data), null, function(_self){
+                    _self.initLatticeSubclass(self._getSubclassForLatticeType());
+                    appState.set("currentNav", "navComposite");
+                });
+
             });
         },
 
diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js
index 0e2db935..9714f965 100644
--- a/js/lattice/LatticeBase.js
+++ b/js/lattice/LatticeBase.js
@@ -21,7 +21,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
         },
 
 
-        initialize: function(options){
+        initialize: function(options, classProperties, callback){
 
             this.cells = [[[null]]];//3D matrix containing all cells and null, dynamic size
             this.sparseCells = [[[null]]];//3D matrix containing highest hierarchical level of cells and null
@@ -32,7 +32,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             this.listenTo(appState, "change:cellsVisible", this._setCellVisibility);
 
             if (this.__bindEvents) this.__bindEvents();
-            if (this.__initialize) this.__initialize(options);
+            if (this.__initialize) this.__initialize(options, callback);
         },
 
 
-- 
GitLab