diff options
author | Jose Antonio Marquez | 2012-03-09 13:36:41 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-09 13:36:41 -0800 |
commit | 9a03f869ff4520431da3ac8c64b748b5fbb60339 (patch) | |
tree | dad948f012cbc7d65e0dccde273667a389ff1c6d /js/panels/Panel.reel/Panel.js | |
parent | b0b4a1ee6792d98f06cbd8ecf5291e66db8a4eef (diff) | |
parent | b4eb2f6cc1208fe5c18aa1f02a85adda25075d81 (diff) | |
download | ninja-9a03f869ff4520431da3ac8c64b748b5fbb60339.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Color
Diffstat (limited to 'js/panels/Panel.reel/Panel.js')
-rwxr-xr-x | js/panels/Panel.reel/Panel.js | 283 |
1 files changed, 127 insertions, 156 deletions
diff --git a/js/panels/Panel.reel/Panel.js b/js/panels/Panel.reel/Panel.js index c8dd0456..33f9b3a7 100755 --- a/js/panels/Panel.reel/Panel.js +++ b/js/panels/Panel.reel/Panel.js | |||
@@ -9,227 +9,198 @@ var Component = require("montage/ui/component").Component; | |||
9 | 9 | ||
10 | exports.Panel = Montage.create(Component, { | 10 | exports.Panel = Montage.create(Component, { |
11 | 11 | ||
12 | 12 | name: { | |
13 | reelDidLoad: { | 13 | value: "Panel" |
14 | value: function() { | ||
15 | } | ||
16 | }, | 14 | }, |
17 | 15 | ||
18 | collapsedHeight: { | 16 | _collapsed: { |
19 | value:26 | 17 | value: false |
20 | }, | 18 | }, |
21 | 19 | ||
22 | _isFirstDraw: { | 20 | _height: { |
23 | value:false | 21 | value: 200 |
24 | }, | 22 | }, |
25 | 23 | ||
26 | _panelBase: { | 24 | minHeight: { |
27 | value: null | 25 | value: 200 |
28 | }, | 26 | }, |
29 | 27 | ||
30 | panelBase: { | 28 | maxHeight: { |
31 | get: function() | ||
32 | { | ||
33 | return this._panelBase; | ||
34 | }, | ||
35 | set: function(value) | ||
36 | { | ||
37 | this._panelBase = value; | ||
38 | this.needsDraw = true; | ||
39 | } | ||
40 | }, | ||
41 | |||
42 | _panelContent: { | ||
43 | value: null | 29 | value: null |
44 | }, | 30 | }, |
45 | 31 | ||
46 | panelContent: { | 32 | flexible: { |
47 | get: function() | 33 | value: true |
48 | { | ||
49 | return this._panelContent; | ||
50 | }, | ||
51 | set: function(value) | ||
52 | { | ||
53 | if (this._panelContent === value) { | ||
54 | return; | ||
55 | } | ||
56 | this._panelContent = value; | ||
57 | this.needsDraw = true; | ||
58 | } | ||
59 | }, | 34 | }, |
60 | 35 | ||
61 | collapseToggle: { | 36 | _locked: { |
62 | value: function() { | 37 | value: false |
63 | if (this.panelBase.forcedCollapse) { | 38 | }, |
64 | this.panelBase.forcedCollapse = false; | ||
65 | this.panelBase.collapsed = false; | ||
66 | this.needsDraw = true; | ||
67 | 39 | ||
68 | } else { | 40 | isResizing: { |
69 | this.panelBase.collapsed = !this.panelBase.collapsed; | 41 | value: false |
70 | this.needsDraw = true; | 42 | }, |
71 | } | ||
72 | NJevent("panelCollapsed", this); | ||
73 | } | ||
74 | }, | ||
75 | 43 | ||
76 | closePanel: { | 44 | _resizedHeight: { |
77 | value: function() { | 45 | value: 0 |
78 | NJevent("panelClose", this); | ||
79 | } | ||
80 | }, | 46 | }, |
81 | 47 | ||
82 | handleMouseover: { | 48 | resizer: { |
83 | value: function() { | 49 | value: null |
84 | this.element.draggable = true; | ||
85 | } | ||
86 | }, | 50 | }, |
87 | 51 | ||
88 | handleMouseout: { | 52 | modulePath: { |
89 | value: function() { | 53 | value: null |
90 | this.element.draggable = false; | ||
91 | } | ||
92 | }, | 54 | }, |
93 | 55 | ||
94 | _resizer: { | 56 | moduleName: { |
95 | value: null | 57 | value: null |
96 | }, | 58 | }, |
97 | 59 | ||
98 | resizer: { | 60 | disabled: { |
61 | value:false | ||
62 | }, | ||
63 | |||
64 | collapsed: { | ||
99 | get: function() { | 65 | get: function() { |
100 | return this._resizer; | 66 | return this._collapsed; |
101 | }, | 67 | }, |
102 | set: function(val) { | 68 | set: function(val) { |
103 | this._resizer = val; | 69 | if (this._collapsed !== val) { |
70 | this._collapsed = val; | ||
71 | this.needsDraw = true; | ||
72 | } | ||
104 | } | 73 | } |
105 | }, | 74 | }, |
106 | 75 | ||
107 | 76 | height: { | |
108 | resized: { | 77 | get: function() { |
109 | value: function() { | 78 | if (this._height < this.minHeight) { |
110 | this.panelBase.contentHeight = parseInt(this.element.style.height); | 79 | this._height = this.minHeight; |
111 | this.needsDraw = true; | 80 | } |
81 | return this._height; | ||
82 | }, | ||
83 | set: function(val) { | ||
84 | if(this._height !== val) { | ||
85 | this._height = val; | ||
86 | this.needsDraw = true; | ||
87 | } | ||
112 | } | 88 | } |
113 | }, | 89 | }, |
114 | 90 | ||
115 | //TODO: Find out why without This following function drop event wont fire ??? | 91 | locked: { |
116 | handleEvent: { | 92 | get: function() { |
117 | value:function(e) { | 93 | return this._locked; |
118 | e.preventDefault(); | 94 | }, |
119 | e.stopImmediatePropagation(); | 95 | set: function(val) { |
120 | 96 | if (this.flexible) { | |
97 | this._locked = val; | ||
98 | this.needsDraw = true; | ||
99 | } | ||
121 | } | 100 | } |
122 | }, | 101 | }, |
123 | 102 | ||
124 | captureDragover: { | 103 | handleBtnCollapseAction: { |
125 | value:function(e) { | 104 | value: function() { |
126 | e.preventDefault(); | 105 | this.collapsed = !this.collapsed; |
127 | e.stopImmediatePropagation(); | 106 | this.needsDraw = true; |
128 | this.element.style.backgroundColor = "#917B56"; | ||
129 | } | 107 | } |
130 | }, | 108 | }, |
131 | 109 | ||
132 | captureDragleave: { | 110 | handleBtnCloseAction: { |
133 | value: function() { | 111 | value: function() { |
134 | this.element.style.backgroundColor = ""; | 112 | this.panelContent.content = null; |
135 | } | 113 | } |
136 | }, | 114 | }, |
137 | 115 | ||
138 | handleDrop: { | 116 | prepareForDraw: { |
139 | value:function(e) { | 117 | value: function() { |
140 | e.stopPropagation(); // Stops some browsers from redirecting. | 118 | if(this.name === "Color") { |
141 | e.preventDefault(); | 119 | this.application.ninja.colorController.colorView = this.application.ninja.colorController.colorPanelBase.create(); |
142 | this.element.style.backgroundColor = ""; | 120 | } |
143 | NJevent("panelOrderChanged", this); | ||
144 | } | ||
145 | }, | ||
146 | 121 | ||
147 | handleDragstart: { | 122 | if(this.modulePath && this.moduleName) { |
148 | value:function(e) { | 123 | // Load the slot content |
149 | e.dataTransfer.effectAllowed = 'move'; | 124 | var that = this; |
150 | e.dataTransfer.setData('text/html', this.element.innerHTML); | 125 | require.async(this.modulePath) |
151 | NJevent("panelSelected", this); | 126 | .then(function(panelContent) { |
127 | var componentRequire = panelContent[that.moduleName]; | ||
128 | that.panelContent.content = componentRequire.create(); | ||
129 | }) | ||
130 | .end(); | ||
131 | } | ||
152 | } | 132 | } |
153 | }, | 133 | }, |
154 | 134 | ||
155 | handleDragEnter: { | 135 | handleResizeStart: { |
156 | value: function(e) { | 136 | value:function(e) { |
157 | this.element.classList.add("over"); | 137 | this.isResizing = true; |
138 | this.needsDraw = true; | ||
158 | } | 139 | } |
159 | }, | 140 | }, |
160 | 141 | ||
161 | handleDragend: { | 142 | handleResizeMove: { |
162 | value:function() { | 143 | value:function(e) { |
163 | 144 | this._resizedHeight = e._event.dY; | |
145 | this.needsDraw = true; | ||