From 3811f72f8cd8caaa2d13fa695b918f25facb85c5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 9 May 2012 16:28:13 -0700 Subject: Preliminary Montage Template Cleanup The template creator is currently not returning serializing code, but does clean the document. Need to investigate reason why, currently all components are removed on save. --- js/document/models/html.js | 25 +++++++++++++------------ js/document/views/design.js | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'js/document') diff --git a/js/document/models/html.js b/js/document/models/html.js index 2764a6d6..b57ff832 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -22,30 +22,30 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + baseHref: { + value: null + }, //////////////////////////////////////////////////////////////////// // webGlHelper: { value: webGlDocumentHelper }, - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // userComponents: { value: {} }, - - /** - * Add a reference to a component instance to the userComponents hash using the - * element UUID - */ + //////////////////////////////////////////////////////////////////// + //Add a reference to a component instance to the userComponents hash using the element UUID setComponentInstance: { value: function(instance, el) { this.userComponents[el.uuid] = instance; } }, - - /** - * Returns the component instance obj from the element - */ + //////////////////////////////////////////////////////////////////// + //Returns the component instance obj from the element getComponentFromElement: { value: function(el) { if(el) { @@ -55,7 +55,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { } } } - + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/views/design.js b/js/document/views/design.js index 9ad088cb..765099e6 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -41,6 +41,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { content: { value: null }, + //////////////////////////////////////////////////////////////////// + //TODO: Remove usage + model: { + value: null + }, //////////////////////////////////////////////////////////////////// // document: { @@ -78,6 +83,8 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { // onTemplateLoad: { value: function (e) { + //TODO: Add support to constructing URL with a base HREF + var basetag = this.content.document.getElementsByTagName('base'); //Removing event this.iframe.removeEventListener("load", this.onTemplateLoad.bind(this), false); //TODO: Improve usage of this reference @@ -88,6 +95,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); } } + //Checking for a base URL + if (basetag.length) { + if (basetag[basetag.length-1].getAttribute && basetag[basetag.length-1].getAttribute('href')) { + //Setting base HREF in model + this.model.baseHref = basetag[basetag.length-1].getAttribute('href'); + } + } //Creating temp code fragement to load head this._headFragment = this.document.createElement('head'); //Adding event listener to know when head is ready, event only dispatched once when using innerHTML -- cgit v1.2.3