aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-06 17:05:05 -0800
committerPushkar Joshi2012-03-06 17:05:05 -0800
commit794abd077a0cd4c797d3f566281deca77b184bfe (patch)
tree3bf4a83ca714def2671fe8cef93db859b0d5553f /js/controllers
parentc155cd238b6f9e0b8191e0fc533f7bc974b762c2 (diff)
parent2e3943a8f751ec572066f168b58464c24b9f29e5 (diff)
downloadninja-794abd077a0cd4c797d3f566281deca77b184bfe.tar.gz
Merge branch 'master' into pentool
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/controllers/elements/shapes-controller.js17
-rwxr-xr-xjs/controllers/selection-controller.js12
-rwxr-xr-xjs/controllers/undo-controller.js17
4 files changed, 38 insertions, 17 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 64ff2c7e..194496a6 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -76,11 +76,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
76 // 76 //
77 handleWebRequest: { 77 handleWebRequest: {
78 value: function (request) { 78 value: function (request) {
79 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { 79 //TODO: Check if frameId is proper
80 if (this._hackRootFlag && request.parentFrameId !== -1) {
80 //TODO: Optimize creating string 81 //TODO: Optimize creating string
81 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]}; 82 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
82 } 83 //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]};
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(chrome.extension.getURL('js/document/templates/montage-html/'))[1]};
83 } 85 }
86 }
84 }, 87 },
85 //////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////
86 // 89 //
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 749a1dd9..3423a5a7 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage,
8 CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, 8 CanvasController = require("js/controllers/elements/canvas-controller").CanvasController,
9 njModule = require("js/lib/NJUtils"); 9 njModule = require("js/lib/NJUtils");
10 10
11var World = require("js/lib/drawing/world").World;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13
11exports.ShapesController = Montage.create(CanvasController, { 14exports.ShapesController = Montage.create(CanvasController, {
12 15
13 setProperty: { 16 setProperty: {
@@ -78,7 +81,7 @@ exports.ShapesController = Montage.create(CanvasController, {
78 this.application.ninja.selectionController.selectElement(el); 81 this.application.ninja.selectionController.selectElement(el);
79 return; 82 return;
80 case "strokeMaterial": 83 case "strokeMaterial":
81 var sm = Object.create(MaterialsLibrary.getMaterial(value)); 84 var sm = Object.create(MaterialsModel.getMaterial(value));
82 if(sm) 85 if(sm)
83 { 86 {
84 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 87 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
@@ -88,7 +91,7 @@ exports.ShapesController = Montage.create(CanvasController, {
88 } 91 }
89 break; 92 break;
90 case "fillMaterial": 93 case "fillMaterial":
91 var fm = Object.create(MaterialsLibrary.getMaterial(value)); 94 var fm = Object.create(MaterialsModel.getMaterial(value));
92 if(fm) 95 if(fm)
93 { 96 {
94 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); 97 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
@@ -317,7 +320,7 @@ exports.ShapesController = Montage.create(CanvasController, {
317 optionItem.innerText = "Default"; 320 optionItem.innerText = "Default";
318 cb.appendChild(optionItem); 321 cb.appendChild(optionItem);
319 322
320 var materials = MaterialsLibrary.materials; 323 var materials = this.application.ninja.appModel.materials;
321 var len = materials.length; 324 var len = materials.length;
322 325
323 var i; 326 var i;
@@ -366,19 +369,19 @@ exports.ShapesController = Montage.create(CanvasController, {
366 worldData = el.elementModel.shapeModel.GLWorld.export(); 369 worldData = el.elementModel.shapeModel.GLWorld.export();
367 if(worldData) 370 if(worldData)
368 { 371 {
369 world = new GLWorld(el, true); 372 world = new World(el, true);
370 el.elementModel.shapeModel.GLWorld = world; 373 el.elementModel.shapeModel.GLWorld = world;
371 el.elementModel.shapeModel.useWebGl = true; 374 el.elementModel.shapeModel.useWebGl = true;
372 world.import(worldData); 375 world.import(worldData);
373 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 376 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
374 377
375 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 378 sm = Object.create(MaterialsModel.getMaterial("FlatMaterial"));
376 if(sm) 379 if(sm)
377 { 380 {
378 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
379 el.elementModel.shapeModel.strokeMaterial = sm; 382 el.elementModel.shapeModel.strokeMaterial = sm;
380 } 383 }
381 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 384 fm = Object.create(MaterialsModel.getMaterial("FlatMaterial"));
382 // TODO - Use consts after GL code is converted to object literal notation 385 // TODO - Use consts after GL code is converted to object literal notation
383// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) ) 386// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) )
384 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) ) 387 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) )
@@ -402,7 +405,7 @@ exports.ShapesController = Montage.create(CanvasController, {
402 worldData = el.elementModel.shapeModel.GLWorld.export(); 405 worldData = el.elementModel.shapeModel.GLWorld.export();
403 if(worldData) 406 if(worldData)
404 { 407 {
405 world = new GLWorld(el, false); 408 world = new World(el, false);
406 el.elementModel.shapeModel.GLWorld = world; 409 el.elementModel.shapeModel.GLWorld = world;
407 el.elementModel.shapeModel.useWebGl = false; 410 el.elementModel.shapeModel.useWebGl = false;
408 world.import(worldData); 411 world.import(worldData);
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index c4623d3f..75968d4a 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -76,7 +76,7 @@ exports.SelectionController = Montage.create(Component, {
76 76
77 77
78 this.application.ninja.selectedElements = currentSelectionArray; 78 this.application.ninja.selectedElements = currentSelectionArray;
79 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); 79 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument});
80 80
81 81
82 82
@@ -92,12 +92,14 @@ exports.SelectionController = Montage.create(Component, {
92 handleSwitchDocument: { 92 handleSwitchDocument: {
93 value: function() { 93 value: function() {
94 this._selectedItems = this.application.ninja.selectedElements.slice(0); 94 this._selectedItems = this.application.ninja.selectedElements.slice(0);
95 if(this._selectedItems.length === 0 ){ 95 if(this._selectedItems.length === 0) {
96 this._isDocument = true; 96 this._isDocument = true;
97 }else{ 97 } else {
98 this._isDocument = false; 98 this._isDocument = false;
99 } 99 }
100 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); 100 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument});
101
102 this._selectionContainer = this.application.ninja.currentSelectedContainer;
101 } 103 }
102 }, 104 },
103 105
@@ -137,7 +139,7 @@ exports.SelectionController = Montage.create(Component, {
137 value: function(event) { 139 value: function(event) {
138 this.application.ninja.selectedElements = []; 140 this.application.ninja.selectedElements = [];
139 this._isDocument = true; 141 this._isDocument = true;
140 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); 142 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument});
141 } 143 }
142 }, 144 },
143 145
diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js
index 926803d3..19cfb6e6 100755
--- a/js/controllers/undo-controller.js
+++ b/js/controllers/undo-controller.js
@@ -71,22 +71,28 @@ exports.UndoController = Montage.create( Component, {
71 /** 71 /**
72 * Undo Queue 72 * Undo Queue
73 */ 73 */
74 _undoQueue: { value: [] }, 74 _undoQueue: { value: []},
75 75
76 undoQueue: { 76 undoQueue: {
77 get: function() { 77 get: function() {
78 return this._undoQueue; 78 return this._undoQueue;
79 },
80 set: function(value){
81 this._undoQueue = value;
79 } 82 }
80 }, 83 },
81 84
82 /** 85 /**
83 * Redo Queue 86 * Redo Queue
84 */ 87 */
85 _redoQueue: { value: [], enumerable: false }, 88 _redoQueue: { value: [], enumerable: false},
86 89
87 redoQueue: { 90 redoQueue: {
88 get: function() { 91 get: function() {
89 return this._redoQueue; 92 return this._redoQueue;
93 },
94 set: function(value){
95 this._redoQueue = value;
90 } 96 }
91 }, 97 },
92 98
@@ -202,5 +208,12 @@ exports.UndoController = Montage.create( Component, {
202 this.redoQueue.splice(0, this.redoQueue.length); 208 this.redoQueue.splice(0, this.redoQueue.length);
203 //this.redoQueue = []; 209 //this.redoQueue = [];
204 } 210 }
211 },
212
213 clearHistory:{
214 value: function(){
215 this.undoQueue.length = 0;
216 this.redoQueue.length = 0;