diff options
author | Nivesh Rajbhandari | 2012-03-06 15:44:04 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-06 15:44:04 -0800 |
commit | b047a9414cc07f2cb20dbfd7240ca9b0bfdc231d (patch) | |
tree | ec1e9d373636569e09cdf669f063d4d2a1e441f4 /js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | |
parent | 792793cd3991032b4840ade67f98ae8eae2d30a0 (diff) | |
parent | 4f498b43264327f5886e0370bd3536453d47570a (diff) | |
download | ninja-b047a9414cc07f2cb20dbfd7240ca9b0bfdc231d.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js')
-rwxr-xr-x | js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js deleted file mode 100755 index 3a141b05..00000000 --- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js +++ /dev/null | |||
@@ -1,180 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | 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/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /* | ||
8 | Panel Container - A container for other panels | ||
9 | */ | ||
10 | var Montage = require("montage/core/core").Montage; | ||
11 | var Component = require("montage/ui/component").Component; | ||
12 | |||
13 | exports.PanelContainer = Montage.create(Component, { | ||
14 | |||
15 | panelData: { | ||
16 | value: null | ||
17 | }, | ||
18 | |||
19 | panels: { | ||
20 | value: [] | ||
21 | }, | ||
22 | |||
23 | panelController: { | ||
24 | value: null | ||
25 | }, | ||
26 | |||
27 | currentPanelState: { | ||
28 | value: {} | ||
29 | }, | ||
30 | |||
31 | templateDidLoad: { | ||
32 | value: function() { | ||
33 | var pLen, storedData; | ||
34 | |||
35 | // Loop through the panels to add to the repetition and get the saved state | ||
36 | pLen = this.panelData.panels.length; | ||
37 | |||
38 | // Get the saved panel state | ||
39 | storedData = this.application.localStorage.getItem("panels"); | ||
40 | |||
41 | for(var i = 0; i < pLen; i++) { | ||
42 | |||
43 | var p = this.panelData.panels[i]; | ||
44 | |||
45 | this.currentPanelState[p.name] = {}; | ||
46 | this.currentPanelState.version = "1.0"; | ||
47 | |||
48 | if(storedData && storedData[p.name]) { | ||
49 | p.collapsed = storedData[p.name].collapsed; | ||
50 | } | ||
51 | |||
52 | this.currentPanelState[p.name].collapsed = p.collapsed; | ||
53 | |||
54 | this.panels.push(p); | ||
55 | } | ||
56 | |||
57 | this.application.localStorage.setItem("panels", this.currentPanelState); | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | prepareForDraw: { | ||
62 | value: function() { | ||
63 | window.addEventListener("resize", this, false); | ||
64 | } | ||
65 | }, | ||
66 | |||
67 | handlePanelResizing: { | ||
68 | value: function(e) { | ||
69 | this._setPanelsSizes(e.target); | ||
70 | } | ||
71 | }, | ||
72 | |||
73 | handleResize: { | ||
74 | value: function(e) { | ||
75 | this._setPanelsSizes(null); | ||
76 | } | ||
77 | }, | ||
78 | |||
79 | handleDropped: { | ||
80 | value: function(e) { | ||
81 | var draggedIndex, droppedIndex = 0; | ||
82 | for(var i = 0; i< this.repeater.childComponents.length; i++ ) { | ||
83 | if (this.repeater.childComponents[i] === e._event.draggedComponent) { | ||
84 | draggedIndex = i; | ||
85 | } | ||
86 | |||
87 | if (this.repeater.childComponents[i] === e._event.droppedComponent) { | ||
88 | droppedIndex = i; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | var panelRemoved = this.panelController.content.splice(draggedIndex,1); | ||
93 | this.panelController.content.splice(droppedIndex,0, panelRemoved[0]); | ||
94 | //console.log(draggedIndex, droppedIndex); | ||
95 | this._setPanelsSizes(null); | ||
96 | } | ||
97 | }, | ||
98 | |||
99 | _setPanelsSizes: { | ||
100 | value: function(panelActivated) { | ||
101 | var setLocked = true; | ||
102 | this.repeater.childComponents.forEach(function(obj) { | ||
103 | if (obj === panelActivated || panelActivated === null) { | ||
104 | setLocked = false; | ||
105 | } | ||
106 | |||
107 | obj.locked = setLocked; | ||
108 | obj.needsDraw = true; | ||
109 | }); | ||
110 | } | ||
111 | }, | ||
112 | |||
113 | _redrawPanels: { | ||
114 | value: function(panelActivated, unlockPanels) { | ||
115 | var maxHeight = this.element.offsetHeight; | ||
116 | var setLocked = true; | ||
117 | if(unlockPanels === true) { | ||
118 | setLocked = false; | ||
119 | } | ||
120 | |||
121 | var childrensMinHeights = ((this.repeater.childComponents.length - 1) * 26) + panelActivated.minHeight; | ||
122 | |||
123 | this.repeater.childComponents.forEach(function(obj) { | ||
124 | if(obj === panelActivated) { | ||
125 | setLocked = false; | ||
126 | } else if(obj.collapsed) { | ||
127 | //Collapsed Ignore the rest of the code | ||
128 | } else { | ||
129 | if (setLocked) { | ||
130 | if((maxHeight - childrensMinHeights) - obj.height > 0 ) { | ||
131 | childrensMinHeights += obj.height - 26; | ||
132 | } else { | ||
133 | this.currentPanelState[obj.name].collapsed = obj.collapsed = true; | ||
134 | this.application.localStorage.setItem("panels", this.currentPanelState); | ||
135 | } | ||
136 | } else { | ||
137 | if ((maxHeight - childrensMinHeights) - obj.minHeight > 0 ) { | ||
138 | childrensMinHeights += obj.minHeight - 26; | ||
139 | } else { | ||
140 | this.currentPanelState[obj.name].collapsed = obj.collapsed = true; | ||
141 | this.application.localStorage.setItem("panels", this.currentPanelState); | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | obj.locked = setLocked; | ||
146 | }, this); | ||
147 | } | ||
148 | }, | ||
149 | |||
150 | handleAction: { | ||
151 | value: function(e) { | ||
152 | var unlockPanels = true; | ||
153 | var afterPanel = false; | ||
154 | var panelName = e.target.parentComponent.name; | ||
155 | switch(e.target.identifier) { | ||
156 | case "btnCollapse": | ||
157 | this.currentPanelState[e.target.parentComponent.name].collapsed = e.target.parentComponent.collapsed; | ||
158 | this.application.localStorage.setItem("panels", this.currentPanelState); | ||
159 | this._setPanelsSizes(e.target.parentComponent); | ||
160 | this._redrawPanels(e.target.parentComponent, unlockPanels); | ||
161 | break; | ||
162 | case "btnClose": | ||
163 | this.panelController.content.forEach(function(obj) { | ||
164 | if(afterPanel) { | ||
165 | if(obj.flexible) { | ||
166 | unlockPanels = false; | ||
167 | } | ||
168 | } | ||
169 | if (obj.name === panelName) { | ||
170 | afterPanel = true; | ||
171 | this.panelController.removeObjects(obj); | ||
172 | } | ||
173 | }); | ||
174 | this._redrawPanels(e.target.parentComponent, unlockPanels); | ||
175 | break; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | |||
180 | }); \ No newline at end of file | ||