From 9d2c2a80483415d7560b00cda5519153db23e241 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sat, 11 Feb 2012 23:04:36 -0800 Subject: Bug Fixes IKNINJA-1101 IKNINJA-1079 IKNINJA-1144 --- js/components/colorwheel.reel/compass_app_log.txt | 3 -- js/components/popup.reel/compass_app_log.txt | 48 ---------------------- .../Color/colorpanelbase.reel/colorpanelbase.js | 8 ++-- .../colorpanelpopup.reel/css/colorpanelpopup.css | 4 +- .../colorpanelpopup.reel/css/colorpanelpopup.scss | 4 +- 5 files changed, 8 insertions(+), 59 deletions(-) delete mode 100644 js/components/colorwheel.reel/compass_app_log.txt delete mode 100644 js/components/popup.reel/compass_app_log.txt (limited to 'js') diff --git a/js/components/colorwheel.reel/compass_app_log.txt b/js/components/colorwheel.reel/compass_app_log.txt deleted file mode 100644 index 815feb02..00000000 --- a/js/components/colorwheel.reel/compass_app_log.txt +++ /dev/null @@ -1,3 +0,0 @@ -2011-11-23 01:07:12 create css/colorwheel.css -2011-11-23 01:07:25 overwrite css/colorwheel.css -2011-12-20 17:04:05 overwrite css/colorwheel.css diff --git a/js/components/popup.reel/compass_app_log.txt b/js/components/popup.reel/compass_app_log.txt deleted file mode 100644 index 8a3fb984..00000000 --- a/js/components/popup.reel/compass_app_log.txt +++ /dev/null @@ -1,48 +0,0 @@ -2011-06-28 18:13:06 create css/popup.css -2011-06-28 18:13:12 identical css/popup.css -2011-06-28 18:14:08 overwrite css/popup.css -2011-06-28 18:14:20 overwrite css/popup.css -2011-06-28 18:14:29 overwrite css/popup.css -2011-06-28 18:17:23 overwrite css/popup.css -2011-06-28 18:17:27 overwrite css/popup.css -2011-06-28 18:17:56 overwrite css/popup.css -2011-06-28 18:18:09 overwrite css/popup.css -2011-06-28 18:20:30 overwrite css/popup.css -2011-06-28 18:22:35 overwrite css/popup.css -2011-06-28 18:24:12 overwrite css/popup.css -2011-06-28 18:24:23 overwrite css/popup.css -2011-06-28 18:24:33 overwrite css/popup.css -2011-06-28 18:25:17 overwrite css/popup.css -2011-06-28 18:26:21 overwrite css/popup.css -2011-06-28 18:26:33 overwrite css/popup.css -2011-06-28 18:26:42 overwrite css/popup.css -2011-06-28 18:26:57 overwrite css/popup.css -2011-06-28 18:29:57 overwrite css/popup.css -2011-06-28 18:30:14 overwrite css/popup.css -2011-06-28 18:30:23 overwrite css/popup.css -2011-06-28 18:30:48 overwrite css/popup.css -2011-06-28 18:31:03 overwrite css/popup.css -2011-06-29 10:18:31 overwrite css/popup.css -2011-06-29 10:18:47 overwrite css/popup.css -2011-06-29 10:37:19 overwrite css/popup.css -2011-06-29 10:40:29 overwrite css/popup.css -2011-06-29 10:45:37 overwrite css/popup.css -2011-06-29 10:45:53 identical css/popup.css -2011-06-29 10:46:52 overwrite css/popup.css -2011-06-29 10:47:02 identical css/popup.css -2011-06-29 13:30:47 overwrite css/popup.css -2011-06-29 13:31:14 overwrite css/popup.css -2011-12-20 17:06:48 overwrite css/popup.css -2011-12-22 11:29:15 overwrite css/popup.css -2011-12-22 11:29:24 identical css/popup.css -2011-12-22 11:30:05 overwrite css/popup.css -2011-12-22 11:30:33 overwrite css/popup.css -2011-12-22 11:30:51 overwrite css/popup.css -2011-12-22 11:32:30 overwrite css/popup.css -2011-12-22 11:33:06 overwrite css/popup.css -2011-12-22 11:33:12 overwrite css/popup.css -2011-12-22 11:33:32 identical css/popup.css -2011-12-22 11:33:36 overwrite css/popup.css -2011-12-22 11:34:48 overwrite css/popup.css -2012-01-26 11:42:18 overwrite css/popup.css -2012-01-26 11:42:20 overwrite css/popup.css diff --git a/js/panels/Color/colorpanelbase.reel/colorpanelbase.js b/js/panels/Color/colorpanelbase.reel/colorpanelbase.js index 9a27689a..ff738bbe 100644 --- a/js/panels/Color/colorpanelbase.reel/colorpanelbase.js +++ b/js/panels/Color/colorpanelbase.reel/colorpanelbase.js @@ -1499,13 +1499,13 @@ exports.ColorPanelBase = Montage.create(Component, { // if (type._event.clientX && type._event.clientY) { // - if (type._event.clientX > (parseInt(document.width)/2)) { + //if (type._event.clientX > (parseInt(document.width)/2)) { //TODO: Fix offset hack this.application.ninja.colorController.colorPopupManager.showColorPopup((type._event.clientX - type._event.offsetX) +'px', (type._event.target.clientHeight/2+type._event.clientY - type._event.offsetY)+'px', 'right', 'top'); - } else { + //} else { // - this.application.ninja.colorController.colorPopupManager.showColorPopup((type._event.clientX - type._event.offsetX)+parseInt(type._event.target.offsetWidth)+'px', (type._event.target.offsetHeight/2+type._event.clientY - type._event.offsetY)+'px', 'left', 'top'); - } + // this.application.ninja.colorController.colorPopupManager.showColorPopup((type._event.clientX - type._event.offsetX)+parseInt(type._event.target.offsetWidth)+'px', (type._event.target.offsetHeight/2+type._event.clientY - type._event.offsetY)+'px', 'left', 'top'); + //} } } } else { diff --git a/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.css b/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.css index 6a418279..4db0abff 100644 --- a/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.css +++ b/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.css @@ -6,7 +6,7 @@ */ /* line 12, colorpanelpopup.scss */ .cpp_popup { - overflow: none; + overflow: hidden; font-size: 12px; text-shadow: 1px 1px 1px #000; font-family: 'Droid Sans', sans-serif; @@ -28,7 +28,7 @@ text-indent: -9999px; overflow: hidden; float: right; - padding: none; + padding: 0; cursor: pointer; border: 1px solid transparent; } diff --git a/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.scss b/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.scss index 20481fb6..1f63658a 100644 --- a/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.scss +++ b/js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.scss @@ -10,7 +10,7 @@ $grey_light: #494949; .cpp_popup { - overflow: none; + overflow: hidden; font-size: 12px; text-shadow: 1px 1px 1px #000; font-family: 'Droid Sans', sans-serif; @@ -32,7 +32,7 @@ $grey_light: #494949; text-indent: -9999px; overflow: hidden; float: right; - padding: none; + padding: 0; cursor: pointer; border: 1px solid transparent; } -- cgit v1.2.3 From 2edcdd88ffc2f6ff0ea836e4da3e1fd2cb3e856f Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 27 Feb 2012 17:39:26 -0800 Subject: persist undo/redo stack per html document Signed-off-by: Ananya Sen --- js/controllers/undo-controller.js | 17 ++++++++++++++-- js/document/html-document.js | 29 ++++++++++++++++++++++++++++ js/models/color-model.js | 6 +++--- js/ninja.reel/ninja.js | 3 +++ js/panels/properties/content.reel/content.js | 4 ++-- 5 files changed, 52 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js index 926803d3..01853593 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: [], writable:true }, undoQueue: { get: function() { return this._undoQueue; + }, + set: function(value){ + this._undoQueue = value; } }, /** * Redo Queue */ - _redoQueue: { value: [], enumerable: false }, + _redoQueue: { value: [], enumerable: false, writable:true }, 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.splice(0, this.undoQueue.length); + this.redoQueue.splice(0, this.redoQueue.length); + } } }); \ No newline at end of file diff --git a/js/document/html-document.js b/js/document/html-document.js index 75628731..111c491d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -59,6 +59,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { _gridVerticalSpacing: {value:0}, //end - drawUtils state + _undoStack: { value: [] }, + undoStack: { + get: function() { + return this._undoStack; + }, + set:function(value){ + this._undoStack = value; + } + }, + + _redoStack: { value: [], enumerable: false }, + + redoStack: { + get: function() { + return this._redoStack; + }, + set:function(value){ + this._redoStack = value; + } + }, + // GETTERS / SETTERS @@ -681,6 +702,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { } this.draw3DGrid = this.application.ninja.appModel.show3dGrid; + + //persist a clone of history per document + this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); + this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); + this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start } }, @@ -704,6 +730,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.handleScroll(); this.application.ninja.appModel.show3dGrid = this.draw3DGrid; + + this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); + this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); } } //////////////////////////////////////////////////////////////////// diff --git a/js/models/color-model.js b/js/models/color-model.js index 2c86422f..d3618c3e 100755 --- a/js/models/color-model.js +++ b/js/models/color-model.js @@ -265,7 +265,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'rgb': //Checking for match of previous (RGB) - if (color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { + if (color && color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { //Setting value and breaking out of function this.rgb = color; return; @@ -279,7 +279,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'hsv': //Checking for match of previous (HSV) - if (color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { + if (color && color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { //Setting value and breaking out of function this.hsv = color; return; @@ -293,7 +293,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'hsl': //Checking for match of previous (HSV) - if (color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { + if (color && color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { //Setting value and breaking out of function this.hsl = color; return; diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 6efeef8a..ab9503ec 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -98,6 +98,9 @@ exports.Ninja = Montage.create(Component, { if(this._appLoaded && this._preload) { // App is now deserialized and files are preloaded this.appModel.materials = MaterialsLibrary.materials; + + this.currentDocument = null; + } } }, diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 8fa33a75..fa4c56f2 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -268,12 +268,12 @@ exports.Content = Montage.create(Component, { } else { - if (currentValue.color.a !== undefined) + if (currentValue.color && (currentValue.color.a !== undefined)) { this.application.ninja.colorController.colorModel.alpha = {value: currentValue.color.a, wasSetByCode: true, type: 'change'}; } - if(currentValue.color.mode) + if(currentValue.color && currentValue.color.mode) { this.application.ninja.colorController.colorModel[currentValue.color.mode] = currentValue.color; } -- cgit v1.2.3 From ada597016685a83f2c9a8b25b28589b9221569c0 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 12:26:52 -0800 Subject: reverting null checks as per request Signed-off-by: Ananya Sen --- js/models/color-model.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/models/color-model.js b/js/models/color-model.js index d3618c3e..2c86422f 100755 --- a/js/models/color-model.js +++ b/js/models/color-model.js @@ -265,7 +265,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'rgb': //Checking for match of previous (RGB) - if (color && color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { + if (color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { //Setting value and breaking out of function this.rgb = color; return; @@ -279,7 +279,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'hsv': //Checking for match of previous (HSV) - if (color && color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { + if (color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { //Setting value and breaking out of function this.hsv = color; return; @@ -293,7 +293,7 @@ exports.ColorModel = Montage.create(Component, { //////////////////////////////////////////////////////// case 'hsl': //Checking for match of previous (HSV) - if (color && color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { + if (color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { //Setting value and breaking out of function this.hsl = color; return; -- cgit v1.2.3 From 866df4801b9e77a0155ffbfb87adbc79a94ce9a5 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 12:34:33 -0800 Subject: reverted null check as per request Signed-off-by: Ananya Sen --- js/panels/properties/content.reel/content.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index fa4c56f2..8fa33a75 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -268,12 +268,12 @@ exports.Content = Montage.create(Component, { } else { - if (currentValue.color && (currentValue.color.a !== undefined)) + if (currentValue.color.a !== undefined) { this.application.ninja.colorController.colorModel.alpha = {value: currentValue.color.a, wasSetByCode: true, type: 'change'}; } - if(currentValue.color && currentValue.color.mode) + if(currentValue.color.mode) { this.application.ninja.colorController.colorModel[currentValue.color.mode] = currentValue.color; } -- cgit v1.2.3 From 1766c6b17e2311fcd21c2be6608c7dcdc0a9b23a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 15:07:49 -0800 Subject: persist selections while switching documents Signed-off-by: Ananya Sen --- js/controllers/selection-controller.js | 9 +++++++++ js/document/html-document.js | 6 +++--- js/panels/properties/content.reel/content.js | 11 +++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index f50762f3..62313960 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -47,6 +47,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementDeleted", this, false); this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("deleteSelection", this, false); + this.eventManager.addEventListener("switchDocument", this, false); // defaultEventManager.addEventListener( "undo", this, false); // defaultEventManager.addEventListener( "redo", this, false); } @@ -88,6 +89,14 @@ exports.SelectionController = Montage.create(Component, { } }, + handleSwitchDocument: { + value: function() { + this._selectedItems = this.application.ninja.selectedElements.slice(0); + this._isDocument = false; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + } + }, + handleElementAdded: { value: function(event) { this.executeSelectElement(event.detail); diff --git a/js/document/html-document.js b/js/document/html-document.js index 111c491d..aac03606 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -698,7 +698,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; if(typeof this.application.ninja.selectedElements !== 'undefined'){ - this.selectionModel = this.application.ninja.selectedElements; + this.selectionModel = this.application.ninja.selectedElements.slice(0); } this.draw3DGrid = this.application.ninja.appModel.show3dGrid; @@ -717,8 +717,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ - this.application.ninja.selectionController.initWithDocument(this.selectionModel); + if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + this.application.ninja.selectedElements = this.selectionModel.slice(0); } if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 8fa33a75..e92fbcb2 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -55,6 +55,8 @@ exports.Content = Montage.create(Component, { } this.eventManager.addEventListener("openDocument", this, false); + + this.eventManager.addEventListener("switchDocument", this, false); } }, @@ -74,6 +76,15 @@ exports.Content = Montage.create(Component, { } }, + handleSwitchDocument: { + value: function(){ + // For now always assume that the stage is selected by default + if(this.application.ninja.selectedElements.length === 0) { + this.displayStageProperties(); + } + } + }, + /** * Blur and Key up to handle change in the Element ID field. */ -- cgit v1.2.3 From e0fab951e4f3869b04fd4a01f429a6654991cd68 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 15:33:35 -0800 Subject: minor fixes in saving undo/redo stacks per document Signed-off-by: Ananya Sen --- js/controllers/undo-controller.js | 8 ++++---- js/ninja.reel/ninja.js | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js index 01853593..19cfb6e6 100755 --- a/js/controllers/undo-controller.js +++ b/js/controllers/undo-controller.js @@ -71,7 +71,7 @@ exports.UndoController = Montage.create( Component, { /** * Undo Queue */ - _undoQueue: { value: [], writable:true }, + _undoQueue: { value: []}, undoQueue: { get: function() { @@ -85,7 +85,7 @@ exports.UndoController = Montage.create( Component, { /** * Redo Queue */ - _redoQueue: { value: [], enumerable: false, writable:true }, + _redoQueue: { value: [], enumerable: false}, redoQueue: { get: function() { @@ -212,8 +212,8 @@ exports.UndoController = Montage.create( Component, { clearHistory:{ value: function(){ - this.undoQueue.splice(0, this.undoQueue.length); - this.redoQueue.splice(0, this.redoQueue.length); + this.undoQueue.length = 0; + this.redoQueue.length = 0; } } }); \ No newline at end of file diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index ab9503ec..6efeef8a 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -98,9 +98,6 @@ exports.Ninja = Montage.create(Component, { if(this._appLoaded && this._preload) { // App is now deserialized and files are preloaded this.appModel.materials = MaterialsLibrary.materials; - - this.currentDocument = null; - } } }, -- cgit v1.2.3 From 1c7e86b6c2c802d720cc3075f75c7a61866ebc07 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 16:41:18 -0800 Subject: fix for creatingNewFile flag Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 02031922..64ff2c7e 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -195,7 +195,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value:function(doc){ var response = doc || null;//default just for testing if(!!response && response.success && (response.status!== 500) && !!response.uri){ + + this.isNewFilePath = true;//path identifier flag this.creatingNewFile = true;//flag for timeline to identify new file flow + this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); }else if(!!response && !response.success){ //Todo: restrict directory path to the sandbox, in the dialog itself @@ -224,9 +227,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //TODO: Add UI to handle error codes, shouldn't be alert windows if(!!response && (response.status === 204)) { - if((typeof this.creatingNewFile === 'undefined') || (this.creatingNewFile !== true)){//not from new file flow + if((typeof this.isNewFilePath === 'undefined') || (this.isNewFilePath !== true)){//not from new file flow this.creatingNewFile = false; } + this.isNewFilePath = false;//reset path identifier flag //Sending full response object this.openDocument(response); -- cgit v1.2.3 From 7a9c2a91dfbbdd0cd7c79d81be5aeecd7887e7f1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 10:12:38 -0800 Subject: handle selections for switching documents Signed-off-by: Ananya Sen --- js/controllers/selection-controller.js | 6 +++++- js/panels/properties/content.reel/content.js | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 62313960..0f2a16e0 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -92,7 +92,11 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { this._selectedItems = this.application.ninja.selectedElements.slice(0); - this._isDocument = false; + if(this._selectedItems.length === 0){ + this._isDocument = true; + }else{ + this._isDocument = false; + } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); } }, diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index e92fbcb2..fcd85675 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -81,6 +81,12 @@ exports.Content = Montage.create(Component, { // For now always assume that the stage is selected by default if(this.application.ninja.selectedElements.length === 0) { this.displayStageProperties(); + }else{ + if(this.application.ninja.selectedElements.length === 1) { + this.displayElementProperties(this.application.ninja.selectedElements[0]._element); + } else { + this.displayGroupProperties(this.application.ninja.selectedElements); + } } } }, -- cgit v1.2.3 From 03ea76700cb8bee3f4f58acf3e3503b0642d13fb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 11:46:19 -0800 Subject: fixed selection which click after switching to a document Signed-off-by: Ananya Sen --- js/controllers/selection-controller.js | 4 +++- js/document/html-document.js | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 0f2a16e0..184c4899 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -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{ this._isDocument = false; } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + + this._selectionContainer = this.application.ninja.currentSelectedContainer; } }, diff --git a/js/document/html-document.js b/js/document/html-document.js index aac03606..9e3f0cdd 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -717,9 +717,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ - this.application.ninja.selectedElements = this.selectionModel.slice(0); - } + if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; @@ -727,12 +725,17 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; this.application.ninja.stage._scrollLeft = this.savedTopScroll; } - this.application.ninja.stage.handleScroll(); + + if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + this.application.ninja.selectedElements = this.selectionModel.slice(0); + } this.application.ninja.appModel.show3dGrid = this.draw3DGrid; this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); + + this.application.ninja.currentSelectedContainer = this.documentRoot; } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 4e21db069b28c79236c8c7fd19dcc7810d28c5cb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 12:18:09 -0800 Subject: set selectionContainer before restoring selected elements Signed-off-by: Ananya Sen --- js/document/html-document.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9e3f0cdd..9dcea8cb 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -726,6 +726,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage._scrollLeft = this.savedTopScroll; } + this.application.ninja.currentSelectedContainer = this.documentRoot; if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } @@ -735,7 +736,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); - this.application.ninja.currentSelectedContainer = this.documentRoot; + } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 7a259f8c78a2394e32c62654623285ee595c6249 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 13:25:35 -0800 Subject: IKNINJA-1217: use encodeURI instead to save into sessionStorage Signed-off-by: Ananya Sen --- js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 428e7bab..3d99ae4d 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -861,12 +861,12 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { var dataStore = window.sessionStorage; try { if(this.pickerModel.pickerMode === "write"){ - dataStore.setItem('lastSavedFolderURI',escape(""+this.currentURI)); + dataStore.setItem('lastSavedFolderURI', encodeURI(""+this.currentURI)); } else if(this.pickerModel.inFileMode === true){ - dataStore.setItem('lastOpenedFolderURI_fileSelection',escape(""+this.currentURI)); + dataStore.setItem('lastOpenedFolderURI_fileSelection',encodeURI(""+this.currentURI)); }else if(this.pickerModel.inFileMode === false){ - dataStore.setItem('lastOpenedFolderURI_folderSelection',escape(""+this.currentURI)); + dataStore.setItem('lastOpenedFolderURI_folderSelection',encodeURI(""+this.currentURI)); } } catch(e){ -- cgit v1.2.3 From 0cd17b6cf9231e60083958d85759d4796f505342 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 29 Feb 2012 13:48:11 -0800 Subject: Fix for selection bug due to bad scrollLeft and scrollTop values when switching between documents. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9dcea8cb..581bbc08 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -719,15 +719,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { - if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ + if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; - this.application.ninja.stage._scrollLeft = this.savedLeftScroll; this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; - this.application.ninja.stage._scrollLeft = this.savedTopScroll; + this.application.ninja.stage.handleScroll(); } this.application.ninja.currentSelectedContainer = this.documentRoot; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + if(!this.selectionModel){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } -- cgit v1.2.3 From 84d6f6f5518e5ef8fc3d68be7e41c510f57b597a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 29 Feb 2012 13:53:45 -0800 Subject: Fixing typo. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 581bbc08..544c0ad5 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -726,7 +726,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } this.application.ninja.currentSelectedContainer = this.documentRoot; - if(!this.selectionModel){ + if(this.selectionModel){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } -- cgit v1.2.3 From 80ac930684255dd24cecae70b488285a6058488e Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 1 Mar 2012 13:34:45 -0800 Subject: Optimizing URL intercepting detection Modified the way the webRequest maps to the file. --- js/controllers/document-controller.js | 9 ++++++--- js/document/html-document.js | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'js') 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/document/html-document.js b/js/document/html-document.js index e40656a3..1691e3e4 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -486,11 +486,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { if(this._document.styleSheets[i].rules === null) { //TODO: Revisit URLs and URI creation logic, very hack right now var fileUri, cssUrl, cssData, tag, query; - if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { + //TODO: Parse out relative URLs and map them to absolute + if (this._document.styleSheets[i].href.indexOf(chrome.extension.getURL('')) !== -1) { //Getting the url of the CSS file - cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; + cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1];//TODO: Parse out relative URLs and map them to absolute //Creating the URI of the file (this is wrong should not be splitting cssUrl) - fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl.split('/')[1]; + fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl; //Loading the data from the file cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); //Creating tag with file content @@ -506,6 +507,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); } } + //TODO: Parse out relative URLs and map them to absolute + //console.log(cssData.content); tag.innerHTML = cssData.content; //Looping through DOM to insert style tag at location of link element query = this._templateDocument.html.querySelectorAll(['link']); -- cgit v1.2.3 From ff77f861fba349dd36d6c15c9a545459c3a76583 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 2 Mar 2012 10:34:01 -0800 Subject: Fixing IO RegEx Fixed parsing files to have correct URLs with RegEx, inner content of CSS files still needs to be fixed. --- js/document/html-document.js | 22 ++++++----- js/mediators/io-mediator.js | 92 +++++++++++++++++++++++++++++--------------- 2 files changed, 74 insertions(+), 40 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 1691e3e4..9353027d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -485,17 +485,18 @@ exports.HTMLDocument = Montage.create(TextDocument, { //If rules are null, assuming cross-origin issue if(this._document.styleSheets[i].rules === null) { //TODO: Revisit URLs and URI creation logic, very hack right now - var fileUri, cssUrl, cssData, tag, query; + var fileUri, cssUrl, cssData, query, prefixUrl; //TODO: Parse out relative URLs and map them to absolute if (this._document.styleSheets[i].href.indexOf(chrome.extension.getURL('')) !== -1) { //Getting the url of the CSS file cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1];//TODO: Parse out relative URLs and map them to absolute //Creating the URI of the file (this is wrong should not be splitting cssUrl) fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl; + fileUri = fileUri.replace(/\/\//gi, '/'); //Loading the data from the file cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); //Creating tag with file content - tag = this.iframe.contentWindow.document.createElement('style'); + var tag = this.iframe.contentWindow.document.createElement('style'); tag.setAttribute('type', 'text/css'); tag.setAttribute('data-ninja-uri', fileUri); tag.setAttribute('data-ninja-file-url', cssUrl); @@ -503,13 +504,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); //Copying attributes to maintain same properties as the for (var n in this._document.styleSheets[i].ownerNode.attributes) { - if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { + if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled' && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); } } - //TODO: Parse out relative URLs and map them to absolute - //console.log(cssData.content); - tag.innerHTML = cssData.content; + //TODO: Fix regEx to have logic for all possible URLs strings + prefixUrl = '('+cssUrl.split(cssUrl.split('/')[cssUrl.split('/').length-1])[0]+'../'; + prefixUrl = prefixUrl.replace('(/', '('); + tag.innerHTML = cssData.content.replace(/\(\.\.\//gi, prefixUrl); //Looping through DOM to insert style tag at location of link element query = this._templateDocument.html.querySelectorAll(['link']); for (var j in query) { @@ -522,15 +524,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } else { console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); - /* -//None local stylesheet, probably on a CDN (locked) + //None local stylesheet, probably on a CDN (locked) tag = this.iframe.contentWindow.document.createElement('style'); tag.setAttribute('type', 'text/css'); tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href); tag.setAttribute('data-ninja-file-read-only', "true"); tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]); - //TODO: Figure out cross-domain XHR issue, might need cloud to handle + /* +//TODO: Figure out cross-domain XHR issue, might need cloud to handle var xhr = new XMLHttpRequest(); xhr.open("GET", this._document.styleSheets[i].href, true); xhr.send(); @@ -538,6 +540,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { if (xhr.readyState === 4) { console.log(xhr); } +*/ //tag.innerHTML = xhr.responseText //xhr.response; //Currently no external styles will load if unable to load via XHR request @@ -552,7 +555,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { this._templateDocument.head.insertBefore(tag, query[j]); } } -*/ } } } diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e763c67c..cc97db5e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -41,9 +41,12 @@ exports.IoMediator = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - appTemplatesUrl: { + getAppTemplatesUrlRegEx: { enumerable: false, - value: new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi') + value: function () { + var regex = new RegExp(chrome.extension.getURL('js/document/templates/montage-html').replace(/\//gi, '\\\/'), 'gi'); + return regex; + } }, //////////////////////////////////////////////////////////////////// // @@ -211,36 +214,59 @@ exports.IoMediator = Montage.create(Component, { enumerable: false, value: function (template) { //Injecting head and body into old document - template.document.content.document.body.innerHTML = template.body; template.document.content.document.head.innerHTML = template.head; + template.document.content.document.body.innerHTML = template.body; //Getting all CSS (style or link) tags var styletags = template.document.content.document.getElementsByTagName('style'), - linktags = template.document.content.document.getElementsByTagName('link'); - //Looping through link tags and removing file recreated elements - for (var j in styletags) { - if (styletags[j].getAttribute) { - if(styletags[j].getAttribute('data-ninja-uri') !== null && !styletags[j].getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll - try { - //Checking head first - template.document.content.document.head.removeChild(styletags[j]); - } catch (e) { - try { - //Checking body if not in head - template.document.content.document.body.removeChild(styletags[j]); - } catch (e) { - //Error, not found! - } + linktags = template.document.content.document.getElementsByTagName('link'), + toremovetags = []; + //Getting styles tags to be removed from document + if (styletags.length) { + for (var j=0; j only | css =