diff options
author | Ananya Sen | 2012-03-06 17:15:46 -0800 |
---|---|---|
committer | Ananya Sen | 2012-03-06 17:15:46 -0800 |
commit | 5afc582a1ae537f1e30113394780f1c8eec58f89 (patch) | |
tree | eb1583408136c207631175405e410148da529652 /js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js | |
parent | 96e4a494d559da6b4041c1c14c26b53221276e4b (diff) | |
parent | cef07085443b7c31e878daaad083b7408c57e104 (diff) | |
download | ninja-5afc582a1ae537f1e30113394780f1c8eec58f89.tar.gz |
Merge branch 'refs/heads/FileIO-jose' into FileIO-ananya
Conflicts:
js/controllers/selection-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
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 | ||