aboutsummaryrefslogtreecommitdiff
path: root/js/ninja.reel/ninja.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ninja.reel/ninja.js')
-rwxr-xr-xjs/ninja.reel/ninja.js96
1 files changed, 52 insertions, 44 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index 1bdd0050..d0eb1557 100755
--- a/js/ninja.reel/ninja.js
+++ b/js/ninja.reel/ninja.js
@@ -134,10 +134,21 @@ exports.Ninja = Montage.create(Component, {
134 value: [] 134 value: []
135 }, 135 },
136 136
137 currentSelectedContainer: { 137 _currentSelectedContainer: {
138 value: null 138 value: null
139 }, 139 },
140 140
141 currentSelectedContainer: {
142 get: function() {
143 return this._currentSelectedContainer;
144 },
145 set: function(value) {
146 if(value !== this._currentSelectedContainer) {
147 this._currentSelectedContainer = value;
148 }
149 }
150 },
151
141 templateDidLoad: { 152 templateDidLoad: {
142 value: function() { 153 value: function() {
143 this.ninjaVersion = window.ninjaVersion.ninja.version; 154 this.ninjaVersion = window.ninjaVersion.ninja.version;
@@ -161,24 +172,30 @@ exports.Ninja = Montage.create(Component, {
161 172
162 window.addEventListener("resize", this, false); 173 window.addEventListener("resize", this, false);
163 174
164 this.eventManager.addEventListener( "selectTool", this, false); 175 this.eventManager.addEventListener("selectTool", this, false);
165 this.eventManager.addEventListener( "selectSubTool", this, false); 176 this.eventManager.addEventListener("selectSubTool", this, false);
166 this.eventManager.addEventListener( "onOpenDocument", this, false); 177 this.eventManager.addEventListener("onOpenDocument", this, false);
178 this.eventManager.addEventListener("onSwitchDocument", this, false);
167 179
168 this.addEventListener("change@appModel.livePreview", this.executeLivePreview, false); 180 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false);
169 this.addEventListener("change@appModel.chromePreview", this.executeChromePreview, false); 181 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false);
170 this.addEventListener("change@appModel.debug", this.toggleDebug, false); 182 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false);
171 183
172 NJevent("appLoading"); 184 NJevent("appLoading");
173 } 185 }
174 }, 186 },
175 187
188
189 ////////////////////////////////////////////////////////////////////
190 //TODO: Expand method to allow other browsers for preview
176 executeChromePreview: { 191 executeChromePreview: {
177 value: function () { 192 value: function () {
178 this.application.ninja.documentController.activeDocument.livePreview(); 193 this.application.ninja.documentController.activeDocument.model.browserPreview('chrome');
179 } 194 }
180 }, 195 },
181 196 ////////////////////////////////////////////////////////////////////
197
198
182 handleResize: { 199 handleResize: {
183 value: function() { 200 value: function() {
184 this.stage.resizeCanvases = true; 201 this.stage.resizeCanvases = true;
@@ -262,8 +279,8 @@ exports.Ninja = Montage.create(Component, {
262 value: function(event) { 279 value: function(event) {
263 this.currentDocument = event.detail; 280 this.currentDocument = event.detail;
264 281
265 if(this.currentDocument.documentRoot) { 282 if(this.currentDocument.model.documentRoot) {
266 this.application.ninja.currentSelectedContainer = this.currentDocument.documentRoot; 283 this.currentSelectedContainer = this.currentDocument.model.documentRoot;
267 } else { 284 } else {
268 alert("The current document has not loaded yet"); 285 alert("The current document has not loaded yet");
269 return; 286 return;
@@ -274,24 +291,40 @@ exports.Ninja = Montage.create(Component, {
274 } 291 }
275 }, 292 },
276 293
294 handleOnSwitchDocument: {
295 value: function() {
296 this.currentDocument = this.documentController.activeDocument;
297
298 if(this.currentDocument.model.documentRoot) {
299 this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.model.documentRoot;
300 }
301
302 NJevent("switchDocument");
303 }
304 },
305
277 executeLivePreview: { 306 executeLivePreview: {
278 value: function() { 307 value: function() {
279 var background, overflow, transitionStopRule; 308 var background, overflow, transitionStopRule;
280 this.stage.hideCanvas(this.appModel.livePreview); 309 this.stage.hideCanvas(this.appModel.livePreview);
281 310
311 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
282 if(this.appModel.livePreview) { 312 if(this.appModel.livePreview) {
283 background = "#000000"; 313// background = "#000000";
284 overflow = "hidden"; 314// overflow = "hidden";
285 transitionStopRule = "nj-css-garbage-selector"; 315 transitionStopRule = "nj-css-garbage-selector";
286 } else { 316 } else {
287 background = "#808080"; 317// background = "#808080";
288 overflow = "visible"; 318// overflow = "visible";
289 transitionStopRule = "*" 319 transitionStopRule = "*"
290 } 320 }
291 321
292 this.currentDocument.documentRoot.elementModel.controller.setProperty(this.currentDocument.documentRoot, "body-background", background); 322 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
293 this.currentDocument.documentRoot.elementModel.controller.setProperty(this.currentDocument.documentRoot, "overflow", overflow); 323// this.currentDocument.model.documentRoot.elementModel.controller.setProperty(this.currentDocument.model.documentRoot, "body-background", background);
294 this.currentDocument.documentRoot.elementModel.controller.changeSelector(this.currentDocument.documentRoot, "transitionStopRule", transitionStopRule); 324// this.currentDocument.model.documentRoot.elementModel.controller.setProperty(this.currentDocument.model.documentRoot, "overflow", overflow);
325// this.currentDocument.model.documentRoot.elementModel.controller.changeSelector(this.currentDocument.model.documentRoot, "transitionStopRule", transitionStopRule);
326
327 this.application.ninja.stylesController._stageStylesheet.rules[0].selectorText = transitionStopRule;
295 328
296 this._toggleWebGlAnimation(this.appModel.livePreview); 329 this._toggleWebGlAnimation(this.appModel.livePreview);
297 } 330 }
@@ -300,7 +333,7 @@ exports.Ninja = Montage.create(Component, {
300 // Turn on WebGL animation during preview 333 // Turn on WebGL animation during preview
301 _toggleWebGlAnimation: { 334 _toggleWebGlAnimation: {
302 value: function(inLivePreview) { 335 value: function(inLivePreview) {
303 var glCanvases = this.currentDocument.iframe.contentWindow.document.querySelectorAll('[data-RDGE-id]'), 336 var glCanvases = this.currentDocument.model.views.design.iframe.contentWindow.document.querySelectorAll('[data-RDGE-id]'),
304 glShapeModel; 337 glShapeModel;
305 if(glCanvases) { 338 if(glCanvases) {
306 for(var i = 0, len = glCanvases.length; i<len; i++) { 339 for(var i = 0, len = glCanvases.length; i<len; i++) {
@@ -337,31 +370,6 @@ exports.Ninja = Montage.create(Component, {
337 } 370 }
338 }, 371 },
339 372
340 _handleAppLoaded: {
341 value: function(event){
342
343 /*
344 Object.defineBinding(docBar, "type", {
345 boundObject: DocumentManagerModule.DocumentManager,
346 boundObjectPropertyPath: "activeDocument.documentType"
347 });
348
349 Object.defineBinding(docBar, "currentView", {
350 boundObject: DocumentManagerModule.DocumentManager,
351 boundObjectPropertyPath: "activeDocument.currentView",
352 oneway: false
353 });
354
355 Object.defineBinding(docBar, "zoomFactor", {
356 boundObject: DocumentManagerModule.DocumentManager,
357 boundObjectPropertyPath: "activeDocument.zoomFactor",
358 oneway: false
359 });
360 */
361
362 }
363 },
364
365 setupGlobalHelpers: { 373 setupGlobalHelpers: {
366 value: function() { 374 value: function() {
367 375