From d4b502302735ae7ce0125732630ef02b6817195b Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 10 Jun 2015 17:40:57 -0700 Subject: [PATCH] composite editor subclass for lattice --- js/lattice/CompositeEditorLattice.js | 38 ++++++++++++++++++++++++++++ js/lattice/Lattice.js | 2 -- js/menus/CompositeMenu.js | 11 ++++++-- js/models/AppState.js | 2 +- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 js/lattice/CompositeEditorLattice.js diff --git a/js/lattice/CompositeEditorLattice.js b/js/lattice/CompositeEditorLattice.js new file mode 100644 index 00000000..4cfc745e --- /dev/null +++ b/js/lattice/CompositeEditorLattice.js @@ -0,0 +1,38 @@ +/** + * Created by aghassaei on 6/10/15. + */ + + +define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'three', 'threeModel'], + function(_, Backbone, appState, lattice, globals, plist, THREE, three){ + + var defaults = { + compositeCells:[[[null]]], + compositeColor: null + }; + + var CompositeEditorLattice = { + + + + _initCompositeEditor: function(){ + + _.each(_.keys(defaults), function(key){ + this.set(key, defaults[key], {silent:true}); + }); + + }, + + _undoCompositeEditor: function(){ + var self = this; + _.each(_.keys(CompositeEditorLattice), function(key){ + self[key] = null; + }); + _.each(_.keys(defaults), function(key){ + this.unset(key, defaults[key], {silent:true}); + }); + } + }; + + return CompositeEditorLattice; +}); diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index b79e5827..f3a25d9d 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -17,8 +17,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre cellsMax: null,//max position of cells matrix numCells: 0, - scale: 20, - //spacing for connectors/joints cellSeparation: {xy:0, z:0}, diff --git a/js/menus/CompositeMenu.js b/js/menus/CompositeMenu.js index 2b6903f3..5ea2a530 100644 --- a/js/menus/CompositeMenu.js +++ b/js/menus/CompositeMenu.js @@ -9,7 +9,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ events: { "click #newRandomColor": "_changeRandomColor", "click #finishComposite": "_finishComposite", - "click #saveComposite": "_saveComposite" + "click #saveComposite": "_saveComposite", + "click #cancelComposite": "_cancelComposite" }, _initialize: function(){ @@ -37,7 +38,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ _finishComposite: function(e){ e.preventDefault(); - + this.model.set("currentNav", "navDesign"); }, _saveComposite: function(e){ @@ -45,6 +46,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ }, + _cancelComposite: function(e){ + e.preventDefault(); + this.model.set("currentNav", "navDesign"); + }, + _makeTemplateJSON: function(){ return _.extend(this.material); }, @@ -59,6 +65,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ <input value="<%= color %>" placeholder="Enter HEX" class="halfWidth form-control" type="text"><br/>\ <a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/><br/>\ <a id="finishComposite" href="#" class="btn btn-block btn-lg btn-success">Finish Composite</a><br/>\ + <a id="cancelComposite" href="#" class="btn btn-block btn-lg btn-danger">Cancel / Exit</a><br/>\ \ ') diff --git a/js/models/AppState.js b/js/models/AppState.js index 4154fb40..f384d2ed 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -97,7 +97,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B //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); + this.set("currentTab", nextTab, {silent:true}); if (navSelection == "navDesign") { this.set("basePlaneIsVisible", true); -- GitLab