aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-09 17:46:29 -0700
committerValerio Virgillito2012-05-09 17:46:29 -0700
commit2e9a6b271439d934439514f6386424567853f93c (patch)
tree530f7e992de0ff04848c1f39c326c72ab57d056e /js/document
parent258f006074616f1c654125059e73d94752afb896 (diff)
parentec68c665dee1936312842c546e1c7347f05dc555 (diff)
downloadninja-2e9a6b271439d934439514f6386424567853f93c.tar.gz
Merge pull request #207 from joseeight/Document
Setting up Montage-Template-Creator
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/models/html.js25
-rwxr-xr-xjs/document/views/design.js14
2 files changed, 27 insertions, 12 deletions
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
@@ -24,28 +24,28 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
24 }, 24 },
25 //////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////
26 // 26 //
27 baseHref: {
28 value: null
29 },
30 ////////////////////////////////////////////////////////////////////
31 //
27 webGlHelper: { 32 webGlHelper: {
28 value: webGlDocumentHelper 33 value: webGlDocumentHelper
29 }, 34 },
30 //////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////
31 //////////////////////////////////////////////////////////////////// 36 //
32 userComponents: { 37 userComponents: {
33 value: {} 38 value: {}
34 }, 39 },
35 40 ////////////////////////////////////////////////////////////////////
36 /** 41 //Add a reference to a component instance to the userComponents hash using the element UUID
37 * Add a reference to a component instance to the userComponents hash using the
38 * element UUID
39 */
40 setComponentInstance: { 42 setComponentInstance: {
41 value: function(instance, el) { 43 value: function(instance, el) {
42 this.userComponents[el.uuid] = instance; 44 this.userComponents[el.uuid] = instance;
43 } 45 }
44 }, 46 },
45 47 ////////////////////////////////////////////////////////////////////
46 /** 48 //Returns the component instance obj from the element
47 * Returns the component instance obj from the element
48 */
49 getComponentFromElement: { 49 getComponentFromElement: {
50 value: function(el) { 50 value: function(el) {
51 if(el) { 51 if(el) {
@@ -55,7 +55,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
55 } 55 }
56 } 56 }
57 } 57 }
58 58 ////////////////////////////////////////////////////////////////////
59 ////////////////////////////////////////////////////////////////////
59}); 60});
60//////////////////////////////////////////////////////////////////////// 61////////////////////////////////////////////////////////////////////////
61//////////////////////////////////////////////////////////////////////// \ No newline at end of file 62//////////////////////////////////////////////////////////////////////// \ 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
@@ -42,6 +42,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
42 value: null 42 value: null
43 }, 43 },
44 //////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////
45 //TODO: Remove usage
46 model: {
47 value: null
48 },
49 ////////////////////////////////////////////////////////////////////
45 // 50 //
46 document: { 51 document: {
47 get: function() {return this._document;}, 52 get: function() {return this._document;},
@@ -78,6 +83,8 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
78 // 83 //
79 onTemplateLoad: { 84 onTemplateLoad: {
80 value: function (e) { 85 value: function (e) {
86 //TODO: Add support to constructing URL with a base HREF
87 var basetag = this.content.document.getElementsByTagName('base');
81 //Removing event 88 //Removing event
82 this.iframe.removeEventListener("load", this.onTemplateLoad.bind(this), false); 89 this.iframe.removeEventListener("load", this.onTemplateLoad.bind(this), false);
83 //TODO: Improve usage of this reference 90 //TODO: Improve usage of this reference
@@ -88,6 +95,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
88 this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); 95 this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true');
89 } 96 }
90 } 97 }
98 //Checking for a base URL
99 if (basetag.length) {
100 if (basetag[basetag.length-1].getAttribute && basetag[basetag.length-1].getAttribute('href')) {
101 //Setting base HREF in model
102 this.model.baseHref = basetag[basetag.length-1].getAttribute('href');
103 }
104 }
91 //Creating temp code fragement to load head 105 //Creating temp code fragement to load head
92 this._headFragment = this.document.createElement('head'); 106 this._headFragment = this.document.createElement('head');
93 //Adding event listener to know when head is ready, event only dispatched once when using innerHTML 107 //Adding event listener to know when head is ready, event only dispatched once when using innerHTML