diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 14 | ||||
-rwxr-xr-x | js/controllers/elements/component-controller.js | 13 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 43 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 12 |
4 files changed, 69 insertions, 13 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7d982a62..d5556fa8 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -64,22 +64,29 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
64 | 64 | ||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 65 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 66 | ||
67 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); | ||
67 | } | 68 | } |
68 | }, | 69 | }, |
69 | 70 | ||
70 | 71 | handleAddComponentFirstDraw: { | |
72 | value: function (e) { | ||
73 | //TODO: Add logic to reparse the document for dynamically added styles | ||
74 | console.log(e); | ||
75 | } | ||
76 | }, | ||
71 | 77 | ||
72 | 78 | ||
73 | 79 | ||
74 | 80 | ||
75 | 81 | ||
76 | //////////////////////////////////////////////////////////////////// | 82 | //////////////////////////////////////////////////////////////////// |
77 | // | 83 | // |
78 | handleWebRequest: { | 84 | handleWebRequest: { |
79 | value: function (request) { | 85 | value: function (request) { |
80 | //TODO: Check if frameId is proper | 86 | //TODO: Check if frameId is proper |
81 | if (this._hackRootFlag && request.parentFrameId !== -1) { | 87 | if (this._hackRootFlag && request.parentFrameId !== -1) { |
82 | //TODO: Optimize creating string | 88 | //TODO: Optimize creating string |
89 | //console.log(request); | ||
83 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); | 90 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); |
84 | //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; | 91 | //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; |
85 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; | 92 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; |
@@ -103,6 +110,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
103 | }, | 110 | }, |
104 | //////////////////////////////////////////////////////////////////// | 111 | //////////////////////////////////////////////////////////////////// |
105 | 112 | ||
113 | |||
106 | 114 | ||
107 | 115 | ||
108 | 116 | ||
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 83450d0f..260ee8a0 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -11,6 +11,8 @@ exports.ComponentController = Montage.create(ElementController, { | |||
11 | 11 | ||
12 | getProperty: { | 12 | getProperty: { |
13 | value: function(el, prop) { | 13 | value: function(el, prop) { |
14 | var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); | ||
15 | |||
14 | switch(prop) { | 16 | switch(prop) { |
15 | case "id": | 17 | case "id": |
16 | case "class": | 18 | case "class": |
@@ -19,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, { | |||
19 | case "width": | 21 | case "width": |
20 | case "height": | 22 | case "height": |
21 | if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { | 23 | if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { |
22 | return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; | 24 | return component[prop]; |
23 | } else { | 25 | } else { |
24 | return ElementController.getProperty(el, prop, true); | 26 | return ElementController.getProperty(el, prop, true); |
25 | } | 27 | } |
26 | default: | 28 | default: |
27 | return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; | 29 | return component[prop]; |
28 | } | 30 | } |
29 | } | 31 | } |
30 | }, | 32 | }, |
31 | 33 | ||
32 | setProperty: { | 34 | setProperty: { |
33 | value: function(el, p, value) { | 35 | value: function(el, p, value) { |
36 | var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); | ||
37 | |||
34 | switch(p) { | 38 | switch(p) { |
35 | case "id": | 39 | case "id": |
36 | case "class": | 40 | case "class": |
@@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, { | |||
39 | case "width": | 43 | case "width": |
40 | case "height": | 44 | case "height": |
41 | if(el.nodeName === "IMG" && (p === "width" || p === "height")) { | 45 | if(el.nodeName === "IMG" && (p === "width" || p === "height")) { |
42 | this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; | 46 | component[p] = value; |
43 | } else { | 47 | } else { |
44 | ElementController.setProperty(el, p, value); | 48 | ElementController.setProperty(el, p, value); |
45 | } | 49 | } |
46 | break; | 50 | break; |
47 | default: | 51 | default: |
48 | if(p === "min" || p === "max") value = parseFloat(value); | 52 | if(p === "min" || p === "max") value = parseFloat(value); |
49 | 53 | component[p] = value; | |
50 | this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; | ||
51 | break; | 54 | break; |
52 | 55 | ||
53 | } | 56 | } |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b3ac9ddb..5b9e4672 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -105,6 +105,20 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
105 | case "editFillMaterial": | 105 | case "editFillMaterial": |
106 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); | 106 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); |
107 | break; | 107 | break; |
108 | case "animate": | ||
109 | if(value) | ||
110 | { | ||
111 | el.elementModel.shapeModel.animate = true; | ||
112 | el.elementModel.shapeModel.GLWorld._previewAnimation = true; | ||
113 | el.elementModel.shapeModel.GLWorld.restartRenderLoop(); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | el.elementModel.shapeModel.animate = false; | ||
118 | el.elementModel.shapeModel.GLWorld._previewAnimation = false; | ||
119 | el.elementModel.shapeModel.GLWorld._canvas.task.stop(); | ||
120 | } | ||
121 | break; | ||
108 | default: | 122 | default: |
109 | CanvasController.setProperty(el, p, value); | 123 | CanvasController.setProperty(el, p, value); |
110 | } | 124 | } |
@@ -123,6 +137,7 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
123 | case "border": | 137 | case "border": |
124 | case "background": | 138 | case "background": |
125 | case "useWebGl": | 139 | case "useWebGl": |
140 | case "animate": | ||
126 | return this.getShapeProperty(el, p); | 141 | return this.getShapeProperty(el, p); |
127 | case "strokeMaterial": | 142 | case "strokeMaterial": |
128 | case "fillMaterial": | 143 | case "fillMaterial": |
@@ -489,13 +504,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
489 | var sm, | 504 | var sm, |
490 | fm, | 505 | fm, |
491 | world, | 506 | world, |
492 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 507 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
493 | if(worldData) | 508 | if(worldData) |
494 | { | 509 | { |
510 | worldData = this.flip3DSense (worldData ); | ||
495 | world = new World(el, true); | 511 | world = new World(el, true); |
496 | el.elementModel.shapeModel.GLWorld = world; | 512 | el.elementModel.shapeModel.GLWorld = world; |
497 | el.elementModel.shapeModel.useWebGl = true; | 513 | el.elementModel.shapeModel.useWebGl = true; |
498 | world.import(worldData); | 514 | world.importJSON(worldData); |
499 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 515 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
500 | 516 | ||
501 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | 517 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); |
@@ -525,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
525 | return; | 541 | return; |
526 | } | 542 | } |
527 | var world, | 543 | var world, |
528 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 544 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
529 | if(worldData) | 545 | if(worldData) |
530 | { | 546 | { |
547 | worldData = this.flip3DSense (worldData ); | ||
531 | world = new World(el, false); | 548 | world = new World(el, false); |
532 | el.elementModel.shapeModel.GLWorld = world; | 549 | el.elementModel.shapeModel.GLWorld = world; |
533 | el.elementModel.shapeModel.useWebGl = false; | 550 | el.elementModel.shapeModel.useWebGl = false; |
534 | world.import(worldData); | 551 | world.importJSON(worldData); |
535 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 552 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
536 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); | 553 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); |
537 | el.elementModel.shapeModel.strokeMaterial = null; | 554 | el.elementModel.shapeModel.strokeMaterial = null; |
@@ -543,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
543 | } | 560 | } |
544 | } | 561 | } |
545 | } | 562 | } |
563 | }, | ||
564 | |||
565 | flip3DSense: { | ||