aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/body-controller.js4
-rwxr-xr-xjs/controllers/elements/element-controller.js8
-rwxr-xr-xjs/controllers/elements/shapes-controller.js2
-rwxr-xr-xjs/document/document-html.js10
-rwxr-xr-xjs/document/models/html.js23
-rwxr-xr-xjs/document/templates/banner/index.html24
-rwxr-xr-xjs/document/templates/html/index.html27
-rwxr-xr-xjs/document/views/design.js30
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js14
-rwxr-xr-xjs/lib/NJUtils.js120
-rwxr-xr-xjs/mediators/drag-drop-mediator.js2
-rwxr-xr-xjs/mediators/element-mediator.js42
-rwxr-xr-xjs/models/element-model.js96
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js22
-rw-r--r--js/tools/BrushTool.js1
-rwxr-xr-xjs/tools/EyedropperTool.js1
-rwxr-xr-xjs/tools/LineTool.js1
-rwxr-xr-xjs/tools/PenTool.js1
-rwxr-xr-xjs/tools/ShapeTool.js1
-rwxr-xr-xjs/tools/TagTool.js3
20 files changed, 184 insertions, 248 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 7a3a66f5..9c427c62 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -71,7 +71,7 @@ exports.BodyController = Montage.create(ElementController, {
71 71
72 getPerspectiveDist: { 72 getPerspectiveDist: {
73 value: function(el) { 73 value: function(el) {
74 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { 74 if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) {
75 return el.elementModel.props3D.perspectiveDist; 75 return el.elementModel.props3D.perspectiveDist;
76 } else { 76 } else {
77 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true); 77 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true);
@@ -83,7 +83,7 @@ exports.BodyController = Montage.create(ElementController, {
83 83
84 getMatrix: { 84 getMatrix: {
85 value: function(el) { 85 value: function(el) {
86 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) 86 if(el.elementModel.props3D && el.elementModel.props3D.matrix3d)
87 { 87 {
88 return el.elementModel.props3D.matrix3d.slice(0); 88 return el.elementModel.props3D.matrix3d.slice(0);
89 } 89 }
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 01e132d7..0223a6b5 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -36,7 +36,7 @@ exports.ElementController = Montage.create(Component, {
36 // Remove the element from the DOM and clear the GLWord. 36 // Remove the element from the DOM and clear the GLWord.
37 removeElement: { 37 removeElement: {
38 value: function(el) { 38 value: function(el) {
39 if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { 39 if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) {
40 el.elementModel.shapeModel.GLWorld.clearTree(); 40 el.elementModel.shapeModel.GLWorld.clearTree();
41 } 41 }
42 el.parentNode.removeChild(el); 42 el.parentNode.removeChild(el);
@@ -229,7 +229,7 @@ exports.ElementController = Montage.create(Component, {
229 // Routines to get/set 3D properties 229 // Routines to get/set 3D properties
230 get3DProperty: { 230 get3DProperty: {
231 value: function(el, prop) { 231 value: function(el, prop) {
232 if(el.elementModel && el.elementModel.props3D) { 232 if(el.elementModel.props3D) {
233 return el.elementModel.props3D[prop]; 233 return el.elementModel.props3D[prop];
234 } 234 }
235 } 235 }
@@ -237,7 +237,7 @@ exports.ElementController = Montage.create(Component, {
237 237
238 getMatrix: { 238 getMatrix: {
239 value: function(el) { 239 value: function(el) {
240 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) { 240 if(el.elementModel.props3D && el.elementModel.props3D.matrix3d) {
241 return el.elementModel.props3D.matrix3d.slice(0); 241 return el.elementModel.props3D.matrix3d.slice(0);
242 } else { 242 } else {
243 var mat; 243 var mat;
@@ -257,7 +257,7 @@ exports.ElementController = Montage.create(Component, {
257 257
258 getPerspectiveDist: { 258 getPerspectiveDist: {
259 value: function(el) { 259 value: function(el) {
260 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { 260 if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) {
261 return el.elementModel.props3D.perspectiveDist; 261 return el.elementModel.props3D.perspectiveDist;
262 } else { 262 } else {
263 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); 263 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false);
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 626dedb6..ae345489 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -133,7 +133,7 @@ exports.ShapesController = Montage.create(CanvasController, {
133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); 133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
134 canvas.width = el.width; 134 canvas.width = el.width;
135 canvas.height = el.height; 135 canvas.height = el.height;
136 canvas.elementModel = el.elementModel; 136 canvas._model = el.elementModel;
137 this.toggleWebGlMode(canvas, value); 137 this.toggleWebGlMode(canvas, value);
138 this.application.ninja.elementMediator.replaceElement(canvas, el); 138 this.application.ninja.elementMediator.replaceElement(canvas, el);
139 break; 139 break;
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 33a41a8e..4a8d5d41 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -88,7 +88,7 @@ exports.HtmlDocument = Montage.create(Component, {
88 //Adding observer to know when template is ready 88 //Adding observer to know when template is ready
89 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 89 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
90 this._observer.observe(this.model.views.design.document.head, {childList: true}); 90 this._observer.observe(this.model.views.design.document.head, {childList: true});
91 }.bind(this), template); 91 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
92 } else { 92 } else {
93 //TODO: Identify default view (probably code) 93 //TODO: Identify default view (probably code)
94 } 94 }
@@ -101,10 +101,14 @@ exports.HtmlDocument = Montage.create(Component, {
101 //Removing observer, only needed on initial load 101 //Removing observer, only needed on initial load
102 this._observer.disconnect(); 102 this._observer.disconnect();
103 this._observer = null; 103 this._observer = null;
104 //Making callback after view is loaded
105 this.loaded.callback.call(this.loaded.context, this);
106 } 104 }
107 }, 105 },
106 handleViewReady: {
107 value: function() {
108 //Making callback after view is loaded
109 this.loaded.callback.call(this.loaded.context, this);
110 }
111 },
108 //////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////
109 // 113 //
110 closeDocument: { 114 closeDocument: {
diff --git a/js/document/models/html.js b/js/document/models/html.js
index 9aa0d27e..a367f95f 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -64,31 +64,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
64 }, 64 },
65 //////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////
66 // 66 //
67 userComponents: {
68 value: {}
69 },
70 ////////////////////////////////////////////////////////////////////
71 //
72 documentRoot: { 67 documentRoot: {
73 value: null 68 value: null
74 },
75 ////////////////////////////////////////////////////////////////////
76 //Add a reference to a component instance to the userComponents hash using the element UUID
77 setComponentInstance: {
78 value: function(instance, el) {
79 this.userComponents[el.uuid] = instance;
80 }
81 },
82 ////////////////////////////////////////////////////////////////////
83 //Returns the component instance obj from the element
84 getComponentFromElement: {
85 value: function(el) {
86 if(el) {
87 if(el.uuid) return this.userComponents[el.uuid];
88 } else {
89 return null;
90 }
91 }
92 } 69 }
93 //////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////
94 //////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html
index f1ee3d98..08a998e5 100755
--- a/js/document/templates/banner/index.html
+++ b/js/document/templates/banner/index.html
@@ -74,9 +74,27 @@
74 </style> 74 </style>
75 75
76 <script type="text/javascript" data-ninja-template="true"> 76 <script type="text/javascript" data-ninja-template="true">
77 function getElement(x,y) { 77
78 return document.elementFromPoint(x,y); 78 function getElement(x,y) {
79 } 79 return document.elementFromPoint(x,y);
80 }
81
82 var njmodelGet = function njmodelGet() {
83 return (this.hasOwnProperty("_model") ? this._model: document.modelGenerator.call(this));
84 };
85
86 Object.defineProperty(Object.prototype, "_model", {
87 enumerable: false,
88 value: null,
89 writable: true
90 });
91
92 Object.defineProperty(Object.prototype, "elementModel", {
93 configurable: true,
94 get: njmodelGet,
95 set: function() {
96 }
97 });
80 </script> 98 </script>
81 99
82 <!-- TODO: Determine if loading Montage is always needed or if it could be done author-time or on file open --> 100 <!-- TODO: Determine if loading Montage is always needed or if it could be done author-time or on file open -->
diff --git a/js/document/templates/html/index.html b/js/document/templates/html/index.html
index 70187900..c74a7251 100755
--- a/js/document/templates/html/index.html
+++ b/js/document/templates/html/index.html
@@ -57,13 +57,32 @@