diff options
author | Eric Guzman | 2012-02-15 21:44:53 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-15 21:44:53 -0800 |
commit | af20ca9b11133dd5cefb9275dbe8fb101c3380d0 (patch) | |
tree | 8d49222346efe38fe64c2a88e1d4d60793321837 | |
parent | 98b3083849b71155a8cb37d300b216150db0dcb5 (diff) | |
download | ninja-af20ca9b11133dd5cefb9275dbe8fb101c3380d0.tar.gz |
Presets - Get/set active tab from local storage + other improvements
-rw-r--r-- | js/panels/presets/content.reel/content.js | 73 |
1 files changed, 23 insertions, 50 deletions
diff --git a/js/panels/presets/content.reel/content.js b/js/panels/presets/content.reel/content.js index 8ddb3757..c43c593c 100644 --- a/js/panels/presets/content.reel/content.js +++ b/js/panels/presets/content.reel/content.js | |||
@@ -12,17 +12,19 @@ exports.content = Montage.create(Component, { | |||
12 | value: true | 12 | value: true |
13 | }, | 13 | }, |
14 | contentPanel : { | 14 | contentPanel : { |
15 | value: "presets" // get from local storage | 15 | value: null |
16 | }, | 16 | }, |
17 | templateDidLoad : { | 17 | templateDidLoad : { |
18 | value: function() { | 18 | value: function() { |
19 | console.log('deserialized'); | 19 | var storedTabIndex = window.localStorage.presetsTabIndex; |
20 | if(storedTabIndex) { | ||
21 | this.activeTabIndex = storedTabIndex; | ||
22 | } | ||
20 | } | 23 | } |
21 | }, | 24 | }, |
22 | prepareForDraw : { | 25 | prepareForDraw : { |
23 | value: function() { | 26 | value: function() { |
24 | this.activeTab = this.tabs[this.activeTabIndex]; | 27 | this.activeTab = this.tabs[this.activeTabIndex]; |
25 | |||
26 | this.tabBar.addEventListener('click', this, false); | 28 | this.tabBar.addEventListener('click', this, false); |
27 | } | 29 | } |
28 | }, | 30 | }, |
@@ -48,59 +50,30 @@ exports.content = Montage.create(Component, { | |||
48 | }, | 50 | }, |
49 | set: function(tabObject) { | 51 | set: function(tabObject) { |
50 | this.contentPanel = tabObject.key; | 52 | this.contentPanel = tabObject.key; |
51 | 53 | window.localStorage.presetsTabIndex = this.tabs.indexOf(tabObject); | |
52 | if(this.activeTab) { | 54 | this._tabToDeactivate = this._activeTab; |
53 | this._activeTab.tab.classList.remove('active-tab'); | ||
54 | } | ||
55 | |||
56 | tabObject.tab.classList.add('active-tab'); | ||
57 | this._activeTab = tabObject; | 55 | this._activeTab = tabObject; |
56 | |||
57 | this.needsDraw = this._needsTabSwitch = true; | ||
58 | } | 58 | } |
59 | }, | 59 | }, |
60 | treeList : { | 60 | _tabToDeactivate : { |
61 | value : null | 61 | value: null, |
62 | enumarable: false | ||
62 | }, | 63 | }, |
63 | data2: { | 64 | _needsTabSwitch : { |
64 | value: { | 65 | value: null, |
65 | "meta": "Blah", | 66 | enumerable: false |
66 | "status": "OK", | ||
67 | "text" : "Root", | ||
68 | "data" : { | ||
69 | "date": "1.1.01", | ||
70 | "text": "Root", | ||
71 | "children": [{ | ||
72 | "date": "3.3.01", | ||
73 | "text": "Child 1" | ||
74 | }, | ||
75 | { | ||
76 | "date": "3.3.01", | ||
77 | "text": "Child 2", | ||
78 | "children": [{ | ||
79 | "date": "3.4.01", | ||
80 | "text": "Grand Child 1", | ||
81 | "children": [{ | ||
82 | "date": "4.4.01", | ||
83 | "text": "Great Grand Child 1" | ||
84 | }] | ||
85 | }] | ||
86 | |||
87 | },{ | ||
88 | "date": "5.5.01", | ||
89 | "text": "Child 3" | ||
90 | }] | ||
91 | } | ||
92 | } | ||
93 | }, | 67 | }, |
68 | draw : { | ||
69 | value: function() { | ||
70 | if(this._needsTabSwitch) { | ||
71 | if(this._tabToDeactivate) { | ||
72 | this._tabToDeactivate.tab.classList.remove('active-tab'); | ||
73 | } | ||
94 | 74 | ||
95 | didDraw: { | 75 | this._activeTab.tab.classList.add('active-tab'); |
96 | value : function() { | 76 | } |
97 | console.log('Presets Panel prepare for draw.'); | ||
98 | // this.treeList.items.push({ | ||
99 | // label : "Box Style", | ||
100 | // type : 'leaf' | ||
101 | // }); | ||
102 | } | 77 | } |
103 | } | 78 | } |
104 | |||
105 | |||
106 | }); | 79 | }); |