From a42c536c2b3209afc058eabd31167bd0aa6f71c8 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 13:40:38 -0800 Subject: Adding webRequest redirects for iFrame templates --- js/controllers/document-controller.js | 20 ++++++++++++++------ js/document/html-document.js | 5 +++-- js/document/text-document.js | 5 +++-- js/io/ui/cloudpopup.reel/cloudpopup.html | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 9785d824..5e2a6461 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -14,7 +14,7 @@ var Montage = require("montage/core/core").Montage, DocumentController; //////////////////////////////////////////////////////////////////////// // -DocumentController = exports.DocumentController = Montage.create(Component, { +var DocumentController = exports.DocumentController = Montage.create(Component, { hasTemplate: { value: false }, @@ -22,6 +22,10 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _documents: { value: [] }, + + _hackRootFlag: { + value: false + }, _activeDocument: { value: null }, _iframeCounter: { value: 1, enumerable: false }, @@ -71,11 +75,13 @@ DocumentController = exports.DocumentController = Montage.create(Component, { //TODO: Figure out why active document is not available here - /* -if (request.url.indexOf('calculator.css') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+'/calculator/components/calculator.reel/calculator.css'}; + if (this._hackRootFlag) { + + //console.log(request.url.split('/')[request.url.split('/').length-1]); + //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.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('/')[request.url.split('/').length-1]}; } -*/ } } }, @@ -205,6 +211,9 @@ if (request.url.indexOf('calculator.css') !== -1) { // openDocument: { value: function(doc) { + + // + this.documentHackReference = doc; // switch (doc.extension) { case 'html': case 'html': @@ -302,7 +311,6 @@ if (request.url.indexOf('calculator.css') !== -1) { _onOpenDocument: { value: function(doc){ //var data = DocumentManager.activeDocument; - this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); diff --git a/js/document/html-document.js b/js/document/html-document.js index 16595d14..ae2b4600 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -235,7 +235,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { // initialize: { value: function(file, uuid, iframe, callback) { - //console.log('allow'); + this.application.ninja.documentController._hackRootFlag = false; // this._userDocument = file; // @@ -363,7 +363,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { // handleEvent: { value: function(event){ - + this.application.ninja.documentController._hackRootFlag = true; + //console.log(this._userDocument.root, this); //TODO: Clean up, using for prototyping save this._templateDocument = {}; this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");; diff --git a/js/document/text-document.js b/js/document/text-document.js index 6f8efaad..3e20e1f6 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -6,9 +6,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //BaseDocument Object for all files types and base class for HTML documents. -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; -var TextDocument = exports.TextDocument = Montage.create(Montage, { +var TextDocument = exports.TextDocument = Montage.create(Component, { //TODO: Clean up, test diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.html b/js/io/ui/cloudpopup.reel/cloudpopup.html index 2c1c169a..e58041ec 100755 --- a/js/io/ui/cloudpopup.reel/cloudpopup.html +++ b/js/io/ui/cloudpopup.reel/cloudpopup.html @@ -36,7 +36,7 @@
Connection to the Cloud Server was not detected. Please verify
that the server is running and the URL below is correct.