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/Splitter.js') 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 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 --- js/panels/Splitter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/panels/Splitter.js') 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 { -- cgit v1.2.3