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

menu event binding

parent a2401f27
Branches
No related tags found
No related merge requests found
......@@ -27,8 +27,6 @@
this.position = position;
this.drawForMode(mode, position);
this._draw();
// this.parts = this._createParts(nodes, config);
}
......@@ -38,6 +36,7 @@
// parts.push(new Part(nodes[i], config[i]));
// }
// return parts;
return null;
};
Cell.prototype._buildCellMesh = function(position){//abstract mesh representation of cell
......
......@@ -12,10 +12,17 @@ LatticeMenuView = Backbone.View.extend({
},
currentlySelected: false,
initialize: function(){
_.bindAll(this, "render");
this.listenTo(this.model, "change", this.render);
this.listenTo(this.model, "change", function(){
if (!this.currentlySelected) return;
if(!this.model.hasChanged('cellMode')){//I want to ignore cellMode changes and listen to everything else
this.render();
}
});
},
_clearCells: function(e){
......@@ -30,7 +37,9 @@ 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");
},
template: _.template('\
......
......@@ -26,6 +26,7 @@ function MenuWrapper(args){
});
$this.parent().addClass("active");
deselectAllMenus();
var tabName = $this.parent().data('name');
if (tabName == "lattice"){
latticeMenu.render();
......@@ -43,6 +44,14 @@ function MenuWrapper(args){
}
});
function deselectAllMenus(){
latticeMenu.currentlySelected = false;
// importMenu.currentlySelected = false;
// sketchMenu.currentlySelected = false;
partMenu.currentlySelected = false;
// scriptMenu.currentlySelected = false;
}
function init(){
latticeMenu.render();//init with lattice menu open
}
......
......@@ -9,6 +9,8 @@ PartMenuView = Backbone.View.extend({
events: {
},
currentlySelected: false,
initialize: function(){
_.bindAll(this, "render");
......@@ -16,7 +18,9 @@ PartMenuView = 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(this.model.attributes));
this.model.set("cellMode", "parts");
},
template: _.template('\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment