From b774ee51a841daf9de8786f6c4e2f09cce72460c Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 2 Jun 2015 13:59:14 -0700
Subject: [PATCH] more menu mods

---
 js/lattice/Lattice.js       |  22 +++----
 js/main.js                  |  14 ++++-
 js/menus/LatticeMenuView.js |   5 +-
 js/menus/MenuParentView.js  |   5 +-
 js/menus/PartMenuView.js    | 113 ++++++++++++++++++------------------
 js/models/PList.js          |  12 ++--
 js/three/ThreeView.js       |   4 +-
 7 files changed, 92 insertions(+), 83 deletions(-)

diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index a4086e69..d44739c6 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -3,7 +3,7 @@
  */
 
 
-define(['appState', 'plist', 'three'], function(appState, plist, THREE){
+define(['appState', 'plist', 'three', 'threeModel'], function(appState, plist, THREE, three){
 
     var Lattice = Backbone.Model.extend({
 
@@ -73,7 +73,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
                     }
                 }
             }
-            globals.three.render();
+            three.render();
             return newCells;
         },
 
@@ -86,7 +86,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             if (!cells[index.x][index.y][index.z]) {
                 cells[index.x][index.y][index.z] = this.makeCellForLatticeType(indices);
                 this.set("numCells", this.get("numCells")+1);
-                if (!noRender) globals.three.render();
+                if (!noRender) three.render();
             } else console.warn("already a cell there");
 
         },
@@ -126,7 +126,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             //todo shrink cells matrix if needed
 
             this.set("numCells", this.get("numCells")-1);
-            globals.three.render();
+            three.render();
         },
 
         //todo send clear all to three and destroy without sceneRemove to cell
@@ -140,7 +140,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             this.set("nodes", []);
             this.set("numCells", 0);
             if (globals.basePlane) globals.basePlane.set("zIndex", 0);
-            globals.three.render();
+            three.render();
         },
 
         calculateBoundingBox: function(){
@@ -193,7 +193,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
                 }
 
             }
-            globals.three.render();
+            three.render();
         },
 
         _findIntersectionsInWindow: function(windowX, windowY, origin, allVertexPos){
@@ -321,7 +321,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             this._iterCells(this.get("cells"), function(cell){
                 if (cell) cell.setMode(cellMode);
             });
-            globals.three.render();
+            three.render();
         },
 
         _updateCellSeparation: function(){
@@ -333,7 +333,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             this._iterCells(this.get("cells"), function(cell){
                 if (cell) cell.updateForScale(cellMode, partType);
             });
-            globals.three.render();
+            three.render();
         },
 
         _setCellVisibility: function(){
@@ -346,7 +346,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             this._iterCells(this.get("cells"), function(cell){
                 if (cell) cell.hide();
             });
-            globals.three.render();
+            three.render();
         },
 
         showCells: function(){
@@ -354,7 +354,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
             this._iterCells(this.get("cells"), function(cell){
                 if (cell) cell.show(cellMode)
             });
-            globals.three.render();
+            three.render();
         },
 
         showCellAtIndex: function(index){
@@ -416,7 +416,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){
                 //}
                 cells[x][y][z] = newCell;
             });
-            globals.three.render();
+            three.render();
         },
 
         _getSubclassForLatticeType: function(loadingFromFile){
diff --git a/js/main.js b/js/main.js
index b78dd18e..be57e720 100644
--- a/js/main.js
+++ b/js/main.js
@@ -27,7 +27,19 @@ requirejs.config({
         //UI
         menuWrapper: 'menus/MenuWrapperView',
         menuParent: 'menus/MenuParentView',
-        latticeMenu: 'menus/LatticeMenuView'
+        latticeMenu: 'menus/LatticeMenuView',
+        importMenu: 'menus/LatticeMenuView',
+        partMenu: 'menus/PartMenuView',
+        scriptMenu: 'menus/ScriptMenuView',
+        physicsMenu: 'menus/PhysicsMenuView',
+        materialMenu: 'menus/MaterialMenuView',
+        optimizeMenu: 'menus/OptimizationMenuView',
+        assemblerMenu: 'menus/AssemblerMenuView',
+        camMenu: 'menus/CamMenuView',
+        animateMenu: 'menus/AnimationMenuView',
+        sendMenu: 'menus/SendMenuView'
+
+
     },
     shim: {
         three: {
diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js
index 4ef8a2ed..0a639d4f 100644
--- a/js/menus/LatticeMenuView.js
+++ b/js/menus/LatticeMenuView.js
@@ -4,7 +4,7 @@
 
 define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, plist){
 
-    var LatticeMenuView = MenuParentView.extend({
+    return MenuParentView.extend({
 
         events: {
         },
@@ -63,9 +63,6 @@ define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, pli
             ')
 
     });
-
-    return LatticeMenuView;
-
 });
 
 //Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): &nbsp;&nbsp;<input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text">\
diff --git a/js/menus/MenuParentView.js b/js/menus/MenuParentView.js
index b10e5301..8d1a8712 100644
--- a/js/menus/MenuParentView.js
+++ b/js/menus/MenuParentView.js
@@ -5,7 +5,7 @@
 
 define(['backbone'], function(Backbone){
 
-    var MenuParentView = Backbone.View.extend({
+    return Backbone.View.extend({
 
         el: "#menuContent",
 
@@ -14,7 +14,4 @@ define(['backbone'], function(Backbone){
         }
 
     });
-
-    return MenuParentView;
-
 });
\ No newline at end of file
diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js
index 991c2150..a060c611 100644
--- a/js/menus/PartMenuView.js
+++ b/js/menus/PartMenuView.js
@@ -2,60 +2,63 @@
  * Created by aghassaei on 1/26/15.
  */
 
-PartMenuView = Backbone.View.extend({
-
-    el: "#menuContent",
-
-    events: {
-    },
-
-    initialize: function(){
-
-        _.bindAll(this, "render");
-
-        //bind events
-        this.listenTo(globals.lattice, "change", this.render);
-        this.listenTo(globals.appState, "change", this.render);
-    },
-
-    render: function(){
-        if (this.model.changedAttributes()["currentNav"]) return;
-        if (this.model.get("currentTab") != "part") return;
-        if ($("input[type=text]").is(":focus")) return;
-        this.$el.html(this.template(_.extend(globals.lattice.toJSON(), globals.appState.toJSON(), globals.plist)));
-    },
-
-    template: _.template('\
-        Part Type: &nbsp;&nbsp;\
-        <div class="btn-group">\
-                <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allPartTypes[cellType][connectionType][partType] %><span class="caret"></span></button>\
-                <ul role="menu" class="dropdown-menu">\
-                    <% _.each(_.keys(allPartTypes[cellType][connectionType]), function(key){ %>\
-                        <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= allPartTypes[cellType][connectionType][key] %></a></li>\
-                    <% }); %>\
-                </ul>\
-            </div><br/><br/>\
-        <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): &nbsp;&nbsp;<input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\
-        &nbsp;<input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\
-        <% } else { %>( radial ): &nbsp;&nbsp;<input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\
-        <br/><br/>--><br/>\
-        <% if (allMaterialTypes[cellType][connectionType]){ %> \
-        Materials:<br/>\
-        <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\
-        <label class="radio colorSwatches">\
-            <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
-            <div class="materialColorSwatch">\
-            <div style="background-color:<% if(realisticColorScheme){ %><%= allMaterialTypes[cellType][connectionType][key].color %><% }else{ %><%= allMaterialTypes[cellType][connectionType][key].altColor %><% } %>"></div>\
-            <span><%= allMaterialTypes[cellType][connectionType][key].name %></span></div>\
-        </label>\
-        <% }); %>\
-        <br/>\
-        <label class="checkbox" for="realisticColorScheme">\
-        <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">\
-        <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
-        Use realistic color scheme</label>\
-        <% } %>\
-        <br/>\
-        ')
+define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, plist){
 
+    return MenuParentView({
+
+        el: "#menuContent",
+
+        events: {
+        },
+
+        initialize: function(){
+
+            _.bindAll(this, "render");
+
+            //bind events
+            this.listenTo(lattice, "change", this.render);
+            this.listenTo(this.model, "change", this.render);
+        },
+
+        render: function(){
+            if (this.model.changedAttributes()["currentNav"]) return;
+            if (this.model.get("currentTab") != "part") return;
+            if ($("input[type=text]").is(":focus")) return;
+            this.$el.html(this.template(_.extend(lattice.toJSON(), this.model.toJSON(), plist)));
+        },
+
+        template: _.template('\
+            Part Type: &nbsp;&nbsp;\
+            <div class="btn-group">\
+                    <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allPartTypes[cellType][connectionType][partType] %><span class="caret"></span></button>\
+                    <ul role="menu" class="dropdown-menu">\
+                        <% _.each(_.keys(allPartTypes[cellType][connectionType]), function(key){ %>\
+                            <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= allPartTypes[cellType][connectionType][key] %></a></li>\
+                        <% }); %>\
+                    </ul>\
+                </div><br/><br/>\
+            <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): &nbsp;&nbsp;<input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\
+            &nbsp;<input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\
+            <% } else { %>( radial ): &nbsp;&nbsp;<input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\
+            <br/><br/>--><br/>\
+            <% if (allMaterialTypes[cellType][connectionType]){ %> \
+            Materials:<br/>\
+            <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\
+            <label class="radio colorSwatches">\
+                <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
+                <div class="materialColorSwatch">\
+                <div style="background-color:<% if(realisticColorScheme){ %><%= allMaterialTypes[cellType][connectionType][key].color %><% }else{ %><%= allMaterialTypes[cellType][connectionType][key].altColor %><% } %>"></div>\
+                <span><%= allMaterialTypes[cellType][connectionType][key].name %></span></div>\
+            </label>\
+            <% }); %>\
+            <br/>\
+            <label class="checkbox" for="realisticColorScheme">\
+            <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">\
+            <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
+            Use realistic color scheme</label>\
+            <% } %>\
+            <br/>\
+            ')
+
+    });
 });
\ No newline at end of file
diff --git a/js/models/PList.js b/js/models/PList.js
index 7f87f81b..b1997334 100644
--- a/js/models/PList.js
+++ b/js/models/PList.js
@@ -15,15 +15,15 @@ define(['three'], function(THREE){
             },
             navSim:{
                 physics:"Physics",
-                    part:"Part",
-                    material:"Material",
-                    optimize:"Optimize"
+                part:"Part",
+                material:"Material",
+                optimize:"Optimize"
             },
             navAssemble:{
                 assembler:"Assembler",
-                    cam: "Process",
-                    animate:"Preview",
-                    send: "Send"
+                cam: "Process",
+                animate:"Preview",
+                send: "Send"
             }
         },
 
diff --git a/js/three/ThreeView.js b/js/three/ThreeView.js
index 4bc5b803..39de47c1 100644
--- a/js/three/ThreeView.js
+++ b/js/three/ThreeView.js
@@ -2,7 +2,7 @@
  * Created by aghassaei on 1/16/15.
  */
 
-define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbone, threeModel, THREE, appState){
+define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbone, three, THREE, appState){
 
     var ThreeView = Backbone.View.extend({
 
@@ -154,6 +154,6 @@ define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbon
 
     });
 
-    return new ThreeView({model:threeModel});
+    return new ThreeView({model:three});
 
 });
\ No newline at end of file
-- 
GitLab