From ac750fd9b9c311dcd48c6ee309607edc6fa048e1 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Wed, 16 May 2012 14:22:18 -0700
Subject: Adding basic montage components I/O
Only for saving basic components without a reel.
---
js/document/models/base.js | 6 +-
js/document/templates/html/main.js | 2 +-
js/mediators/io-mediator.js | 72 ++++++++++++++++++----
.../components-panel.reel/components-panel.js | 6 +-
4 files changed, 67 insertions(+), 19 deletions(-)
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 033e16f6..649539ea 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -149,7 +149,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
template: this.fileTemplate,
document: this.views.design.iframe.contentWindow.document,
head: this.views.design.iframe.contentWindow.document.head,
- body: this.views.design.iframe.contentWindow.document.body
+ body: this.views.design.iframe.contentWindow.document.body,
+ mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
}, callback.bind(this));
} else {
//TODO: Add logic to save code view data
@@ -177,7 +178,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
template: this.fileTemplate,
document: this.views.design.iframe.contentWindow.document,
head: this.views.design.iframe.contentWindow.document.head,
- body: this.views.design.iframe.contentWindow.document.body
+ body: this.views.design.iframe.contentWindow.document.body,
+ mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
}, callback.bind(this));
} else {
//TODO: Add logic to save code view data
diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js
index f45657bb..2696dfa0 100644
--- a/js/document/templates/html/main.js
+++ b/js/document/templates/html/main.js
@@ -42,7 +42,7 @@ exports.Main = Montage.create(Component, {
//
window.mjsTemplateCreator = TemplateCreator.create();
//
- window.mjsTemplate = Template.create();
+ window.mjsTemplate = Template.create();
// Dispatch event when this template has loaded.
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index e6f2cc2d..6cdf70fe 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -219,11 +219,24 @@ exports.IoMediator = Montage.create(Component, {
parseNinjaTemplateToHtml: {
enumerable: false,
value: function (template, ninjaWrapper) {
- var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]));
+ //TODO: Improve reference for rootUrl
+ var regexRootUrl,
+ rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])),
+ montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document),
+ mJsSerialization;
+ //Setting up expression for parsing URLs
regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi');
//Injecting head and body into old document
- template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, '');
- template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, '');
+ if (montageTemplate._ownerSerialization.length > 0) {
+ template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, '');
+ template.file.content.document.body.innerHTML = montageTemplate._document.body.innerHTML.replace(regexRootUrl, '');
+ //
+ mJsSerialization = montageTemplate._ownerSerialization;
+ } else {
+ template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, '');
+ template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, '');
+ }
+
//Copying attributes to maintain same properties as the
for (var n in template.body.attributes) {
if (template.body.attributes[n].value) {
@@ -233,15 +246,6 @@ exports.IoMediator = Montage.create(Component, {
}
//TODO: Add attribute copying for and
- /*
- var tc = this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator, code;
- code = tc.initWithDocument(this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.document);
- console.log(code._ownerSerialization, code._document.getElementsByTagName('html')[0].innerHTML);
-
- template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, '');
- template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, '');
- */
-
@@ -521,7 +525,49 @@ function loadWebGL (e) {\n\
-
+
+ //Checking for Montage
+ if (mJsSerialization) {
+ //Copy Montage library if needed
+ for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) {
+ //Checking for Montage library to be available
+ if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') {
+ mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
+ mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
+ this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName);
+ //TODO: Fix to allow no overwrite and nested locations
+ var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' });
+ } else {
+ //TODO: Error handle no available library to copy
+ }
+ }
+ //
+ if (!mjslibtag) {
+ mjslibtag = template.file.content.document.createElement('script');
+ mjslibtag.setAttribute('type', 'text/javascript');
+ mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js');
+ mjslibtag.setAttribute('data-mjs-lib', 'true');
+ if (ninjaWrapper) {
+ template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag);
+ } else {
+ template.file.content.document.head.appendChild(mjslibtag);
+ }
+
+ }
+ //
+ if (!mjstag) {
+ mjstag = template.file.content.document.createElement('script');
+ mjstag.setAttribute('type', 'text/montage-serialization');
+ if (ninjaWrapper) {
+ template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjstag);
+ } else {
+ template.file.content.document.head.appendChild(mjstag);
+ }
+
+ }
+ //
+ mjstag.innerHTML = mJsSerialization;
+ }
//
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js
index 53049cad..fdf744d2 100755
--- a/js/panels/components-panel.reel/components-panel.js
+++ b/js/panels/components-panel.reel/components-panel.js
@@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component,
- ClassUUID = require("js/components/core/class-uuid").ClassUuid;
-
-var PIData = require("js/data/pi/pi-data").PiData;
+ NJUtils = require("js/lib/NJUtils").NJUtils;
+ ClassUUID = require("js/components/core/class-uuid").ClassUuid,
+ PIData = require("js/data/pi/pi-data").PiData;
String.prototype.capitalizeFirstChar = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
--
cgit v1.2.3
From a2afa558aba65b81f8b1b58687629def14ea471d Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Wed, 16 May 2012 14:37:32 -0700
Subject: Fixing reference to serialization tag
---
js/mediators/io-mediator.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 6cdf70fe..7f7bd72a 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -433,7 +433,7 @@ exports.IoMediator = Montage.create(Component, {
if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) {
webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags
}
- if (scripts[i].getAttribute('type') !== 'text/montage-serialization') {
+ if (scripts[i].getAttribute('type') === 'text/montage-serialization') {
mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags
}
if (scripts[i].getAttribute('data-mjs-lib') !== null) {
--
cgit v1.2.3
From 5cc5d29736d8bf253e3a168cdd6443e839ffb23c Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Wed, 16 May 2012 15:42:09 -0700
Subject: Fixing serialization referencing (new object per save)
---
js/document/templates/html/main.js | 4 +--
js/mediators/io-mediator.js | 60 ++++----------------------------------
2 files changed, 8 insertions(+), 56 deletions(-)
diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js
index 2696dfa0..ffa3fab2 100644
--- a/js/document/templates/html/main.js
+++ b/js/document/templates/html/main.js
@@ -40,9 +40,9 @@ exports.Main = Montage.create(Component, {
};
//
- window.mjsTemplateCreator = TemplateCreator.create();
+ window.mjsTemplateCreator = TemplateCreator;
//
- window.mjsTemplate = Template.create();
+ window.mjsTemplate = Template;
// Dispatch event when this template has loaded.
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 7f7bd72a..b1916446 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -222,8 +222,11 @@ exports.IoMediator = Montage.create(Component, {
//TODO: Improve reference for rootUrl
var regexRootUrl,
rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])),
- montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document),
- mJsSerialization;
+ mjsCreator = template.mjsTemplateCreator.create(),
+ mJsSerialization,
+ montageTemplate;
+ //
+ montageTemplate = mjsCreator.initWithDocument(template.document);
//Setting up expression for parsing URLs
regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi');
//Injecting head and body into old document
@@ -567,58 +570,8 @@ function loadWebGL (e) {\n\
}
//
mjstag.innerHTML = mJsSerialization;
+ mjsCreator = null;
}
-
-
- //
-
- /*
-for (var m in template.mjs) {
- mjsComponents.push(template.mjs[m]);
- mjsCounter++;
- }
- //
- if (template.mjs && mjsCounter > 0) {
- var mjsDirName, mjsVersion,
- mjscode = temp.initWithHeadAndBodyElements(template.file.content.document.documentElement.head, template.file.content.document.documentElement.body, mjsComponents)._ownerSerialization;
- //Copy Montage library if needed
- for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) {
- //Checking for Montage library to be available
- if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') {
- mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
- mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
- this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName);
- //TODO: Fix to allow no overwrite and nested locations
- var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' });
- } else {
- //TODO: Error handle no available library to copy
- }
- }
- //
- if (!mjslibtag) {
- mjslibtag = template.file.content.document.createElement('script');
- mjslibtag.setAttribute('type', 'text/javascript');
- mjslibtag.setAttribute('src', mjsDirName + '/montage.js');
- mjslibtag.setAttribute('data-mjs-lib', 'true');
- template.file.content.document.head.appendChild(mjslibtag);
- }
- //
- if (!mjstag) {
- mjstag = template.file.content.document.createElement('script');
- mjstag.setAttribute('type', 'text/montage-serialization');
- template.file.content.document.head.appendChild(mjstag);
- }
- //
- mjstag.innerHTML = mjscode;
- }
-*/
-
-
-
-
-
-
-
//Cleaning URLs from HTML
var cleanHTML;
if (ninjaWrapper) {
@@ -639,7 +592,6 @@ for (var m in template.mjs) {
cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div');
cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div');
}
-
//
return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), ''));
}
--
cgit v1.2.3
From f48bb7aa60a5eb1f9319ddd0334bd7a0afa2aca4 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Wed, 16 May 2012 20:33:44 -0700
Subject: Timeline should not select an element when a layer is selected by
code.
Signed-off-by: Valerio Virgillito
---
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 94ca9b57..c382c9a7 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -110,7 +110,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
this._selectedLayerID = newVal;
this._captureSelection = true;
if (this.currentLayerSelected !== false) {
- this.selectLayer(selectIndex, true);
+ this.selectLayer(selectIndex, false);
}
if (this.currentLayersSelected !== false) {
this.selectLayers(this.currentLayersSelected);
--
cgit v1.2.3
From b1e5ef1949eeddc39a1e9570a65612879cbdadef Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Wed, 16 May 2012 20:49:40 -0700
Subject: clearing the needs save flag on save.
Signed-off-by: Valerio Virgillito
---
js/controllers/document-controller.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1e894f02..ecb988ff 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -177,6 +177,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
testCallback: {
value: function (value) {
console.log(value);
+ //TODO: Move this to the model.save()
+ this.activeDocument.model.needsSave = false;
}
},
////////////////////////////////////////////////////////////////////
--
cgit v1.2.3
From c26de5fa7b909a53b103b72027b5cbe7c3e1c49f Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Wed, 16 May 2012 22:48:39 -0700
Subject: code cleanup and refactoring of the document controller and stage
view
Signed-off-by: Valerio Virgillito
---
js/controllers/document-controller.js | 194 ++++++++++-----------------------
js/data/menu-data.js | 4 +-
js/stage/stage-view.reel/stage-view.js | 33 +-----
3 files changed, 59 insertions(+), 172 deletions(-)
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index ecb988ff..1796f9b5 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -21,10 +21,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
value: false
},
- webTemplate: {
- value: false
- },
-
_documents: {
value: []
},
@@ -75,10 +71,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
this.eventManager.addEventListener("executeFileCloseAll", this, false);
this.eventManager.addEventListener("styleSheetDirty", this, false);
-
- // Temporary add listeners for the new stage templates
- this.eventManager.addEventListener("executeWebpageOpen", this, false);
- this.eventManager.addEventListener("executeNewWebpage", this, false);
}
},
@@ -138,20 +130,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- handleExecuteWebpageOpen: {
- value: function(event) {
- this.webTemplate = true;
- this.handleExecuteFileOpen(event);
- }
- },
-
- handleExecuteNewWebpage: {
- value: function(event) {
- this.webTemplate = true;
- this.handleExecuteNewFile(event);
- }
- },
-
handleExecuteNewFile: {
value: function(event) {
var newFileSettings = event._event.settings || {};
@@ -304,12 +282,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
this.isNewFilePath = false;//reset path identifier flag
//Sending full response object
- // TODO: Unify those 2 methods. Using if/else for the new template
- if(this.webTemplate) {
- this.openWebDocument(response);
- } else {
- this.openDocument(response);
- }
+ this.openDocument(response);
+
} else if (!!response && (response.status === 404)){
alert("Unable to open file.\n [Error: File does not exist]");
} else if (!!response && (response.status === 500)){
@@ -345,30 +319,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
},
////////////////////////////////////////////////////////////////////
- openDocument: {
- value: function(doc) {
-
- //
- this.documentHackReference = doc;
- //
- switch (doc.extension) {
- case 'html':
- //Open in designer view
- Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this));
- break;
- default:
- //Open in code view
- var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea;
- textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid);
- code.initialize(doc, docuuid, textArea, textArea.parentNode);
- //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
- code.textArea.value = doc.content;
- this.application.ninja.stage.stageView.createTextView(code);
- break;
- }
- }
- },
- openWebDocument: {
+ openDocument: {
value: function(doc) {
var template, dimensions;
if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) {
@@ -484,14 +435,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
- this._removeDocumentView(doc.container);
+ doc.container.parentNode.removeChild(doc.container);
}else if(this._documents.length === 0){
// See above
}else{//closing inactive document tab - just clear DOM
if(typeof doc.pauseAndStopVideos !== "undefined"){
doc.pauseAndStopVideos();
}
- this._removeDocumentView(doc.container);
+ doc.container.parentNode.removeChild(doc.container);
}
NJevent("closeDocument", doc.uri);
@@ -500,41 +451,65 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- // Document has been loaded into the Iframe. Dispatch the event.
- // Event Detail: Contains the current ActiveDocument
+ // Open document callback
_onOpenDocument: {
value: function(doc){
- this.application.ninja.currentDocument = doc;
- this._hideCurrentDocument();
- this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid);
- this.application.ninja.stage.hideCanvas(false);
+ if(this.activeDocument) {
+ // There is a document currently opened
- this.activeDocument = doc;
+// this.application.ninja.stage.stageView.showCodeViewBar(false);
+// this.application.ninja.stage.stageView.restoreAllPanels();
- if(!this.webTemplate) {
- this._showCurrentDocument();
+ //
+ /*
+ if(this.activeDocument.currentView === "design"){
+ this.activeDocument.saveAppState();
+ this.activeDocument.container.parentNode.style["display"] = "none";
+ this.application.ninja.stage.hideCanvas(true);
+ this.application.ninja.stage.stageView.hideRulers();
+ }
+
+ this.activeDocument.container.style["display"] = "none";
+ */
+ // hide current document
} else {
- this.application.ninja.stage.stageView.showRulers();
- }
+ // There is no document opened
- this.webTemplate = false;
+ // Set the active document
+ this.activeDocument = doc;
- this._initializeBodyStyles();
- NJevent("onOpenDocument", doc);
+ // Show the canvas
+ this.application.ninja.stage.hideCanvas(false);
+
+ // Show the rulers
+ // TODO: Move this indo design view
+ this.application.ninja.stage.stageView.showRulers();
- this.application.ninja.stage.stageView.showCodeViewBar(false);
- this.application.ninja.stage.stageView.restoreAllPanels();
+ // Initialize the documentRoot styles
+ this.initializeRootStyles(doc.documentRoot);
+ // Flag to stop stylesheet dirty event
+ this._hackInitialStyles = false;
- // Flag to stop stylesheet dirty event
- this._hackInitialStyles = false;
+ NJevent("onOpenDocument", doc);
+ }
}
},
_onOpenTextDocument: {
value: function(doc) {
- this._hideCurrentDocument();
+ if(this.activeDocument) {
+ if(this.activeDocument.currentView === "design"){
+ this.activeDocument.saveAppState();
+ this.activeDocument.container.parentNode.style["display"] = "none";
+ this.application.ninja.stage.hideCanvas(true);
+ this.application.ninja.stage.stageView.hideRulers();
+ }
+
+ this.activeDocument.container.style["display"] = "none";
+ }
+
this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
this.activeDocument = doc;
@@ -589,21 +564,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- _hideCurrentDocument: {
- value: function() {
- if(this.activeDocument) {
- if(this.activeDocument.currentView === "design"){
- this.activeDocument.saveAppState();
- this.activeDocument.container.parentNode.style["display"] = "none";
- this.application.ninja.stage.hideCanvas(true);
- this.application.ninja.stage.stageView.hideRulers();
- }
-
- this.activeDocument.container.style["display"] = "none";
- }
- }
- },
-
_showCurrentDocument: {
value: function() {
if(this.activeDocument) {
@@ -611,8 +571,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
if(this.activeDocument.currentView === "design"){
this.activeDocument.container.parentNode.style["display"] = "block";
this.activeDocument.restoreAppState();
- this.application.ninja.stage.hideCanvas(false);
- this.application.ninja.stage.stageView.showRulers();
}else{
//hide the iframe when switching to code view
document.getElementById("iframeContainer").style.display = "none";
@@ -621,46 +579,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- _removeDocumentView: {
- value: function(node) {
- node.parentNode.removeChild(node);
- }
- },
-
- reloadDocumentContent: {
- value: function() {
- this.activeDocument._window.location.reload();
- }
- },
-
- /**
- * Creates a new iFrame element using a new unique ID for it. Returns the iframe ID.
- */
- _createIframeElement: {
- value: function() {
- var e = document.createElement("iframe");
- e.id = this._createIframeID();
- e.style.border = "none";
- e.style.opacity = 0;
- e.height = 1000;
- e.width = 2000;
- e.src = "";
-
- if(!this._iframeHolder) this._iframeHolder = document.getElementById("iframeContainer");
-
- this._iframeHolder.appendChild(e);
-
- return e;
- }
- },
-
-
- _createIframeID: {
- value: function() {
- return "userDocument_" + (this._iframeCounter++);
- }
- },
-
handleStyleSheetDirty:{
value:function(){
if(!this._hackInitialStyles) {
@@ -669,27 +587,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- _initializeBodyStyles: {
- value: function() {
+ // TODO: Move this into the design views
+ initializeRootStyles: {
+ value: function(documentRoot) {
var sc = this.application.ninja.stylesController,
- docRoot = this.application.ninja.currentDocument.documentRoot,
styles = {},
needsRule = false,
rule;
- if(sc.getElementStyle(docRoot, "width", false, false) == null) {
+ if(sc.getElementStyle(documentRoot, "width", false, false) == null) {
styles['width'] = '100%';
needsRule = true;
}
- if(sc.getElementStyle(docRoot, "height", false, false) == null) {
+ if(sc.getElementStyle(documentRoot, "height", false, false) == null) {
styles['height'] = '100%';
needsRule = true;
}
- if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) {
+ if(sc.getElementStyle(documentRoot, "-webkit-transform", false, false) == null) {
styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
needsRule = true;
}
- if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) {
+ if(sc.getElementStyle(documentRoot, "-webkit-transform-style", false, false) == null) {
styles['-webkit-transform-style'] = 'preserve-3d';
needsRule = true;
}
@@ -697,7 +615,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
if(needsRule) {
rule = sc.addRule('.ninja-body{}');
sc.setStyles(rule, styles);
- sc.addClass(docRoot, "ninja-body");
+ sc.addClass(documentRoot, "ninja-body");
}
}
}
diff --git a/js/data/menu-data.js b/js/data/menu-data.js
index 7cf40a8a..aeb95ccc 100755
--- a/js/data/menu-data.js
+++ b/js/data/menu-data.js
@@ -22,13 +22,13 @@ exports.MenuData = Montage.create( Montage, {
"displayText" : "New File",
"hasSubMenu" : false,
"enabled": true,
- "action": "executeNewWebpage"
+ "action": "executeNewFile"
},
{
"displayText" : "Open File",
"hasSubMenu" : false,
"enabled": true,
- "action": "executeWebpageOpen"
+ "action": "executeFileOpen"
},
{
"displayText" : "Close File",
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js
index 518c3bdd..7680103d 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -25,32 +25,12 @@ exports.StageView = Montage.create(Component, {
}
},
- templateDidLoad: {
- value: function() {
- this.eventManager.addEventListener("appLoaded", this, false);
- }
- },
-
didDraw:{
value: function() {
if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element;
}
},
- handleAppLoaded: {
- value: function() {
-
- // Don't bind for now
- /*
- Object.defineBinding(this, "docs", {
- boundObject: this.application.ninja.documentController,
- boundObjectPropertyPath: "_documents"
- });
- */
-
- }
- },
-
/**
* Public method
* Creates a textarea element which will contain the content of the opened text document.
@@ -172,17 +152,6 @@ exports.StageView = Montage.create(Component, {
}
},
- hideOtherDocuments:{
- value:function(docUuid){
- this.application.ninja.documentController._documents.forEach(function(aDoc){
- if(aDoc.currentView === "design"){
- aDoc.container.parentNode.style["display"] = "none";
- }else if((aDoc.currentView === "code") && (aDoc.uuid !== docUuid)){
- aDoc.container.style["display"] = "none";
- }
- }, this);
- }
- },
showRulers:{
value:function(){
this.application.ninja.rulerTop.style.display = "block";
@@ -200,7 +169,7 @@ exports.StageView = Montage.create(Component, {
if(isCodeView === true) {
this.application.ninja.editorViewOptions.element.style.display = "block";
this.application.ninja.documentBar.element.style.display = "none";
- }else{
+ } else {
this.application.ninja.documentBar.element.style.display = "block";
this.application.ninja.editorViewOptions.element.style.display = "none";
}
--
cgit v1.2.3
From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Wed, 16 May 2012 23:19:32 -0700
Subject: document controller and stage view code cleanup
Signed-off-by: Valerio Virgillito
---
js/controllers/document-controller.js | 33 ++++++++++++++++-----------------
js/document/document-html.js | 21 ++++++++++++++++++---
js/document/html-document.js | 26 --------------------------
js/document/models/html.js | 5 +++++
js/stage/stage-view.reel/stage-view.js | 17 ++++++++++++++++-
5 files changed, 55 insertions(+), 47 deletions(-)
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1796f9b5..cf46e73e 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -458,8 +458,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
if(this.activeDocument) {
// There is a document currently opened
-// this.application.ninja.stage.stageView.showCodeViewBar(false);
-// this.application.ninja.stage.stageView.restoreAllPanels();
+
+
+ //this.application.ninja.stage.stageView.showCodeViewBar(false);
+ //this.application.ninja.stage.stageView.restoreAllPanels();
//
/*
@@ -472,6 +474,18 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
this.activeDocument.container.style["display"] = "none";
*/
+
+ /*
+ this.activeDocument.container.style["display"] = "block";
+ if(this.activeDocument.currentView === "design"){
+ this.activeDocument.container.parentNode.style["display"] = "block";
+ this.activeDocument.restoreAppState();
+ }else{
+ //hide the iframe when switching to code view
+ document.getElementById("iframeContainer").style.display = "none";
+ }
+
+ */
// hide current document
} else {
// There is no document opened
@@ -564,21 +578,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
}
},
- _showCurrentDocument: {
- value: function() {
- if(this.activeDocument) {
- this.activeDocument.container.style["display"] = "block";
- if(this.activeDocument.currentView === "design"){
- this.activeDocument.container.parentNode.style["display"] = "block";
- this.activeDocument.restoreAppState();
- }else{
- //hide the iframe when switching to code view
- document.getElementById("iframeContainer").style.display = "none";
- }
- }
- }
- },
-
handleStyleSheetDirty:{
value:function(){
if(!this._hackInitialStyles) {
diff --git a/js/document/document-html.js b/js/document/document-html.js
index a26b74d5..56d9db02 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -134,14 +134,29 @@ exports.HtmlDocument = Montage.create(Component, {
},
////////////////////////////////////////////////////////////////////
//
- saveAppState: {
+ serializeDocument: {
value: function () {
- //TODO: Import functionality
+ // There are not needed for now ssince we cannot change them
+ //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
+ //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
+
+ // Serialize the current scroll position
+ // TODO: Implement
+
+ // Serialize the selection
+ this.model.selection = this.application.ninja.selectedElements.slice(0);
+ this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
+
+ // Serialize the undo
+ // TODO: Save the montage undo queue
+
+ // Pause the videos
+ this.model.views.design.pauseVideos();
}
},
////////////////////////////////////////////////////////////////////
//
- restoreAppState: {
+ deserializeDocument: {
value: function () {
//TODO: Import functionality
}
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 6a84abdf..68c2a9fb 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -920,32 +920,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
}
},
- ////////////////////////////////////////////////////////////////////
- saveAppState:{
- enumerable: false,
- value: function () {
-
- this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft;
- this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop;
-
- this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
- this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
-
- if(typeof this.application.ninja.selectedElements !== 'undefined'){
- this.selectionModel = this.application.ninja.selectedElements.slice(0);
- }
-
- this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
-
- //persist a clone of history per document
- this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
- this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
- this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
-
- //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
- this.pauseVideos();
- }
- },
////////////////////////////////////////////////////////////////////
restoreAppState:{
diff --git a/js/document/models/html.js b/js/document/models/html.js
index b57ff832..67457863 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -16,6 +16,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
//
hasTemplate: {
value: false
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ selection: {
+ value: []
},
////////////////////////////////////////////////////////////////////
//
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js
index 7680103d..ba94fadf 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -120,7 +120,22 @@ exports.StageView = Montage.create(Component, {
}
this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
- this.application.ninja.documentController._showCurrentDocument();
+
+
+// this.application.ninja.documentController._showCurrentDocument();
+ // Inline function below
+ if(this.activeDocument) {
+ this.activeDocument.container.style["display"] = "block";
+ if(this.activeDocument.currentView === "design"){
+ this.activeDocument.container.parentNode.style["display"] = "block";
+ this.activeDocument.restoreAppState();
+ } else {
+ //hide the iframe when switching to code view
+ document.getElementById("iframeContainer").style.display = "none";
+ }
+ }
+
+
//focus editor
if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){
this.application.ninja.documentController.activeDocument.editor.focus();
--
cgit v1.2.3
From 65cea92d839bcd25ea9094a0798190a4dc4bea35 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Thu, 17 May 2012 00:16:43 -0700
Subject: Adding a disabled property to the label-checkbox.
Signed-off-by: Valerio Virgillito
---
.../ui/label-checkbox.reel/label-checkbox.js | 22 +++++++++++++++++++++-
.../properties.reel/sections/custom.reel/custom.js | 8 ++++----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.js b/js/components/ui/label-checkbox.reel/label-checkbox.js
index 82c01262..21b72cb5 100755
--- a/js/components/ui/label-checkbox.reel/label-checkbox.js
+++ b/js/components/ui/label-checkbox.reel/label-checkbox.js
@@ -42,6 +42,25 @@ exports.LabelCheckbox = Montage.create(Component, {
}
},
+ _enabled: {
+ enumerable: false,
+ value: true
+ },
+
+ enabled: {
+ enumerable: true,
+ serializable: true,
+ get: function() {
+ return this._enabled;
+ },
+ set: function(value) {
+ if(value !== this._enabled) {
+ this._enabled = value;
+ this.needsDraw = true;
+ }
+ }
+ },
+
value: {
value: false
},
@@ -52,7 +71,7 @@ exports.LabelCheckbox = Montage.create(Component, {
e.initEvent("change", true, true);
e.type = "change";
e.wasSetByCode = false;
- this.value = e.value = this._checkbox.checked;
+ this.checked = this.value = e.value = this._checkbox.checked;
this.dispatchEvent(e);
}
},
@@ -61,6 +80,7 @@ exports.LabelCheckbox = Montage.create(Component, {
value: function() {
this._labelText.value = this.label;
this._checkbox.checked = this.checked;
+ this._checkbox.disabled = !this._enabled;
}
}
diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js
index 3ab32888..49b4414e 100755
--- a/js/panels/properties.reel/sections/custom.reel/custom.js
+++ b/js/panels/properties.reel/sections/custom.reel/custom.js
@@ -262,10 +262,10 @@ exports.CustomSection = Montage.create(Component, {
if(aField.enabled.boundObject) {
// TODO - For now, always bind to this.controls[someProperty]
Object.defineBinding(obj, "enabled", {
- boundObject: this.controls,
- boundObjectPropertyPath: aField.enabled.boundProperty,
- oneway: false
- });
+ boundObject: this.controls,
+ boundObjectPropertyPath: aField.enabled.boundProperty,
+ oneway: false
+ });
} else {
obj.enabled = aField.enabled;
}
--
cgit v1.2.3