Skip to content
Snippets Groups Projects
Commit 6e59aebe authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

appstate instead of weird properties on menus

parent a6c503ac
No related branches found
No related tags found
No related merge requests found
......@@ -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");
},
......
......@@ -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");
},
......
......@@ -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(){
......
......@@ -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");
},
......
......@@ -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");
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment