aboutsummaryrefslogtreecommitdiff
path: root/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-03-01 18:13:18 -0800
committerJose Antonio Marquez2012-03-01 18:13:18 -0800
commit66bc1f46938afc696b11878ebbb97d1fd361386e (patch)
treea4e8d066bf80a43f42ce971a3ca05ab88f457d16 /js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
parent80ac930684255dd24cecae70b488285a6058488e (diff)
parent61dd921d5bb06ab47ee84506dbaaeaf4895ebf42 (diff)
downloadninja-66bc1f46938afc696b11878ebbb97d1fd361386e.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js')
-rwxr-xr-xjs/panels/PanelContainer/PanelContainer.reel/PanelContainer.js432
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 003724bb..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/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3No 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/*
8Panel Container - A container for other panels 8Panel Container - A container for other panels
9*/ 9*/
10var Montage = require("montage/core/core").Montage; 10var Montage = require("montage/core/core").Montage;
11var Component = require("montage/ui/component").Component; 11var Component = require("montage/ui/component").Component;
12var PropertiesPanel = require("js/panels/Properties/properties-panel").PropertiesPanel; 12
13var ColorPanel = require("js/panels/Color/ColorPanel").ColorPanel;
14var CSSPanel = require("js/panels/CSSPanel/CSSPanel").CSSPanel;
15var ComponentsPanel = require("js/panels/Components/ComponentsPanel").ComponentsPanel;
16var ProjectPanel = require("js/panels/Project/ProjectPanel").ProjectPanel;
17var MaterialsPanel = require("js/panels/Materials/MaterialsPanel").MaterialsPanel;
18var PresetsPanel = require("js/panels/presets/presets-panel").PresetsPanel;
19
20exports.PanelContainer = Montage.create(Component, { 13exports.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: ['ColorPanel', 'PropertiesPanel','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;
147