From c153d895bdaa38951d4c12c874fd126a721ee717 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 10 Jun 2015 16:16:58 -0700 Subject: [PATCH] simplify nav tab logic --- js/menus/MaterialMenuView.js | 6 ++++++ js/models/AppState.js | 24 ++++++------------------ js/models/PList.js | 3 +++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/js/menus/MaterialMenuView.js b/js/menus/MaterialMenuView.js index 46e5517f..432875ac 100644 --- a/js/menus/MaterialMenuView.js +++ b/js/menus/MaterialMenuView.js @@ -7,6 +7,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ return MenuParentView.extend({ events: { + "click #navToCompositeMenu": "_navToCompositeMenu" }, _initialize: function(){ @@ -15,6 +16,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ this.listenTo(this.model, "change", this.render); }, + _navToCompositeMenu: function(e){ + e.preventDefault(); + this.model.set("currentNav", "navComposite"); + }, + _makeTemplateJSON: function(){ return _.extend(lattice.toJSON(), this.model.toJSON(), plist); }, diff --git a/js/models/AppState.js b/js/models/AppState.js index b6ef4f7e..41971c24 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -5,7 +5,7 @@ //a class to store global app state, model for navbar and menu wrapper //never deallocated -define(['underscore', 'backbone', 'threeModel', 'three'], function(_, Backbone, three, THREE){ +define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, Backbone, three, THREE, plist){ var AppState = Backbone.Model.extend({ @@ -15,9 +15,7 @@ define(['underscore', 'backbone', 'threeModel', 'three'], function(_, Backbone, currentTab:"lattice", //last tab that one open in each of the main menus - lastDesignTab: "lattice", - lastSimulationTab: "physics", - lastAssembleTab: "assembler", + lastNavTab: {}, menuIsVisible: true, scriptIsVisible: false, @@ -85,16 +83,10 @@ define(['underscore', 'backbone', 'threeModel', 'three'], function(_, Backbone, if (currentTab != "animate") this.set("stockSimulationPlaying", false); if (currentTab != "cam") this.set("manualSelectOrigin", false); if (currentTab == "import" && globals.lattice.get("connectionType") == "edgeRot") globals.lattice.set("partType", "voxLowPoly"); - this._storeTab(this.get("currentNav"), currentTab); + this.get("lastNavTab")[this.get("currentNav")] = currentTab;//store tab this._updateCellMode(currentTab); }, - _storeTab: function(currentNav, currentTab){ - if (currentNav == "navDesign") this.set("lastDesignTab", currentTab); - else if (currentNav == "navSim") this.set("lastSimulationTab", currentTab); - else if (currentNav == "navAssemble") this.set("lastAssembleTab", currentTab); - }, - _updateCellMode: function(currentTab){ if (currentTab == "lattice" || currentTab == "import") this.set("cellMode", "cell"); //else if (currentTab == "import") this.set("cellMode", "cell"); @@ -105,17 +97,13 @@ define(['underscore', 'backbone', 'threeModel', 'three'], function(_, Backbone, _navChanged: function(){ //update to last tab open in that section var navSelection = this.get("currentNav"); + var nextTab = this.get("lastNavTab")[navSelection] || _.keys(plist.allMenuTabs[navSelection])[0]; + this.set("currentTab", nextTab); + if (navSelection == "navDesign") { - this.set("currentTab", this.get("lastDesignTab")); this.set("basePlaneIsVisible", true); this.set("highlighterIsVisible", true); } - else if (navSelection == "navSim") { - this.set("currentTab", this.get("lastSimulationTab")); - } - else if (navSelection == "navAssemble") { - this.set("currentTab", this.get("lastAssembleTab")); - } }, _updateColorScheme: function(){ diff --git a/js/models/PList.js b/js/models/PList.js index 6c30ae34..7e740684 100644 --- a/js/models/PList.js +++ b/js/models/PList.js @@ -24,6 +24,9 @@ define(['three'], function(THREE){ cam: "Process", animate:"Preview", send: "Send" + }, + navComposite:{ + composite:"Composite" } }, -- GitLab