aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcss/ninja.css2
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/document/html-document.js97
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js10
-rw-r--r--js/mediators/io-mediator.js8
-rwxr-xr-xjs/panels/Panel.reel/Panel.html20
-rwxr-xr-xjs/panels/Panel.reel/Panel.js4
-rwxr-xr-xjs/panels/PanelContainer.reel/PanelContainer.js77
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js26
-rwxr-xr-xscss/imports/scss/_PanelUI.scss14
10 files changed, 224 insertions, 43 deletions
diff --git a/css/ninja.css b/css/ninja.css
index f139c3b9..8213ec26 100755
--- a/css/ninja.css
+++ b/css/ninja.css
@@ -655,6 +655,8 @@ body section .dragging { opacity: 0.4; }
655 655
656body .main .dragOver:not(.dragging) { background-color: #917B56; } 656body .main .dragOver:not(.dragging) { background-color: #917B56; }
657 657
658.panelDisabled { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 6000; color: white; text-align: center; line-height: 100px; box-shadow: inset 0 0 14px #111111; background: rgba(30, 30, 30, 0.8); }
659
658.menuBar { width: 100%; border-style: solid; border-width: 1px; height: 22px; color: white; background: #474747; border-color: black; } 660.menuBar { width: 100%; border-style: solid; border-width: 1px; height: 22px; color: white; background: #474747; border-color: black; }
659 661
660.menuBar ul { list-style: none; margin: 0; padding: 0; float: left; cursor: default; } 662.menuBar ul { list-style: none; margin: 0; padding: 0; float: left; cursor: default; }
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 194496a6..a8056519 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -336,14 +336,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
336 nextDocumentIndex = closeDocumentIndex - 1; 336 nextDocumentIndex = closeDocumentIndex - 1;
337 } 337 }
338 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 338 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
339 if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();}
339 this._removeDocumentView(doc.container); 340 this._removeDocumentView(doc.container);
340 }else if(this._documents.length === 0){ 341 }else if(this._documents.length === 0){
342 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){
343 this.activeDocument.pauseAndStopVideos();
344 }
341 this.activeDocument = null; 345 this.activeDocument = null;
342 this._removeDocumentView(doc.container); 346 this._removeDocumentView(doc.container);
343 this.application.ninja.stage.stageView.hideRulers(); 347 this.application.ninja.stage.stageView.hideRulers();
344 document.getElementById("iframeContainer").style.display="block"; 348 document.getElementById("iframeContainer").style.display="block";
345 349
346 this.application.ninja.stage.hideCanvas(true); 350 this.application.ninja.stage.hideCanvas(true);
351 }else{//closing inactive document tab - just clear DOM
352 if(typeof doc.pauseAndStopVideos !== "undefined"){
353 doc.pauseAndStopVideos();
354 }
355 this._removeDocumentView(doc.container);
347 } 356 }
348 357
349 NJevent("closeDocument", doc.uri); 358 NJevent("closeDocument", doc.uri);
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 80930af2..23b55e92 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -437,8 +437,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
437 } else if (prop.indexOf('url') !== -1) { //From CSS property 437 } else if (prop.indexOf('url') !== -1) { //From CSS property
438 //TODO: Add functionality 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, '/')); 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); 440 prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl);
441 function test (s) { 441 function cssUrlToNinjaUrl (s) {
442 if (s !== 'url') { 442 if (s !== 'url') {
443 s = docRootUrl + s; 443 s = docRootUrl + s;
444 } 444 }
@@ -451,9 +451,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
451 // 451 //
452 function ninjaUrlPrepend (url) { 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, '/')); 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, '')+'"'; 454 if (url.indexOf('data:image') !== -1) {
455 return url;
456 } else {
457 return '"'+docRootUrl+url.replace(/\"/gi, '')+'"';
458 }
455 } 459 }
456
457 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 460 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
458 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 461 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
459 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 462 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -570,8 +573,22 @@ exports.HTMLDocument = Montage.create(TextDocument, {
570 } 573 }
571 // 574 //
572 fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; 575 fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0];
573 prefixUrl = 'url('+fileCouldDirUrl; //This should be re-written with better RegEx 576
574 tag.innerHTML = cssData.content.replace(/url\(/gi, prefixUrl); 577 tag.innerHTML = cssData.content.replace(/url\(()(.+?)\1\)/g, detectUrl);
578
579 function detectUrl (prop) {
580 return prop.replace(/[^()\\""\\'']+/g, prefixUrl);;
581 }
582
583 function prefixUrl (url) {
584 if (url !== 'url') {
585 if (!url.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) {
586 url = fileCouldDirUrl+url;
587 }
588 }
589 return url;
590 }
591
575 //Looping through DOM to insert style tag at location of link element 592 //Looping through DOM to insert style tag at location of link element
576 query = this._templateDocument.html.querySelectorAll(['link']); 593 query = this._templateDocument.html.querySelectorAll(['link']);
577 for (var j in query) { 594 for (var j in query) {
@@ -600,12 +617,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
600 } 617 }
601 } 618 }
602 } 619 }
603
604
605
606
607 /* 620 /*
608//TODO: Figure out cross-domain XHR issue, might need cloud to handle 621
622 //TODO: Figure out cross-domain XHR issue, might need cloud to handle
609 var xhr = new XMLHttpRequest(); 623 var xhr = new XMLHttpRequest();
610 xhr.open("GET", this._document.styleSheets[i].href, true); 624 xhr.open("GET", this._document.styleSheets[i].href, true);
611 xhr.send(); 625 xhr.send();
@@ -613,20 +627,24 @@ exports.HTMLDocument = Montage.create(TextDocument, {
613 if (xhr.readyState === 4) { 627 if (xhr.readyState === 4) {
614 console.log(xhr); 628 console.log(xhr);
615 } 629 }
616*/
617 //tag.innerHTML = xhr.responseText //xhr.response; 630 //tag.innerHTML = xhr.responseText //xhr.response;
618 tag.innerHTML = 'noRULEjustHACK{background: #000}' 631 */
619 //Currently no external styles will load if unable to load via XHR request 632 //Temp rule so it's registered in the array
620 633 tag.innerHTML = 'noRULEjustHACK{background: #000}';
621 //Disabling external style sheets 634 //Disabling external style sheets
622 query = this._templateDocument.html.querySelectorAll(['link']); 635 query = this._templateDocument.html.querySelectorAll(['link']);
623 for (var k in query) { 636 for (var k in query) {
624 if (query[k].href === this._document.styleSheets[i].href) { 637 if (query[k].href === this._document.styleSheets[i].href) {
638
639 //TODO: Removed the temp insertion of the stylesheet
640 //because it wasn't the proper way to do it
641 //need to be handled via XHR with proxy in Cloud Sim
642
625 //Disabling style sheet to reload via inserting in style tag 643 //Disabling style sheet to reload via inserting in style tag
626 var tempCSS = query[k].cloneNode(true); 644 //var tempCSS = query[k].cloneNode(true);
627 tempCSS.setAttribute('data-ninja-template', 'true'); 645 //tempCSS.setAttribute('data-ninja-template', 'true');
628 query[k].setAttribute('disabled', 'true'); 646 query[k].setAttribute('disabled', 'true');
629 this.iframe.contentWindow.document.head.appendChild(tempCSS); 647 //this.iframe.contentWindow.document.head.appendChild(tempCSS);
630 //Inserting tag 648 //Inserting tag
631 this._templateDocument.head.insertBefore(tag, query[k]); 649 this._templateDocument.head.insertBefore(tag, query[k]);
632 } 650 }
@@ -824,6 +842,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
824 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 842 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
825 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 843 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
826 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start 844 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
845
846 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
847 this.pauseVideos();
827 } 848 }
828 }, 849 },
829 850
@@ -852,6 +873,44 @@ exports.HTMLDocument = Montage.create(TextDocument, {
852 873
853 874
854 } 875 }
855 } 876 },
856 //////////////////////////////////////////////////////////////////// 877 ////////////////////////////////////////////////////////////////////
878 /**
879 *pause videos on switching or closing the document, so that the browser does not keep downloading the media data
880 */
881 pauseVideos:{
882 value:function(){
883 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
884 for(i=0;i<videosArr.length;i++){
885 if(!videosArr[i].paused){
886 videosArr[i].pause();
887 }