diff --git a/js/menus/ImportMenuView.js b/js/menus/ImportMenuView.js index d82590d177c997277ea593f02900dda573b0b1ef..c454f98d886c7737394b85c52a8251b83365b03b 100644 --- a/js/menus/ImportMenuView.js +++ b/js/menus/ImportMenuView.js @@ -15,15 +15,13 @@ ImportMenuView = Backbone.View.extend({ "click #removeFillGeo": "_removeMesh" }, - currentlySelected: false, - initialize: function(options){ this.lattice = options.lattice; _.bindAll(this, "render", "_onMeshLoad"); this.listenTo(this.model, "change", function(){ - if (!this.currentlySelected) return; + if (options.appState.get("currentTab")!="import") return; this.render(); }); // this.listenTo(this.model, "change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation @@ -74,7 +72,6 @@ ImportMenuView = Backbone.View.extend({ }, render: function(){ - this.currentlySelected = true; this.$el.html(this.template(this.model.attributes)); this.lattice.set("cellMode", "cell"); }, diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index d747d3743ffd0881d237d276d967d7f5ca3d24c0..396f6fc29f4ecc9910e834a4b48ee298dcb44ab0 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -12,13 +12,12 @@ LatticeMenuView = Backbone.View.extend({ "change #latticeScale": "_changeScale" }, - currentlySelected: false, - initialize: function(){ + initialize: function(options){ _.bindAll(this, "render"); this.listenTo(this.model, "change", function(){ - if (!this.currentlySelected) return; + if (options.appState.get("currentTab")!="lattice") return; if(!this.model.hasChanged('cellMode')){//I want to ignore cellMode changes and listen to everything else this.render(); } @@ -44,7 +43,6 @@ LatticeMenuView = Backbone.View.extend({ }, render: function(){ - this.currentlySelected = true;//if this causes a change, render must have been called from menu wrapper this.$el.html(this.template(_.extend(this.model.attributes, this._formatData()))); this.model.set("cellMode", "cell"); }, diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 100d63e4e3a97ff5ae5afae04be6077fbc5eed75..9c5dbd5e8db8ac3e026214a071819921c7983105 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -16,11 +16,11 @@ MenuWrapper = Backbone.View.extend({ _.bindAll(this, "render", "_updateCurrentTab", "_setVisibility", "_hide", "_show"); //init all tab view controllers - this.latticeMenu = new LatticeMenuView({model:options.lattice}); - this.importMenu = new ImportMenuView({lattice:options.lattice}); - this.sketchMenu = new SketchMenuView({model:options.lattice}); - this.partMenu = new PartMenuView({model:options.lattice}); - this.scriptMenu = new ScriptMenuView(); + this.latticeMenu = new LatticeMenuView({model:options.lattice, appState:this.model}); + this.importMenu = new ImportMenuView({lattice:options.lattice, appState:this.model}); + this.sketchMenu = new SketchMenuView({model:options.lattice, appState:this.model}); + this.partMenu = new PartMenuView({model:options.lattice, appState:this.model}); + this.scriptMenu = new ScriptMenuView({appState:this.model}); //data names and titles this.designMenuTabs = {lattice:"Lattice", import:"Import", sketch:"Sketch", part:"Part", script:"Script"}; @@ -52,8 +52,6 @@ MenuWrapper = Backbone.View.extend({ } }); - this._deselectAllMenus(); - if (tabName == "lattice"){ this.latticeMenu.render(); } else if (tabName == "import"){ @@ -71,15 +69,6 @@ MenuWrapper = Backbone.View.extend({ }, - //todo get rid of this!! - _deselectAllMenus: function(){ - this.latticeMenu.currentlySelected = false; - this.importMenu.currentlySelected = false; - this.sketchMenu.currentlySelected = false; - this.partMenu.currentlySelected = false; -// this.scriptMenu.currentlySelected = false; - }, - render: function(){ var self = this; this._hide(function(){ diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index 21cdec39b060392058cd6b86553223038c0e094b..a8c455db3155f3626841560f006b7c4461bffe29 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -9,20 +9,17 @@ PartMenuView = Backbone.View.extend({ events: { }, - currentlySelected: false, - initialize: function(){ _.bindAll(this, "render"); this.listenTo(this.model, "change:partType", this.render); // this.listenTo(this.model, "change", function(){ -// if (!this.currentlySelected) return; +// if (options.appState.get("currentTab")!="part") return; // this.render(); // }); }, render: function(){ - this.currentlySelected = true;//if this causes a change, render must have been called from menu wrapper this.$el.html(this.template(this.model.attributes)); this.model.set("cellMode", "parts"); }, diff --git a/js/menus/SketchMenuView.js b/js/menus/SketchMenuView.js index 2ae4c70976161cddc3842885293c5ad48bd23013..e146cb59abd049a251cd2aceabdfa9b81a8ec45f 100644 --- a/js/menus/SketchMenuView.js +++ b/js/menus/SketchMenuView.js @@ -10,19 +10,16 @@ SketchMenuView = Backbone.View.extend({ events: { }, - currentlySelected: false, - initialize: function(){ _.bindAll(this, "render"); // this.listenTo(this.model, "change", function(){ -// if (!this.currentlySelected) return; +// if (options.appState.get("currentTab")!="sketch") return; // this.render(); // }); }, render: function(){ - this.currentlySelected = true; this.$el.html(this.template()); this.model.set("cellMode", "cell"); },