aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/controllers/selection-controller.js12
-rwxr-xr-xjs/controllers/undo-controller.js17
-rwxr-xr-xjs/document/html-document.js201
-rw-r--r--js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js6
-rw-r--r--js/mediators/io-mediator.js167
6 files changed, 330 insertions, 82 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..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;
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 078a73b5..05c7d6c0 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -61,6 +61,27 @@ exports.HTMLDocument = Montage.create(TextDocument, {
61 _gridVerticalSpacing: {value:0}, 61 _gridVerticalSpacing: {value:0},
62 //end - drawUtils state 62 //end - drawUtils state
63 63
64 _undoStack: { value: [] },
65 undoStack: {
66 get: function() {
67 return this._undoStack;
68 },
69 set:function(value){
70 this._undoStack = value;
71 }
72 },
73
74 _redoStack: { value: [], enumerable: false },
75
76 redoStack: {
77 get: function() {
78 return this._redoStack;
79 },
80 set:function(value){
81 this._redoStack = value;
82 }
83 },
84
64 85
65 // GETTERS / SETTERS 86 // GETTERS / SETTERS
66 87
@@ -510,10 +531,69 @@ exports.HTMLDocument = Montage.create(TextDocument, {
510 // 531 //
511 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; 532 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
512 //Inserting user's document into template 533 //Inserting user's document into template
513 this._templateDocument.head.innerHTML = this._userDocument.content.head; 534
514 this._templateDocument.body.innerHTML = this._userDocument.content.body; 535
515 //TODO: Use querySelectorAll 536
516 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; 537
538
539
540
541
542
543 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
544 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
545 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
546
547 //TODO: Clean up and make public method to prepend properties with Ninja URL
548 this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this));
549 this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this));
550 //
551 //var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
552 //
553 function ninjaUrlRedirect (prop) {
554 //Checking for property value to not contain a full direct URL
555 if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) {
556 //Checking for attributes and type of source
557 if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { //From HTML attribute
558 //
559 prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this));
560 } else if (prop.indexOf('url') !== -1) { //From CSS property
561 //TODO: Add functionality
562 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
563 prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl);
564 function cssUrlToNinjaUrl (s) {
565 if (s !== 'url') {
566 s = docRootUrl + s;
567 }
568 return s;
569 }
570 }
571 }
572 return prop;
573 }
574 //
575 function ninjaUrlPrepend (url) {
576 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
577 if (url.indexOf('data:image') !== -1) {
578 return url;
579 } else {
580 return '"'+docRootUrl+url.replace(/\"/gi, '')+'"';
581 }
582 }
583 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
584 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
585 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
586
587