diff options
Diffstat (limited to 'js/mediators/element-mediator.js')
-rwxr-xr-x | js/mediators/element-mediator.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 1d5e9ade..88baf3d9 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -12,7 +12,13 @@ var ElementController = require("js/controllers/elements/element-controller").El | |||
12 | NJUtils = require("js/lib/NJUtils").NJUtils; | 12 | NJUtils = require("js/lib/NJUtils").NJUtils; |
13 | 13 | ||
14 | exports.ElementMediator = Montage.create(Component, { | 14 | exports.ElementMediator = Montage.create(Component, { |
15 | 15 | ||
16 | _NJUtils: { | ||
17 | get: function() { | ||
18 | if (!NJUtils) NJUtils = require("js/lib/NJUtils").NJUtils; | ||
19 | return NJUtils; | ||
20 | } | ||
21 | }, | ||
16 | 22 | ||
17 | addDelegate: { | 23 | addDelegate: { |
18 | enumerable: false, | 24 | enumerable: false, |
@@ -104,7 +110,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
104 | value: function(el, prop, valueMutator) { | 110 | value: function(el, prop, valueMutator) { |
105 | if(!el.elementModel) { | 111 | if(!el.elementModel) { |
106 | console.log("Element has no Model -> One should have been created"); | 112 | console.log("Element has no Model -> One should have been created"); |
107 | NJUtils.makeElementModel(el, "Div", "block"); | 113 | this._NJUtils.makeElementModel(el, "Div", "block"); |
108 | } | 114 | } |
109 | 115 | ||
110 | if(valueMutator && typeof valueMutator === "function") { | 116 | if(valueMutator && typeof valueMutator === "function") { |
@@ -119,7 +125,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
119 | value: function(el, prop) { | 125 | value: function(el, prop) { |
120 | if(!el.elementModel) { | 126 | if(!el.elementModel) { |
121 | console.log("Element has no Model -> One should have been created"); | 127 | console.log("Element has no Model -> One should have been created"); |
122 | NJUtils.makeElementModel(el, "Canvas", "block", true); | 128 | this._NJUtils.makeElementModel(el, "Canvas", "block", true); |
123 | } | 129 | } |
124 | 130 | ||
125 | return el.elementModel.controller["getShapeProperty"](el, prop); | 131 | return el.elementModel.controller["getShapeProperty"](el, prop); |
@@ -130,7 +136,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
130 | value: function(el, prop, value) { | 136 | value: function(el, prop, value) { |
131 | if(!el.elementModel) { | 137 | if(!el.elementModel) { |
132 | console.log("Element has no Model -> One should have been created"); | 138 | console.log("Element has no Model -> One should have been created"); |
133 | NJUtils.makeElementModel(el, "Canvas", "block", true); | 139 | this._NJUtils.makeElementModel(el, "Canvas", "block", true); |
134 | } | 140 | } |
135 | 141 | ||
136 | return el.elementModel.controller["setShapeProperty"](el, prop, value); | 142 | return el.elementModel.controller["setShapeProperty"](el, prop, value); |
@@ -298,7 +304,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
298 | getColor: { | 304 | getColor: { |
299 | value: function(el, isFill, borderSide) { | 305 | value: function(el, isFill, borderSide) { |
300 | if(!el.elementModel) { | 306 | if(!el.elementModel) { |
301 | NJUtils.makeModelFromElement(el); | 307 | this._NJUtils.makeModelFromElement(el); |
302 | } | 308 | } |
303 | return el.elementModel.controller["getColor"](el, isFill, borderSide); | 309 | return el.elementModel.controller["getColor"](el, isFill, borderSide); |
304 | } | 310 | } |
@@ -375,7 +381,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
375 | getStroke: { | 381 | getStroke: { |
376 | value: function(el) { | 382 | value: function(el) { |
377 | if(!el.elementModel) { | 383 | if(!el.elementModel) { |
378 | NJUtils.makeElementModel(el, "Div", "block"); | 384 | this._NJUtils.makeElementModel(el, "Div", "block"); |
379 | } | 385 | } |
380 | return el.elementModel.controller["getStroke"](el); | 386 | return el.elementModel.controller["getStroke"](el); |
381 | } | 387 | } |
@@ -453,7 +459,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
453 | get3DProperty: { | 459 | get3DProperty: { |
454 | value: function(el, prop) { | 460 | value: function(el, prop) { |
455 | if(!el.elementModel) { | 461 | if(!el.elementModel) { |
456 | NJUtils.makeModelFromElement(el); | 462 | this._NJUtils.makeModelFromElement(el); |
457 | } | 463 | } |
458 | return el.elementModel.controller["get3DProperty"](el, prop); | 464 | return el.elementModel.controller["get3DProperty"](el, prop); |
459 | } | 465 | } |
@@ -462,7 +468,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
462 | get3DProperties: { | 468 | get3DProperties: { |
463 | value: function(el) { | 469 | value: function(el) { |
464 | if(!el.elementModel) { | 470 | if(!el.elementModel) { |
465 | NJUtils.makeModelFromElement(el); | 471 | this._NJUtils.makeModelFromElement(el); |
466 | } | 472 | } |
467 | // var mat = this.getMatrix(el); | 473 | // var mat = this.getMatrix(el); |
468 | // var dist = this.getPerspectiveDist(el); | 474 | // var dist = this.getPerspectiveDist(el); |
@@ -475,7 +481,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
475 | getMatrix: { | 481 | getMatrix: { |
476 | value: function(el) { | 482 | value: function(el) { |
477 | if(!el.elementModel) { | 483 | if(!el.elementModel) { |
478 | NJUtils.makeModelFromElement(el); | 484 | this._NJUtils.makeModelFromElement(el); |
479 | } | 485 | } |
480 | return el.elementModel.controller["getMatrix"](el); | 486 | return el.elementModel.controller["getMatrix"](el); |
481 | } | 487 | } |
@@ -484,7 +490,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
484 | getPerspectiveDist: { | 490 | getPerspectiveDist: { |
485 | value: function(el) { | 491 | value: function(el) { |
486 | if(!el.elementModel) { | 492 | if(!el.elementModel) { |
487 | NJUtils.makeModelFromElement(el); | 493 | this._NJUtils.makeModelFromElement(el); |
488 | } | 494 | } |
489 | return el.elementModel.controller["getPerspectiveDist"](el); | 495 | return el.elementModel.controller["getPerspectiveDist"](el); |
490 | } | 496 | } |