aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-14 11:22:21 -0800
committerValerio Virgillito2012-02-14 11:22:21 -0800
commitab1466b2627e40f58afcaa3d425d4145fa47525a (patch)
tree5c0de8b4db67b07b0e745e776e99eabff989d804 /js
parent33c805d441abb2f83fd1ac9ee2d3d4282acc009f (diff)
parentdf898049b2990f456a305eb18434b887468225cf (diff)
downloadninja-ab1466b2627e40f58afcaa3d425d4145fa47525a.tar.gz
Merge branch 'components' of https://github.com/mencio/ninja-internal into integration
Conflicts: js/io/document/html-document.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rw-r--r--js/components/treeview/ninja-leaf.reel/ninja-leaf.js7
-rwxr-xr-xjs/controllers/elements/component-controller.js41
-rwxr-xr-xjs/io/document/html-document.js74
-rwxr-xr-xjs/mediators/drag-drop-mediator.js17
-rwxr-xr-xjs/ninja.reel/ninja.html1
-rwxr-xr-xjs/panels/Components/Components.xml28
-rwxr-xr-xjs/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html39
-rwxr-xr-xjs/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js328
8 files changed, 353 insertions, 182 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 100755
--- 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
10exports.ComponentController = Montage.create(ElementController, { 10exports.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 ac556c2d..88cfec67 100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 BaseDocument = require("js/io/document/base-document").BaseDocument, 10 BaseDocument = require("js/io/document/base-document").BaseDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils; 11 NJUtils = require("js/lib/NJUtils").NJUtils;
12//////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////
13// 13//
14exports.HTMLDocument = Montage.create(BaseDocument, { 14exports.HTMLDocument = Montage.create(BaseDocument, {
@@ -31,6 +31,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
31 _userDocument: { value: null, enumerable: false }, 31 _userDocument: { value: null, enumerable: false },
32 _htmlSource: {value: "<html></html>", enumerable: false}, 32 _htmlSource: {value: "<html></html>", enumerable: false},
33 _glData: {value: null, enumerable: false }, 33 _glData: {value: null, enumerable: false },
34 _userComponents: { value: {}, enumarable: false},
34 35
35 _elementCounter: { value: 1, enumerable: false }, 36 _elementCounter: { value: 1, enumerable: false },
36 _snapping : { value: true, enumerable: false }, 37 _snapping : { value: true, enumerable: false },
@@ -137,23 +138,11 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
137 } 138 }
138 }, 139 },
139 140
140 _userComponentSet: { 141 userComponents: {
141 value: {}, 142 get: function() {
142 writable: true, 143 return this._userComponents;
143 enumerable:true 144 }
144 }, 145 },
145
146// userComponentSet:{
147// enumerable: true,
148// get: function() {
149// return this._userComponentSet;
150// },
151// set: function(value) {
152// this._userComponentSet = value;
153// this._drawUserComponentsOnOpen();
154// }
155// },
156//
157// _drawUserComponentsOnOpen:{ 146// _drawUserComponentsOnOpen:{
158// value:function(){ 147// value:function(){
159// for(var i in this._userComponentSet){ 148// for(var i in this._userComponentSet){
@@ -220,22 +209,45 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
220 set: function(value) { this._zoomFactor = value; } 209 set: function(value) { this._zoomFactor = value; }
221 }, 210 },
222 211
212 /**
213 * Add a reference to a component instance to the userComponents hash using the
214 * element UUID
215 */
216 setComponentInstance: {
217 value: function(instance, el) {
218 this.userComponents[el.uuid] = instance;
219 }
220 },
221
222 /**
223 * Returns the component instance obj from the element
224 */
225 getComponentFromElement: {
226 value: function(el) {
227 if(el) {
228 if(el.uuid) return this.userComponents[el.uuid];
229 } else {
230 return null;
231 }
232 }
233 },
234
223 //****************************************// 235 //****************************************//
224 // PUBLIC METHODS 236 // PUBLIC METHODS
225 237
226 238
227 //////////////////////////////////////////////////////////////////// 239 ////////////////////////////////////////////////////////////////////
228 // 240 //
229 initialize: { 241 initialize: {
230 value: function(file, uuid, iframe, callback) { 242 value: function(file, uuid, iframe, callback) {
231 // 243 //
232 this._userDocument = file; 244 this._userDocument = file;
233 // 245 //
234 this.init(file.name, file.uri, file.extension, iframe, uuid, callback); 246 this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
235 // 247 //
236 this.iframe = iframe; 248 this.iframe = iframe;
237 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; 249 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
238 this.currentView = "design"; 250 this.currentView = "design";
239 // 251 //
240 this.iframe.src = this._htmlTemplateUrl; 252 this.iframe.src = this._htmlTemplateUrl;
241 this.iframe.addEventListener("load", this, true); 253 this.iframe.addEventListener("load", this, true);
@@ -347,7 +359,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
347 }, 359 },
348 360
349 /* 361 /*
350// Private 362 // Private
351 _loadDocument: { 363 _loadDocument: {
352 value: function(uri) { 364 value: function(uri) {
353 // Load the document into the Iframe 365 // Load the document into the Iframe
@@ -356,7 +368,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
356 } 368 }
357 }, 369 },