diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 9 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 2 | ||||
-rwxr-xr-x | js/controllers/undo-controller.js | 17 | ||||
-rwxr-xr-x | js/document/html-document.js | 57 | ||||
-rw-r--r-- | js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js | 6 |
5 files changed, 71 insertions, 20 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/selection-controller.js b/js/controllers/selection-controller.js index c4623d3f..08eb018f 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -98,6 +98,8 @@ exports.SelectionController = Montage.create(Component, { | |||
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 | ||
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; | ||
217 | } | ||
205 | } | 218 | } |
206 | }); \ No newline at end of file | 219 | }); \ No newline at end of file |
diff --git a/js/document/html-document.js b/js/document/html-document.js index 5d507476..1691e3e4 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -59,6 +59,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
59 | _gridVerticalSpacing: {value:0}, | 59 | _gridVerticalSpacing: {value:0}, |
60 | //end - drawUtils state | 60 | //end - drawUtils state |
61 | 61 | ||
62 | _undoStack: { value: [] }, | ||
63 | undoStack: { | ||
64 | get: function() { | ||
65 | return this._undoStack; | ||
66 | }, | ||
67 | set:function(value){ | ||
68 | this._undoStack = value; | ||
69 | } | ||
70 | }, | ||
71 | |||
72 | _redoStack: { value: [], enumerable: false }, | ||
73 | |||
74 | redoStack: { | ||
75 | get: function() { | ||
76 | return this._redoStack; | ||
77 | }, | ||
78 | set:function(value){ | ||
79 | this._redoStack = value; | ||
80 | } | ||
81 | }, | ||
82 | |||
62 | 83 | ||
63 | // GETTERS / SETTERS | 84 | // GETTERS / SETTERS |
64 | 85 | ||
@@ -465,11 +486,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
465 | if(this._document.styleSheets[i].rules === null) { | 486 | if(this._document.styleSheets[i].rules === null) { |
466 | //TODO: Revisit URLs and URI creation logic, very hack right now | 487 | //TODO: Revisit URLs and URI creation logic, very hack right now |
467 | var fileUri, cssUrl, cssData, tag, query; | 488 | var fileUri, cssUrl, cssData, tag, query; |
468 | if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { | 489 | //TODO: Parse out relative URLs and map them to absolute |
490 | if (this._document.styleSheets[i].href.indexOf(chrome.extension.getURL('')) !== -1) { | ||
469 | //Getting the url of the CSS file | 491 | //Getting the url of the CSS file |
470 | cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; | 492 | cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1];//TODO: Parse out relative URLs and map them to absolute |
471 | //Creating the URI of the file (this is wrong should not be splitting cssUrl) | 493 | //Creating the URI of the file (this is wrong should not be splitting cssUrl) |
472 | fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl.split('/')[1]; | 494 | fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl; |
473 | //Loading the data from the file | 495 | //Loading the data from the file |
474 | cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); | 496 | cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); |
475 | //Creating tag with file content | 497 | //Creating tag with file content |
@@ -485,6 +507,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
485 | tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); | 507 | tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); |
486 | } | 508 | } |
487 | } | 509 | } |
510 | //TODO: Parse out relative URLs and map them to absolute | ||
511 | //console.log(cssData.content); | ||
488 | tag.innerHTML = cssData.content; | 512 | tag.innerHTML = cssData.content; |
489 | //Looping through DOM to insert style tag at location of link element | 513 | //Looping through DOM to insert style tag at location of link element |
490 | query = this._templateDocument.html.querySelectorAll(['link']); | 514 | query = this._templateDocument.html.querySelectorAll(['link']); |
@@ -715,6 +739,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
715 | } | 739 | } |
716 | 740 | ||
717 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | 741 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; |
742 | |||
743 | //persist a clone of history per document | ||
744 | this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); | ||
745 | this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); | ||
746 | this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start | ||
718 | } | 747 | } |
719 | }, | 748 | }, |
720 | 749 | ||
@@ -724,20 +753,24 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
724 | value: function () { | 753 | value: function () { |
725 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | 754 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; |
726 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | 755 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; |
727 | 756 | ||
728 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ | 757 | if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ |
729 | this.application.ninja.selectedElements = this.selectionModel.slice(0); | ||
730 | } | ||
731 | |||
732 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ | ||
733 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; | 758 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; |
734 | this.application.ninja.stage._scrollLeft = this.savedLeftScroll; | ||
735 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; | 759 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; |
736 | this.application.ninja.stage._scrollLeft = this.savedTopScroll; | 760 | this.application.ninja.stage.handleScroll(); |
761 | } | ||
762 | |||
763 | this.application.ninja.currentSelectedContainer = this.documentRoot; | ||
764 | if(this.selectionModel){ | ||
765 | this.application.ninja.selectedElements = this.selectionModel.slice(0); | ||
737 | } | 766 | } |
738 | this.application.ninja.stage.handleScroll(); | ||
739 | 767 | ||
740 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | 768 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; |
769 | |||
770 | this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); | ||
771 | this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); | ||
772 | |||
773 | |||
741 | } | 774 | } |
742 | } | 775 | } |
743 | //////////////////////////////////////////////////////////////////// | 776 | //////////////////////////////////////////////////////////////////// |
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, { | |||
861 | var dataStore = window.sessionStorage; | 861 | var dataStore = window.sessionStorage; |
862 | try { | 862 | try { |