From 8974ecd564563a991ff96f9cb6d47da172174242 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 22 Feb 2012 00:49:47 -0800 Subject: local storage integration and versioning - Fixed the splitters Signed-off-by: Valerio Virgillito --- js/panels/Splitter.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'js/panels') diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js index 9f5b4de7..cb05104d 100755 --- a/js/panels/Splitter.js +++ b/js/panels/Splitter.js @@ -9,6 +9,10 @@ var Component = require("montage/ui/component").Component; exports.Splitter = Montage.create(Component, { + version: { + value: "1.0" + }, + hasTemplate: { value: false }, @@ -49,19 +53,23 @@ exports.Splitter = Montage.create(Component, { get: function() { return this._collapsed; }, - set: function(value) - { + set: function(value) { this._collapsed = value; - this.application.ninja.settings.setSetting(this.element.id, "collapsed", this.collapsed); + + this.application.localStorage._setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": value}); } }, prepareForDraw: { value: function() { - //Get Setting from SettingManager - this.application.ninja.settings.getSetting(this.element.id, "collapsed"); - lapsed = false; - if (lapsed != null) this._collapsed = lapsed; + //Get splitter initial value from SettingManager + var storedData = this.application.localStorage._getItem(this.element.getAttribute("data-montage-id")); + if(storedData && this.element.getAttribute("data-montage-id") !== null) { + this._collapsed = storedData.value; + } else { + this._collapsed = false; + } + this.element.addEventListener("click", this, false); } }, -- cgit v1.2.3 From 2b672f6508a849b8023b0bc114ad15e9ddca5adc Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 24 Feb 2012 13:27:04 -0800 Subject: prefixing the local storage and using the new local-storage object. Signed-off-by: Valerio Virgillito --- js/panels/presets/content.reel/content.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/panels') diff --git a/js/panels/presets/content.reel/content.js b/js/panels/presets/content.reel/content.js index c43c593c..1ede7246 100644 --- a/js/panels/presets/content.reel/content.js +++ b/js/panels/presets/content.reel/content.js @@ -16,7 +16,7 @@ exports.content = Montage.create(Component, { }, templateDidLoad : { value: function() { - var storedTabIndex = window.localStorage.presetsTabIndex; + var storedTabIndex = this.application.localStorage.getItem("presetsTabIndex"); if(storedTabIndex) { this.activeTabIndex = storedTabIndex; } @@ -50,7 +50,7 @@ exports.content = Montage.create(Component, { }, set: function(tabObject) { this.contentPanel = tabObject.key; - window.localStorage.presetsTabIndex = this.tabs.indexOf(tabObject); + this.application.localStorage.setItem("presetsTabIndex", this.tabs.indexOf(tabObject)); this._tabToDeactivate = this._activeTab; this._activeTab = tabObject; -- cgit v1.2.3 From f97080989ee988c1e613915c2d246dc17b104b3b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 24 Feb 2012 13:27:33 -0800 Subject: clearing the old local setting and using the new version/prefix local settings. Signed-off-by: Valerio Virgillito --- .../CSSPanel/CSSPanelBase.reel/CSSPanelBase.html | 2 +- js/panels/Panel.reel/Panel.html | 9 ++++++++- js/panels/Panel.reel/Panel.js | 4 +++- js/panels/PanelBase.js | 23 +++++++++++++++++----- .../PanelContainer.reel/PanelContainer.js | 8 +++++--- js/panels/Resizer.js | 14 +++++++++---- js/panels/Splitter.js | 4 ++-- .../Timeline/TimelinePanel.reel/TimelinePanel.html | 2 +- 8 files changed, 48 insertions(+), 18 deletions(-) (limited to 'js/panels') diff --git a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.html b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.html index db630934..98b2b61d 100755 --- a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.html +++ b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.html @@ -53,7 +53,7 @@ -
+

diff --git a/js/panels/Panel.reel/Panel.html b/js/panels/Panel.reel/Panel.html index dc76d871..46c8fb91 100755 --- a/js/panels/Panel.reel/Panel.html +++ b/js/panels/Panel.reel/Panel.html @@ -15,6 +15,13 @@ "element": {"#": "resizeBar"}, "panel": {"#": "panel"}, "isVertical": true + }, + "bindings": { + "ownerId": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "panelBase.panelName", + "oneway": true + } } }, @@ -55,7 +62,7 @@ -
+
diff --git a/js/panels/Panel.reel/Panel.js b/js/panels/Panel.reel/Panel.js index efa287c5..c8dd0456 100755 --- a/js/panels/Panel.reel/Panel.js +++ b/js/panels/Panel.reel/Panel.js @@ -188,6 +188,8 @@ exports.Panel = Montage.create(Component, { //Resized Event if(typeof this.resizer.value == "number") this.panelBase.contentHeight = this.resizer.value; this.resizer.element.addEventListener("mouseup",this.resized.bind(this),false); + + this.panelContent.content = this.panelBase.content; } } }, @@ -226,7 +228,7 @@ exports.Panel = Montage.create(Component, { else pContentDiv.style.overflow = "hidden"; this.element.getElementsByClassName("panelTitle")[0].innerHTML = this.panelBase.panelName; //pContentDiv.appendChild(this.panelBase.content); - this.panelContent.content = this.panelBase.content; + //this.panelContent.content = this.panelBase.content; } } diff --git a/js/panels/PanelBase.js b/js/panels/PanelBase.js index b7b6945c..03dcd0ee 100755 --- a/js/panels/PanelBase.js +++ b/js/panels/PanelBase.js @@ -32,11 +32,14 @@ exports.PanelBase = Montage.create(Component, { contentHeight: { get: function() { if(this._contentHeight == null) { + // Old settings + /* 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; }, @@ -44,50 +47,60 @@ exports.PanelBase = Montage.create(Component, { 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) { + /* 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) { + /* 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: { get: function() { if(this._visible === null) { + /* 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; + } return this._visible; @@ -95,7 +108,7 @@ exports.PanelBase = Montage.create(Component, { set: function(value) { this._visible = value; - this.application.ninja.settings.setSetting(this.panelName, "visible", value); + //this.application.ninja.settings.setSetting(this.panelName, "visible", value); } } diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js index b8223471..bdd112c6 100755 --- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js @@ -63,14 +63,16 @@ exports.PanelContainer = Montage.create(Component, { value: function() { //Panels Loading this.lastOffset = this.element.offsetHeight; + /* 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; @@ -221,7 +223,7 @@ exports.PanelContainer = Montage.create(Component, { } minHeights -= this._panels[lastPanel].minHeight - this._collapsedHeight; this._panels[lastPanel].collapsed = true; - this.repeater.childComponents[lastPanel].needsDraw = true; + //this.repeater.childComponents[lastPanel].needsDraw = true; } @@ -329,7 +331,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); + //this.application.ninja.settings.setSetting(this.element.id, "panelOrder", this.panelOrder); } } }, diff --git a/js/panels/Resizer.js b/js/panels/Resizer.js index 3afe5d5b..e9bd4fc0 100755 --- a/js/panels/Resizer.js +++ b/js/panels/Resizer.js @@ -12,6 +12,10 @@ exports.Resizer = Montage.create(Component, { hasTemplate: { value: false }, + + ownerId: { + value: "" + }, _isInversed: { value: false @@ -74,7 +78,6 @@ exports.Resizer = Montage.create(Component, { e.preventDefault(); this.panel.addEventListener("webkitTransitionEnd", this, true); if (this.isVertical) { - //console.log("y: " + e.y + " startPosition: " + this._startPosition + " initDimension: " + this._initDimension); this._startPosition = e.y; this._initDimension = this.panel.offsetHeight; } @@ -98,7 +101,7 @@ exports.Resizer = Montage.create(Component, { } else { this.panel.style.width = ""; } - this.application.ninja.settings.setSetting(this.element.id,"value", ""); +// this.application.ninja.settings.setSetting(this.element.id,"value", ""); } }, @@ -113,6 +116,8 @@ 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.value != null) { if (this.isVertical) { this.panel.style.height = this.value + "px"; @@ -142,7 +147,7 @@ exports.Resizer = Montage.create(Component, { } else { this.panel.style.width = this.panel.offsetWidth; } - this.application.ninja.settings.setSetting(this.element.id,"value", this.value); +// this.application.ninja.settings.setSetting(this.element.id,"value", this.value); if(this.redrawStage) { this.application.ninja.stage.resizeCanvases = true; } @@ -154,7 +159,6 @@ exports.Resizer = Montage.create(Component, { value: function(e) { if(this.isVertical) { this.value = this._isInversed ? this._initDimension + (this._startPosition - e.y) : this._initDimension + (e.y - this._startPosition); - //console.log("y: " + e.y + " startPosition: " + this._startPosition + " initDimension: " + this._initDimension + " finalPosition: " + pos); this.panel.style.height = this.value + "px"; } else { @@ -184,12 +188,14 @@ exports.Resizer = Montage.create(Component, { 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) { diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js index cb05104d..3215e928 100755 --- a/js/panels/Splitter.js +++ b/js/panels/Splitter.js @@ -56,14 +56,14 @@ exports.Splitter = Montage.create(Component, { set: function(value) { this._collapsed = value; - this.application.localStorage._setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": value}); + this.application.localStorage.setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": value}); } }, prepareForDraw: { value: function() { //Get splitter initial value from SettingManager - var storedData = this.application.localStorage._getItem(this.element.getAttribute("data-montage-id")); + var storedData = this.application.localStorage.getItem(this.element.getAttribute("data-montage-id")); if(storedData && this.element.getAttribute("data-montage-id") !== null) { this._collapsed = storedData.value; } else { diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.html b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.html index 0c302436..0fd5b05d 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.html +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.html @@ -264,7 +264,7 @@ -
+
-- cgit v1.2.3 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/panels/Panel.reel/Panel.html | 3 +- js/panels/PanelBase.js | 40 +++++------- .../PanelContainer.reel/PanelContainer.js | 8 ++- js/panels/Resizer.js | 76 +++++++++++++--------- 4 files changed, 70 insertions(+), 57 deletions(-) (limited to 'js/panels') 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