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.js2
-rwxr-xr-xjs/controllers/undo-controller.js17
-rwxr-xr-xjs/document/html-document.js181
-rw-r--r--js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js6
-rw-r--r--js/mediators/io-mediator.js163
6 files changed, 302 insertions, 76 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..3f39c4df 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
@@ -387,10 +408,66 @@ exports.HTMLDocument = Montage.create(TextDocument, {
387 // 408 //
388 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; 409 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
389 //Inserting user's document into template 410 //Inserting user's document into template
390 this._templateDocument.head.innerHTML = this._userDocument.content.head; 411
391 this._templateDocument.body.innerHTML = this._userDocument.content.body; 412
392 //TODO: Use querySelectorAll 413
393 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; 414
415
416
417
418
419
420 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
421 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
422 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
423
424 //TODO: Clean up and make public method to prepend properties with Ninja URL
425 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));
426 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));
427 //
428 //var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
429 //
430 function ninjaUrlRedirect (prop) {
431 //Checking for property value to not contain a full direct URL
432 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)) {
433 //Checking for attributes and type of source
434 if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { //From HTML attribute
435 //
436 prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this));
437 } else if (prop.indexOf('url') !== -1) { //From CSS property
438 //TODO: Add functionality
439 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
440 prop = prop.replace(/[^()\\""\\'']+/g, test);
441 function test (s) {
442 if (s !== 'url') {
443 s = docRootUrl + s;
444 }
445 return s;
446 }
447 }
448 }
449 return prop;
450 }
451 //
452 function ninjaUrlPrepend (url) {
453 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
454 return '"'+docRootUrl+url.replace(/\"/gi, '')+'"';
455 }
456
457 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
458 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
459 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
460
461
462
463
464
465
466
467
468
469
470 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; //TODO: Use querySelectorAll
394 // 471 //
395 for (var w in scripttags) { 472 for (var w in scripttags) {
396 if (scripttags[w].getAttribute) { 473 if (scripttags[w].getAttribute) {
@@ -464,16 +541,18 @@ exports.HTMLDocument = Montage.create(TextDocument, {
464 //If rules are null, assuming cross-origin issue 541 //If rules are null, assuming cross-origin issue
465 if(this._document.styleSheets[i].rules === null) { 542 if(this._document.styleSheets[i].rules === null) {
466 //TODO: Revisit URLs and URI creation logic, very hack right now 543 //TODO: Revisit URLs and URI creation logic, very hack right now
467 var fileUri, cssUrl, cssData, tag, query; 544 var fileUri, cssUrl, cssData, query, prefixUrl, fileCouldDirUrl, docRootUrl;
468 if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { 545 //
469 //Getting the url of the CSS file 546 docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
470 cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; 547 //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) 548 if (this._document.styleSheets[i].href.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) {
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]; 549 //
473 //Loading the d