From 84332ab81c1b445195f1d9be8bbeae0725c8e758 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 10:58:25 -0800 Subject: Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito --- js/controllers/elements/shapes-controller.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'js/controllers') 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, CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, njModule = require("js/lib/NJUtils"); +var World = require("js/lib/drawing/world").World; +var MaterialsModel = require("js/models/materials-model").MaterialsModel; + exports.ShapesController = Montage.create(CanvasController, { setProperty: { @@ -78,7 +81,7 @@ exports.ShapesController = Montage.create(CanvasController, { this.application.ninja.selectionController.selectElement(el); return; case "strokeMaterial": - var sm = Object.create(MaterialsLibrary.getMaterial(value)); + var sm = Object.create(MaterialsModel.getMaterial(value)); if(sm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); @@ -88,7 +91,7 @@ exports.ShapesController = Montage.create(CanvasController, { } break; case "fillMaterial": - var fm = Object.create(MaterialsLibrary.getMaterial(value)); + var fm = Object.create(MaterialsModel.getMaterial(value)); if(fm) { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); @@ -317,7 +320,7 @@ exports.ShapesController = Montage.create(CanvasController, { optionItem.innerText = "Default"; cb.appendChild(optionItem); - var materials = MaterialsLibrary.materials; + var materials = this.application.ninja.appModel.materials; var len = materials.length; var i; @@ -366,19 +369,19 @@ exports.ShapesController = Montage.create(CanvasController, { worldData = el.elementModel.shapeModel.GLWorld.export(); if(worldData) { - world = new GLWorld(el, true); + world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; world.import(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); - sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); if(sm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); el.elementModel.shapeModel.strokeMaterial = sm; } - fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + fm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); // TODO - Use consts after GL code is converted to object literal notation // if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) ) if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) ) @@ -402,7 +405,7 @@ exports.ShapesController = Montage.create(CanvasController, { worldData = el.elementModel.shapeModel.GLWorld.export(); if(worldData) { - world = new GLWorld(el, false); + world = new World(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; world.import(worldData); -- cgit v1.2.3 From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: Squashed commit FileIO-Build-Candidate into Master Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 9 ++++++--- js/controllers/selection-controller.js | 12 +++++++----- js/controllers/undo-controller.js | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) (limited to 'js/controllers') 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, // handleWebRequest: { value: function (request) { - if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { + //TODO: Check if frameId is proper + if (this._hackRootFlag && request.parentFrameId !== -1) { //TODO: Optimize creating string - 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]}; - } + //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); + //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]}; + 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]}; } + } }, //////////////////////////////////////////////////////////////////// // 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, { this.application.ninja.selectedElements = currentSelectionArray; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); @@ -92,12 +92,14 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { this._selectedItems = this.application.ninja.selectedElements.slice(0); - if(this._selectedItems.length === 0 ){ + if(this._selectedItems.length === 0) { this._isDocument = true; - }else{ + } else { this._isDocument = false; } - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); + + this._selectionContainer = this.application.ninja.currentSelectedContainer; } }, @@ -137,7 +139,7 @@ exports.SelectionController = Montage.create(Component, { value: function(event) { this.application.ninja.selectedElements = []; this._isDocument = true; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); } }, 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, { /** * Undo Queue */ - _undoQueue: { value: [] }, + _undoQueue: { value: []}, undoQueue: { get: function() { return this._undoQueue; + }, + set: function(value){ + this._undoQueue = value; } }, /** * Redo Queue */ - _redoQueue: { value: [], enumerable: false }, + _redoQueue: { value: [], enumerable: false}, redoQueue: { get: function() { return this._redoQueue; + }, + set: function(value){ + this._redoQueue = value; } }, @@ -202,5 +208,12 @@ exports.UndoController = Montage.create( Component, { this.redoQueue.splice(0, this.redoQueue.length); //this.redoQueue = []; } + }, + + clearHistory:{ + value: function(){ + this.undoQueue.length = 0; + this.redoQueue.length = 0; + } } }); \ No newline at end of file -- cgit v1.2.3