From 72baf1c366829ada6858097dd7553ee9988d6110 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 24 Feb 2012 14:43:51 -0800 Subject: removing the old settings class and disabling panel settings until the new panels are in Signed-off-by: Valerio Virgillito --- js/data/settings.js | 54 --------------- js/ninja.reel/ninja.html | 5 -- js/panels/Panel.reel/Panel.html | 3 +- js/panels/PanelBase.js | 40 +++++------- .../PanelContainer.reel/PanelContainer.js | 8 ++- js/panels/Resizer.js | 76 +++++++++++++--------- 6 files changed, 70 insertions(+), 116 deletions(-) delete mode 100755 js/data/settings.js (limited to 'js') diff --git a/js/data/settings.js b/js/data/settings.js deleted file mode 100755 index 6b1af3fc..00000000 --- a/js/data/settings.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - LocalStorage = require("js/controllers/local-storage-controller").LocalStorage; - -exports.Settings = Montage.create( Component, { - - _settings: { - value: null - }, - - settings: { - get: function() { return this._settings; }, - set: function(value) { this._settings = value; } - }, - - getSetting: { - value: function(objName, fieldName, namespace) { - try { - objName = objName.replace(/-/gi, "_").replace(/\//gi, "zzSlash"); - return this.settings[objName][fieldName]; - } catch(e) { - return null; - } - } - }, - - setSetting: { - value: function(objName, fieldName, value, namespace) { - try { - objName = objName.replace(/-/gi, "_").replace(/\//gi, "zzSlash"); - - if(this.settings === null) { - this.settings = {}; - } - - if (this.settings[objName] == null) { - this.settings[objName] = {}; - } - - this.settings[objName][fieldName] = value; - - LocalStorage.setItem("settings", this.settings); - } catch(e) { - return null; - } - } - } -}); \ No newline at end of file diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 953e560c..b1fb6352 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -27,11 +27,6 @@ "name": "LocalStorage" }, - "settings1": { - "module": "js/data/settings", - "name": "Settings" - }, - "toolsData1": { "module": "js/data/tools-data", "name": "ToolsData" diff --git a/js/panels/Panel.reel/Panel.html b/js/panels/Panel.reel/Panel.html index 46c8fb91..7556952c 100755 --- a/js/panels/Panel.reel/Panel.html +++ b/js/panels/Panel.reel/Panel.html @@ -14,7 +14,8 @@ "properties": { "element": {"#": "resizeBar"}, "panel": {"#": "panel"}, - "isVertical": true + "isVertical": true, + "willSave": false }, "bindings": { "ownerId": { diff --git a/js/panels/PanelBase.js b/js/panels/PanelBase.js index 03dcd0ee..473de596 100755 --- a/js/panels/PanelBase.js +++ b/js/panels/PanelBase.js @@ -36,56 +36,55 @@ exports.PanelBase = Montage.create(Component, { /* if(this.application.ninja.settings.getSetting(this.panelName, "contentHeight")) { this._contentHeight = this.application.ninja.settings.getSetting(this.panelName, "contentHeight"); - } else { - this._contentHeight = this.defaultHeight; - }*/ + } */ + this._contentHeight = this.defaultHeight; } return this._contentHeight; }, set: function(value) { - if (this.minHeight > value) value = this._minHeight; - if (this.maxHeight != null) if(this.maxHeight < value) value = this.maxHeight; + if (this.minHeight > value) value = this._minHeight; + if (this.maxHeight != null) if(this.maxHeight < value) value = this.maxHeight; this._contentHeight = value; -// this.application.ninja.settings.setSetting(this.panelName, "contentHeight", value); + + // this.application.ninja.settings.setSetting(this.panelName, "contentHeight", value); } }, forcedCollapse: { get: function() { if(this._forcedCollapse == null) { + // Old settings /* if(this.application.Ninja.SettingsManager.getSetting(this.panelName, "isPanelForceCollapsed")) { this._forcedCollapse = this.application.Ninja.SettingsManager.getSetting(this.panelName, "isPanelForceCollapsed"); - } else { - this._forcedCollapse = false; - } - */ + } */ this._forcedCollapse = false; } return this._forcedCollapse; }, set: function(value) { this._forcedCollapse = value; - //this.application.Ninja.SettingsManager.setSetting(this.panelName, "isPanelForceCollapsed", value); + + // this.application.Ninja.SettingsManager.setSetting(this.panelName, "isPanelForceCollapsed", value); } }, collapsed: { get: function() { if(this._collapsed == null) { + // Old settings /* if(this.application.ninja.settings.getSetting(this.panelName, "isPanelCollapsed")) { this._collapsed = this.application.ninja.settings.getSetting(this.panelName, "isPanelCollapsed"); - } else { - this._collapsed = false; - } - */ + } */ + this._collapsed = false; } return this._collapsed; }, set: function(value) { this._collapsed = value; - //this.application.ninja.settings.setSetting(this.panelName, "isPanelCollapsed", value); + + // this.application.ninja.settings.setSetting(this.panelName, "isPanelCollapsed", value); } }, visible: { @@ -95,10 +94,8 @@ exports.PanelBase = Montage.create(Component, { /* if(typeof(this.application.ninja.settings.getSetting(this.panelName, "visible")) !== "undefined") { this._visible = this.application.ninja.settings.getSetting(this.panelName, "visible"); - } else { - this._visible = true; - } - */ + } */ + this._visible = true; } @@ -112,7 +109,4 @@ exports.PanelBase = Montage.create(Component, { } } - - // Methods exist in panel.js - }); diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js index bdd112c6..3cbd4369 100755 --- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js @@ -63,16 +63,19 @@ exports.PanelContainer = Montage.create(Component, { value: function() { //Panels Loading this.lastOffset = this.element.offsetHeight; - /* + + /* Old Settings if( this.application.ninja.settings.getSetting(this.element.id, "panelOrder") != null) { this.initPanelOrder = this.application.ninja.settings.getSetting(this.element.id, "panelOrder") } */ + // if Panels already loaded no need to load again. for(var i = 0; i < this.initPanelOrder.length; i++) { this.addPanel(eval(this.initPanelOrder[i])); this.panelOrder.push(this.initPanelOrder[i]); -// this.application.ninja.settings.setSetting(this.element.id, "panelOrder", this.panelOrder); + +// this.application.ninja.settings.setSetting(this.element.id, "panelOrder", this.panelOrder); } var hideSplitter = true; @@ -331,6 +334,7 @@ exports.PanelContainer = Montage.create(Component, { this._panels.splice(overed,0, panelRemoved[0]); var panelOrderRemoved = this.panelOrder.splice(selected,1); this.panelOrder.splice(overed,0, panelOrderRemoved[0]); + //this.application.ninja.settings.setSetting(this.element.id, "panelOrder", this.panelOrder); } } diff --git a/js/panels/Resizer.js b/js/panels/Resizer.js index e9bd4fc0..60fdde4f 100755 --- a/js/panels/Resizer.js +++ b/js/panels/Resizer.js @@ -8,15 +8,42 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; exports.Resizer = Montage.create(Component, { - + + version: { + value: "1.0" + }, + hasTemplate: { value: false }, + // This property might not be needed anymore. + // TODO - Review this once we the the new panels in place ownerId: { value: "" }, - + + willSave: { + value: true + }, + + _value: { + value: null + }, + + value: { + get: function() { + return this._value; + }, + set: function(val) { + this._value = val; + } + }, + + redrawStage: { + value:false + }, + _isInversed: { value: false }, @@ -101,7 +128,8 @@ exports.Resizer = Montage.create(Component, { } else { this.panel.style.width = ""; } -// this.application.ninja.settings.setSetting(this.element.id,"value", ""); + + this.application.localStorage.setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": ""}); } }, @@ -116,8 +144,15 @@ exports.Resizer = Montage.create(Component, { prepareForDraw: { value: function() { -// console.log("owner id: ", this.ownerId); - console.log("resizer for ", this.element.getAttribute("data-montage-id") + this.ownerId); + if(this.willSave) { + var storedData = this.application.localStorage.getItem(this.element.getAttribute("data-montage-id")); + + if(storedData && storedData.value) { + this.value = storedData.value; + } + + } + if(this.value != null) { if (this.isVertical) { this.panel.style.height = this.value + "px"; @@ -142,15 +177,19 @@ exports.Resizer = Montage.create(Component, { window.removeEventListener("mousemove", this); window.removeEventListener("mouseup", this); this.panel.classList.remove("disableTransition"); + if (this.isVertical) { this.panel.style.height = this.panel.offsetHeight; } else { this.panel.style.width = this.panel.offsetWidth; } -// this.application.ninja.settings.setSetting(this.element.id,"value", this.value); + + this.application.localStorage.setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": this.value}); + if(this.redrawStage) { this.application.ninja.stage.resizeCanvases = true; } + NJevent("panelResizedEnd", this) } }, @@ -176,30 +215,5 @@ exports.Resizer = Montage.create(Component, { NJevent("panelResizing", this); } - }, - - _value: { - value: null - }, - - redrawStage: { - value:false - }, - - value: { - get: function() { - /* - if(this.application.ninja.settings) { - var gottenValue = this.application.ninja.settings.getSetting(this.id, "value"); - if (this._value == null && gottenValue !=null) { - this.value = gottenValue; - } - } - */ - return this._value; - }, - set: function(val) { - this._value = val; - } } }); \ No newline at end of file -- cgit v1.2.3