From a6c503ac73ec715d68bc15c953db9b3946e6e2ca Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Thu, 29 Jan 2015 17:01:47 -0500
Subject: [PATCH] all menus working

---
 js/menus/MenuWrapperView.js | 13 +++++++------
 js/menus/navbar.js          |  7 ++++++-
 js/models/AppState.js       |  2 +-
 main.html                   |  6 +++---
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js
index 7d539359..100d63e4 100644
--- a/js/menus/MenuWrapperView.js
+++ b/js/menus/MenuWrapperView.js
@@ -66,7 +66,7 @@ MenuWrapper = Backbone.View.extend({
             this.scriptMenu.render();
         } else {
             console.warn("no tab initialized!");
-            $("#menuContent").html('');//clear out content from menu
+            $("#menuContent").html('Something goes here eventually.');//clear out content from menu
         }
 
     },
@@ -89,9 +89,9 @@ MenuWrapper = Backbone.View.extend({
 
     _populateAndShow: function(){
         this.$el.html(this.template(_.extend(this.model.attributes,
-            {designMenuTabs:this.designMenuTabs,
-            simMenuTabs:this.simMenuTabs,
-            assemMenuTabs:this.assemMenuTabs})));
+            {navDesign:this.designMenuTabs,
+            navSim:this.simMenuTabs,
+            navAssemble:this.assemMenuTabs})));
         this._updateCurrentTab();
         this._show();
     },
@@ -116,8 +116,9 @@ MenuWrapper = Backbone.View.extend({
 
     template: _.template('\
         <ul class="nav nav-tabs nav-justified">\
-        <% _.each(_.keys(designMenuTabs), function(key){%>\
-          <li role="presentation" data-name="<%= key %>"><a href="#"><%= designMenuTabs[key] %></a></li>\
+        <% var dict = eval(currentNav);\
+        _.each(_.keys(dict), function(key){%>\
+          <li role="presentation" data-name="<%= key %>"><a href="#"><%= dict[key] %></a></li>\
         <% }); %>\
         </ul>\
         ')
diff --git a/js/menus/navbar.js b/js/menus/navbar.js
index a18cd392..9d52b6ca 100644
--- a/js/menus/navbar.js
+++ b/js/menus/navbar.js
@@ -49,7 +49,12 @@ NavBar = Backbone.View.extend({
         $link.parent().addClass("open");//highlight
         var navSelection = $link.data("menuId");
         if (navSelection == "about") return;
-        if (navSelection) this.model.set("currentNav", navSelection);
+        if (navSelection) {
+            if (navSelection=="navDesign") this.model.set("currentTab", "lattice", {silent: true});
+            else if (navSelection=="navSim") this.model.set("currentTab", "physics", {silent: true});
+            else if (navSelection=="navAssemble") this.model.set("currentTab", "assembler", {silent: true});
+            this.model.set("currentNav", navSelection);
+        }
     },
 
     _uiStuff: function(){
diff --git a/js/models/AppState.js b/js/models/AppState.js
index 063bff72..829ff896 100644
--- a/js/models/AppState.js
+++ b/js/models/AppState.js
@@ -8,7 +8,7 @@
 AppState = Backbone.Model.extend({
 
     defaults: {
-        currentNav:"design",//design, sim, assemble
+        currentNav:"navDesign",//design, sim, assemble
         currentTab:"lattice",
         menuIsVisible: true
     },
diff --git a/main.html b/main.html
index 13519dae..1a9ebc8a 100644
--- a/main.html
+++ b/main.html
@@ -80,9 +80,9 @@
     </div>
     <div class="collapse navbar-collapse" id="navbar-collapse-01">
       <ul class="nav navbar-nav navbar-left">
-        <li><a data-menu-id="design" class="menuHoverControls" href="#">Design</a></li>
-        <li><a data-menu-id="sim" class="menuHoverControls" href="#">Simulate</a></li>
-        <li><a data-menu-id="assemble" class="menuHoverControls" href="#">Assemble</a></li>
+        <li><a data-menu-id="navDesign" class="menuHoverControls" href="#">Design</a></li>
+        <li><a data-menu-id="navSim" class="menuHoverControls" href="#">Simulate</a></li>
+        <li><a data-menu-id="navAssemble" class="menuHoverControls" href="#">Assemble</a></li>
         <li class="dropdown navDropdown">
           <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <b class="caret"></b></a>
           <span class="dropdown-arrow"></span>
-- 
GitLab