diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/components/treeview/ninja-leaf.reel/ninja-leaf.js | 7 | ||||
-rw-r--r-- | js/controllers/elements/component-controller.js | 41 | ||||
-rw-r--r-- | js/io/document/html-document.js | 47 | ||||
-rw-r--r-- | js/mediators/drag-drop-mediator.js | 17 | ||||
-rw-r--r-- | js/ninja.reel/ninja.html | 1 | ||||
-rw-r--r-- | js/panels/Components/Components.xml | 28 | ||||
-rw-r--r-- | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html | 39 | ||||
-rw-r--r-- | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | 328 |
8 files changed, 340 insertions, 168 deletions
diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js index 0b7a171e..c6416693 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js | |||
@@ -36,14 +36,14 @@ exports.Leaf = Montage.create(TreeNode, { | |||
36 | handleEvent : { | 36 | handleEvent : { |
37 | value: function(e) { | 37 | value: function(e) { |
38 | var delegateMethod = this.delegateEventMap[e._event.type]; | 38 | var delegateMethod = this.delegateEventMap[e._event.type]; |
39 | this.callDelegateMethod(delegateMethod); | 39 | this.callDelegateMethod(delegateMethod, e); |
40 | } | 40 | } |
41 | }, | 41 | }, |
42 | callDelegateMethod : { | 42 | callDelegateMethod : { |
43 | value: function(methodName) { | 43 | value: function(methodName, evt) { |
44 | var delegate = this.treeView.contentController.delegate; | 44 | var delegate = this.treeView.contentController.delegate; |
45 | if(delegate && typeof delegate[methodName] === 'function') { | 45 | if(delegate && typeof delegate[methodName] === 'function') { |
46 | delegate[methodName](this.sourceObject); | 46 | delegate[methodName](this.sourceObject, evt); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | }, | 49 | }, |
@@ -60,6 +60,7 @@ exports.Leaf = Montage.create(TreeNode, { | |||
60 | delegateEventMap : { | 60 | delegateEventMap : { |
61 | value: { | 61 | value: { |
62 | 'click' : 'handleNodeActivation', | 62 | 'click' : 'handleNodeActivation', |
63 | 'dblclick' : 'handleDblclick', | ||
63 | 'dragstart' : 'handleDragStart', | 64 | 'dragstart' : 'handleDragStart', |
64 | 'dragend' : 'handleDragEnd' | 65 | 'dragend' : 'handleDragEnd' |
65 | } | 66 | } |
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 458e6b46..33b9b79a 100644 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -9,4 +9,45 @@ var Montage = require("montage/core/core").Montage, | |||
9 | 9 | ||
10 | exports.ComponentController = Montage.create(ElementController, { | 10 | exports.ComponentController = Montage.create(ElementController, { |
11 | 11 | ||
12 | getProperty: { | ||
13 | value: function(el, prop) { | ||
14 | switch(prop) { | ||
15 | case "label": | ||
16 | return this.application.ninja.currentDocument.getComponentFromElement(el).label; | ||
17 | break; | ||
18 | case "enabled": | ||
19 | return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; | ||
20 | break; | ||
21 | case "disabled": | ||
22 | return this.application.ninja.currentDocument.getComponentFromElement(el).disabled; | ||
23 | break; | ||
24 | case "value": | ||
25 | return this.application.ninja.currentDocument.getComponentFromElement(el).value; | ||
26 | break; | ||
27 | default: | ||
28 | return ElementController.getProperty(el, prop, true); | ||
29 | } | ||
30 | } | ||
31 | }, | ||
32 | |||
33 | setProperty: { | ||
34 | value: function(el, p, value) { | ||
35 | switch(p) { | ||
36 | case "label": | ||
37 | this.application.ninja.currentDocument.getComponentFromElement(el).label = value; | ||
38 | break; | ||
39 | case "enabled": | ||
40 | this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; | ||
41 | break; | ||
42 | case "disabled": | ||
43 | this.application.ninja.currentDocument.getComponentFromElement(el).disabled = value; | ||
44 | break; | ||
45 | case "value": | ||
46 | this.application.ninja.currentDocument.getComponentFromElement(el).value = value; | ||
47 | break; | ||
48 | default: | ||
49 | ElementController.setProperty(el, p, value); | ||
50 | } | ||
51 | } | ||
52 | } | ||
12 | }); | 53 | }); |
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index dd3507c2..393d29fe 100644 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -27,6 +27,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
27 | _initialUserDocument: { value: null, enumerable: false }, | 27 | _initialUserDocument: { value: null, enumerable: false }, |
28 | _htmlSource: {value: "<html></html>", enumerable: false}, | 28 | _htmlSource: {value: "<html></html>", enumerable: false}, |
29 | _glData: {value: null, enumerable: false }, | 29 | _glData: {value: null, enumerable: false }, |
30 | _userComponents: { value: {}, enumarable: false}, | ||
30 | 31 | ||
31 | _elementCounter: { value: 1, enumerable: false }, | 32 | _elementCounter: { value: 1, enumerable: false }, |
32 | _snapping : { value: true, enumerable: false }, | 33 | _snapping : { value: true, enumerable: false }, |
@@ -108,23 +109,11 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
108 | } | 109 | } |
109 | }, | 110 | }, |
110 | 111 | ||
111 | _userComponentSet: { | 112 | userComponents: { |
112 | value: {}, | 113 | get: function() { |
113 | writable: true, | 114 | return this._userComponents; |
114 | enumerable:true | 115 | } |
115 | }, | 116 | }, |
116 | |||
117 | // userComponentSet:{ | ||
118 | // enumerable: true, | ||
119 | // get: function() { | ||
120 | // return this._userComponentSet; | ||
121 | // }, | ||
122 | // set: function(value) { | ||
123 | // this._userComponentSet = value; | ||
124 | // this._drawUserComponentsOnOpen(); | ||
125 | // } | ||
126 | // }, | ||
127 | // | ||
128 | // _drawUserComponentsOnOpen:{ | 117 | // _drawUserComponentsOnOpen:{ |
129 | // value:function(){ | 118 | // value:function(){ |
130 | // for(var i in this._userComponentSet){ | 119 | // for(var i in this._userComponentSet){ |
@@ -191,6 +180,29 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
191 | set: function(value) { this._zoomFactor = value; } | 180 | set: function(value) { this._zoomFactor = value; } |
192 | }, | 181 | }, |
193 | 182 | ||
183 | /** | ||
184 | * Add a reference to a component instance to the userComponents hash using the | ||
185 | * element UUID | ||
186 | */ | ||
187 | setComponentInstance: { | ||
188 | value: function(instance, el) { | ||
189 | this.userComponents[el.uuid] = instance; | ||
190 | } | ||
191 | }, | ||
192 | |||
193 | /** | ||
194 | * Returns the component instance obj from the element | ||
195 | */ | ||
196 | getComponentFromElement: { | ||
197 | value: function(el) { | ||
198 | if(el) { | ||
199 | if(el.uuid) return this.userComponents[el.uuid]; | ||
200 | } else { | ||
201 | return null; | ||
202 | } | ||
203 | } | ||
204 | }, | ||
205 | |||
194 | //****************************************// | 206 | //****************************************// |
195 | // PUBLIC METHODS | 207 | // PUBLIC METHODS |
196 | initialize: { | 208 | initialize: { |
@@ -353,9 +365,6 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
353 | this.callback(this); | 365 | this.callback(this); |
354 | } | 366 | } |
355 | }.bind(this), 50); | 367 | }.bind(this), 50); |
356 | |||
357 | // TODO - Not sure where this goes | ||
358 | this._userComponentSet = {}; | ||
359 | } else { | 368 | } else { |
360 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; | 369 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; |
361 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array | 370 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array |
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index ede71383..bf22aed2 100644 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
@@ -24,6 +24,10 @@ exports.DragDropMediator = Montage.create(Component, { | |||
24 | writable: true | 24 | writable: true |
25 | }, | 25 | }, |
26 | 26 | ||
27 | dropDelegate: { | ||
28 | value: null | ||
29 | }, | ||
30 | |||
27 | deserializedFromTemplate: { | 31 | deserializedFromTemplate: { |
28 | value: function() { | 32 | value: function() { |
29 | this.eventManager.addEventListener("appLoaded", this, false); | 33 | this.eventManager.addEventListener("appLoaded", this, false); |
@@ -69,13 +73,14 @@ exports.DragDropMediator = Montage.create(Component, { | |||
69 | 73 | ||
70 | xferString = evt.dataTransfer.getData("text/plain"); | 74 | xferString = evt.dataTransfer.getData("text/plain"); |
71 | if(xferString) { | 75 | if(xferString) { |
72 | 76 | // If the drop is a component, call the delegate with the top,left coordinates | |
73 | if(xferString.lastIndexOf("-Component") !== -1) { | 77 | if(xferString.indexOf("componentDrop") > -1) { |
74 | component = xferString.substring(0, xferString.lastIndexOf("-Component")); | 78 | if(this.dropDelegate && typeof this.dropDelegate === 'object') { |
75 | NJevent( "executeAddComponent", { "component": component, "dropX": this.baseX, "dropY": this.baseY }); | 79 | this.dropDelegate.handleComponentDrop(this.baseX, this.baseY); |
76 | // ComponentPanelModule.ComponentsPanelBase.addComponentToStage(componentStr.substring(0, compInd), this.baseX, this.baseY); | 80 | return; |
81 | } | ||
77 | } | 82 | } |
78 | return; | 83 | |
79 | } | 84 | } |
80 | 85 | ||
81 | // Verify that browser supports FileReader API. | 86 | // Verify that browser supports FileReader API. |
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index c8625159..6daa75de 100644 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html | |||
@@ -276,6 +276,7 @@ | |||
276 | "stage": {"@": "stage1"}, | 276 | "stage": {"@": "stage1"}, |
277 | "settings": {"@": "settings1"}, | 277 | "settings": {"@" |