diff options
author | Pushkar Joshi | 2012-03-02 12:24:33 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-03-02 12:24:33 -0800 |
commit | 4419209a1fd850ab468209b562b66b0242b42a9c (patch) | |
tree | bd7ca04f963f5a3aeb4b3c06db6f187903307d45 /js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | |
parent | 1b68bb87c458877cb850a96d8a093d6064bc41dc (diff) | |
parent | ff0a956f33df034e9a009cfcb8999e469456a4b5 (diff) | |
download | ninja-4419209a1fd850ab468209b562b66b0242b42a9c.tar.gz |
Merge branch 'master' into brushtool
Diffstat (limited to 'js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js')
-rwxr-xr-x | js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | 432 |
1 files changed, 111 insertions, 321 deletions
diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js index 3cbd4369..3a141b05 100755 --- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | |||
@@ -3,388 +3,178 @@ This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | |||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | Panel Container - A container for other panels | 8 | Panel Container - A container for other panels |
9 | */ | 9 | */ |
10 | var Montage = require("montage/core/core").Montage; | 10 | var Montage = require("montage/core/core").Montage; |
11 | var Component = require("montage/ui/component").Component; | 11 | var Component = require("montage/ui/component").Component; |
12 | var PropertiesPanel = require("js/panels/Properties/properties-panel").PropertiesPanel; | 12 | |
13 | var ColorPanel = require("js/panels/Color/ColorPanel").ColorPanel; | ||
14 | var CSSPanel = require("js/panels/CSSPanel/CSSPanel").CSSPanel; | ||
15 | var ComponentsPanel = require("js/panels/Components/ComponentsPanel").ComponentsPanel; | ||
16 | var ProjectPanel = require("js/panels/Project/ProjectPanel").ProjectPanel; | ||
17 | var MaterialsPanel = require("js/panels/Materials/MaterialsPanel").MaterialsPanel; | ||
18 | var PresetsPanel = require("js/panels/presets/presets-panel").PresetsPanel; | ||
19 | |||
20 | exports.PanelContainer = Montage.create(Component, { | 13 | exports.PanelContainer = Montage.create(Component, { |
21 | lastOffset: { | ||
22 | value:null | ||
23 | }, | ||
24 | _collapsedHeight: { | ||
25 | value: 26 | ||
26 | }, | ||
27 | _isFirstAdjustableNonCollapsed: { | ||
28 | value:true | ||
29 | }, | ||
30 | _spaceAvailable: { | ||
31 | value:null | ||
32 | }, | ||
33 | _panelSelected : { | ||
34 | value: null | ||
35 | }, | ||
36 | _isFirstDraw: { | ||
37 | value: false | ||
38 | }, | ||
39 | _panels: { | ||
40 | value: [] | ||
41 | }, | ||
42 | 14 | ||
43 | skipPanelIndex: { | 15 | panelData: { |
44 | value: null | 16 | value: null |
45 | }, | 17 | }, |
46 | 18 | ||
47 | initPanelOrder: { | 19 | panels: { |
48 | value: ['PropertiesPanel','ColorPanel','ComponentsPanel','ProjectPanel','CSSPanel','MaterialsPanel','PresetsPanel'] | ||
49 | }, | ||
50 | |||
51 | panelOrder: { | ||
52 | value: [] | 20 | value: [] |
53 | }, | 21 | }, |
54 | 22 | ||
55 | deserializedFromTemplate : { | 23 | panelController: { |
56 | value: function() { | 24 | value: null |
57 | this.eventManager.addEventListener( "appLoaded", this, false); | 25 | }, |
58 | 26 | ||
59 | } | 27 | currentPanelState: { |
28 | value: {} | ||
60 | }, | 29 | }, |
61 | 30 | ||
62 | handleAppLoaded: { | 31 | templateDidLoad: { |
63 | value: function() { | 32 | value: function() { |
64 | //Panels Loading | 33 | var pLen, storedData; |
65 | this.lastOffset = this.element.offsetHeight; | ||
66 | |||
67 | /* Old Settings | ||
68 | if( this.application.ninja.settings.getSetting(this.element.id, "panelOrder") != null) { | ||
69 | this.initPanelOrder = this.application.ninja.settings.getSetting(this.element.id, "panelOrder") | ||
70 | } | ||
71 | */ | ||
72 | 34 | ||
73 | // if Panels already loaded no need to load again. | 35 | // Loop through the panels to add to the repetition and get the saved state |
74 | for(var i = 0; i < this.initPanelOrder.length; i++) { | 36 | pLen = this.panelData.panels.length; |
75 | this.addPanel(eval(this.initPanelOrder[i])); | ||
76 | this.panelOrder.push(this.initPanelOrder[i]); | ||
77 | 37 | ||
78 | // this.application.ninja.settings.setSetting(this.element.id, "panelOrder", this.panelOrder); | 38 | // Get the saved panel state |
79 | } | 39 | storedData = this.application.localStorage.getItem("panels"); |
80 | |||
81 | var hideSplitter = true; | ||
82 | 40 | ||
83 | var that = this; | 41 | for(var i = 0; i < pLen; i++) { |
84 | this._panels.forEach(function(obj) { | ||
85 | 42 | ||
86 | var panelMenuName = obj.panelName.substring(0, obj.panelName.indexOf('/') !== -1 ? obj.panelName.indexOf('/'): obj.panelName.length) + "Panel"; | 43 | var p = this.panelData.panels[i]; |
87 | 44 | ||
88 | that.application.ninja.appModel[panelMenuName] = obj.visible; | 45 | this.currentPanelState[p.name] = {}; |
46 | this.currentPanelState.version = "1.0"; | ||
89 | 47 | ||
90 | if (obj.visible) { | 48 | if(storedData && storedData[p.name]) { |
91 | hideSplitter = false; | 49 | p.collapsed = storedData[p.name].collapsed; |
92 | } | 50 | } |
93 | }); | ||
94 | 51 | ||
95 | if (hideSplitter) { | 52 | this.currentPanelState[p.name].collapsed = p.collapsed; |
96 | this.panelSplitter.toggle(); | ||
97 | this.panelSplitter.disabled = true; | ||
98 | } | ||
99 | 53 | ||
100 | // this.needsDraw = true; | 54 | this.panels.push(p); |
55 | } | ||
101 | 56 | ||
102 | this.addEventListener("change@appModel.PropertiesPanel", this, false); | 57 | this.application.localStorage.setItem("panels", this.currentPanelState); |
103 | this.addEventListener("change@appModel.ProjectPanel", this, false); | ||
104 | this.addEventListener("change@appModel.ColorPanel", this, false); | ||
105 | this.addEventListener("change@appModel.ComponentsPanel", this, false); | ||
106 | this.addEventListener("change@appModel.CSSPanel", this, false); | ||
107 | this.addEventListener("change@appModel.MaterialsPanel", this, false); | ||
108 | this.addEventListener("change@appModel.PresetsPanel", this, false); | ||
109 | } | 58 | } |
110 | }, | 59 | }, |
111 | 60 | ||
112 | handleEvent: { | 61 | prepareForDraw: { |
113 | value: function(e) { | 62 | value: function() { |
114 | this.togglePanel(e.propertyName); | 63 | window.addEventListener("resize", this, false); |
115 | } | 64 | } |
116 | }, | 65 | }, |
117 | 66 | ||
118 | addPanel: { | 67 | handlePanelResizing: { |
119 | value: function(panel) { | 68 | value: function(e) { |
120 | if (panel.init) { | 69 | this._setPanelsSizes(e.target); |
121 | panel.init(); | ||
122 | } | ||
123 | this._panels.push(panel); | ||
124 | if (this.panelSplitter.disabled) { | ||
125 | this.panelSplitter.disabled = false; | ||
126 | this.panelSplitter.toggle(); | ||
127 | } | ||
128 | } | 70 | } |
129 | }, | 71 | }, |
130 | handlePanelCollapsed: { | 72 | |
73 | handleResize: { | ||
131 | value: function(e) { | 74 | value: function(e) { |
132 | 75 | this._setPanelsSizes(null); | |
133 | for(var i=0; i < this._panels.length; i++) { | ||
134 | if (e._event.detail.panelBase._uuid == this._panels[i]._uuid) { | ||
135 | this.skipPanelIndex = i; | ||
136 | this.handlePanelResized(i, true); | ||
137 | } | 76 | } |
138 | } | ||
139 | } | ||
140 | }, | 77 | }, |
141 | 78 | ||
142 | handlePanelResizedStart : { | 79 | handleDropped: { |
143 | value: function(e) { | 80 | value: function(e) { |
144 | for (var i = 0; i < this._panels.length; i++) { | 81 | var draggedIndex, droppedIndex = 0; |
145 | if ( e._event.detail.element.parentNode.uuid == this.repeater.childComponents[i].element.uuid) { | 82 | for(var i = 0; i< this.repeater.childComponents.length; i++ ) { |
146 | this.handlePanelResized(i); | 83 | if (this.repeater.childComponents[i] === e._event.draggedComponent) { |
84 | draggedIndex = i; | ||