diff options
Diffstat (limited to 'js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js')
-rw-r--r-- | js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js | 1968 |
1 files changed, 1968 insertions, 0 deletions
diff --git a/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js new file mode 100644 index 00000000..31582153 --- /dev/null +++ b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js | |||
@@ -0,0 +1,1968 @@ | |||
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 | var TreeControl = require("js/components/tree.reel").Tree, | ||
8 | ResizerControl = require("js/panels/Resizer").Resizer, | ||
9 | nj = require("js/lib/NJUtils.js").NJUtils; | ||
10 | |||
11 | exports.ProjectPanelBase = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { | ||
12 | hasTemplate: { | ||
13 | value: true | ||
14 | }, | ||
15 | _hasFocus: { | ||
16 | numerable: false, | ||
17 | value: false | ||
18 | }, | ||
19 | |||
20 | /* The current project that we have in memory */ | ||
21 | _activeProject: { | ||
22 | value: false | ||
23 | }, | ||
24 | activeProject: { | ||
25 | get: function() { | ||
26 | return this._activeProject; | ||
27 | }, | ||
28 | set: function(objNewProject) { | ||
29 | this._activeProject = objNewProject; | ||
30 | } | ||
31 | }, | ||
32 | |||
33 | /* Is the panel initialized? Helps keep us from re-initializing things when a project switches */ | ||
34 | _isPanelInitialized: { | ||
35 | value: false | ||
36 | }, | ||
37 | isPanelInitialized: { | ||
38 | get: function() { | ||
39 | return this._isPanelInitialized; | ||
40 | }, | ||
41 | set: function(boolValue) { | ||
42 | this._isPanelInitialized = boolValue; | ||
43 | } | ||
44 | }, | ||
45 | |||
46 | /* Project models: is there an active project, did the user just swap the project, etc. */ | ||
47 | _swapProject: { | ||
48 | value: false | ||
49 | }, | ||
50 | swapProject: { | ||
51 | get: function() { | ||
52 | return this._swapProject; | ||
53 | }, | ||
54 | set: function(boolValue) { | ||
55 | this._swapProject = boolValue; | ||
56 | } | ||
57 | }, | ||
58 | _updateTree: { | ||
59 | value: false | ||
60 | }, | ||
61 | updateTree: { | ||
62 | get: function() { | ||
63 | return this._updateTree; | ||
64 | }, | ||
65 | set: function(boolValue) { | ||
66 | this._updateTree = boolValue; | ||
67 | } | ||
68 | }, | ||
69 | _updateAssets: { | ||
70 | value: false | ||
71 | }, | ||
72 | _updateAssets : { | ||
73 | get: function() { | ||
74 | return this._updateAssets; | ||
75 | }, | ||
76 | set: function(boolValue) { | ||
77 | this._updateAssets = boolValue; | ||
78 | } | ||
79 | }, | ||
80 | _hasActiveProject: { | ||
81 | value: false | ||
82 | }, | ||
83 | hasActiveProject: { | ||
84 | get: function() { | ||
85 | return this._hasActiveProject; | ||
86 | }, | ||
87 | set: function(boolValue) { | ||
88 | if (this.hasActiveProject !== boolValue) { | ||
89 | this._hasActiveProject = boolValue; | ||
90 | this.needsDraw = true; | ||
91 | this.swapProject = true; | ||
92 | this.loadPanelState(); | ||
93 | } | ||
94 | } | ||
95 | }, | ||
96 | setActiveProject: { | ||
97 | value: function(myVal) { | ||
98 | this.hasActiveProject = myVal; | ||
99 | } | ||
100 | }, | ||
101 | |||
102 | /* Focus monitor: needed to modify keyboard navigation through panels. */ | ||
103 | _hasFocus: { | ||
104 | value: false | ||
105 | }, | ||
106 | hasFocus: { | ||
107 | get: function() { | ||
108 | return this._hasFocus; | ||
109 | }, | ||
110 | set: function(newVal) { | ||
111 | if (this._hasFocus !== newVal) { | ||
112 | this._hasFocus = newVal; | ||
113 | } | ||
114 | } | ||
115 | }, | ||
116 | |||
117 | /* Active column models: Used to store the state of the columns as a resize is happening */ | ||
118 | _activeColumn: { | ||
119 | enumerable: false, | ||
120 | value: false | ||
121 | }, | ||
122 | activeColumn: { | ||
123 | get: function() { | ||
124 | return this._activeColumn; | ||
125 | }, | ||
126 | set: function(intActiveColumn) { | ||
127 | this._activeColumn = intActiveColumn; | ||
128 | } | ||
129 | }, | ||
130 | _activeColumnWidths: { | ||
131 | enumerable: false, | ||
132 | value: [0,0,0] | ||
133 | }, | ||
134 | activeColumnWidths: { | ||
135 | get: function() { | ||
136 | return this._activeColumnWidths; | ||
137 | }, | ||
138 | set: function(activeColumnWidths) { | ||
139 | for (var i = 0; i < activeColumnWidths.length; i++) { | ||
140 | if (this._activeColumnWidths[i] !== activeColumnWidths[i]) { | ||
141 | this._activeColumnWidths[i] = activeColumnWidths[i]; | ||
142 | this.activeColumn = i; | ||
143 | this.needsDraw = true; | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | }, | ||
148 | |||
149 | /* resizeColumn: Method to resize a column */ | ||
150 | resizeColumn: { | ||
151 | value: function(strSelectorBase) { | ||
152 | // Resize column with index this.activeColumn in view specified by strSelectorBase. | ||
153 | var intAdjust = 0, | ||
154 | intTotalWidth = 0, | ||
155 | arrToChange = [], | ||
156 | arrToChangeLength = 0, | ||
157 | arrHeaders = document.querySelectorAll(strSelectorBase + " .pp-header"); | ||
158 | arrHeadersLength = arrHeaders.length; | ||
159 | containerList = document.querySelectorAll(strSelectorBase + " .pp-scroll-linked"); | ||
160 | containerListLength = containerList.length, | ||
161 | intNewWidth = 0, | ||
162 | strNewWidth = "", | ||
163 | boolProjectView = true, | ||
164 | arrStoredWidths = this.panelState.projectColumnWidths; | ||
165 | |||
166 | if (strSelectorBase.indexOf("assets") > -1) { | ||
167 | boolProjectView = false; | ||
168 | arrStoredWidths = this.panelState.assetColumnWidths; | ||
169 | } | ||
170 | |||
171 | |||
172 | if (this.activeColumn === 0) { | ||
173 | strSelector = strSelectorBase + " .pp-col-files"; | ||
174 | intAdjust = 17; | ||
175 | } else if (this.activeColumn === 1) { | ||
176 | strSelector = strSelectorBase + " .pp-col-date"; | ||
177 | intAdjust = 6; | ||
178 | } else if (this.activeColumn === 2) { | ||
179 | strSelector = strSelectorBase + " .pp-col-size"; | ||
180 | intAdjust = 6; | ||
181 | } else if (this.activeColumn === 3) { | ||
182 | strSelector = strSelectorBase + " .pp-col-type"; | ||
183 | intAdjust = 10; | ||
184 | } else { | ||
185 | return; | ||
186 | } | ||
187 | if ((this.activeColumn === 3) && boolProjectView) { | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | // Adjust intAdjust: for the asset view it needs to be 0. | ||
192 | if (strSelectorBase.indexOf("assets") >0) { | ||
193 | intAdjust = 0; | ||
194 | } | ||
195 | |||
196 | // Get the total width of the headers and set the container to that width. | ||
197 | for (i = 0; i < arrHeadersLength; i++) { | ||
198 | intTotalWidth = intTotalWidth + parseInt(arrHeaders[i].offsetWidth); | ||
199 | } | ||
200 | if (intTotalWidth === 0) { | ||
201 | for (i = 0; i < arrStoredWidths.length; i++) { | ||
202 | intTotalWidth = intTotalWidth + arrStoredWidths[i]; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | for (i = 0; i < containerListLength; i++) { | ||
207 | containerList[i].style.minWidth = (intTotalWidth+12) + "px"; | ||
208 | } | ||
209 | intNewWidth = arrHeaders[this.activeColumn].offsetWidt |