aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/document-html.js43
-rwxr-xr-xjs/document/models/base.js22
2 files changed, 62 insertions, 3 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 142ffe4a..b7dacf6a 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -76,7 +76,7 @@ exports.HtmlDocument = Montage.create(Component, {
76 //////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////
77 // 77 //
78 init: { 78 init: {
79 value:function(file, context, callback, view, template) { 79 value: function(file, context, callback, view, template) {
80 //Storing callback data for loaded dispatch 80 //Storing callback data for loaded dispatch
81 this.loaded.callback = callback; 81 this.loaded.callback = callback;
82 this.loaded.context = context; 82 this.loaded.context = context;
@@ -122,6 +122,44 @@ exports.HtmlDocument = Montage.create(Component, {
122 } 122 }
123 }, 123 },
124 //////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////
125 //TODO: Make into one method to use here and one init
126 reloadView: {
127 value: function (view, template) {
128 //
129 this.model.parentContainer.removeChild(this.model.views.design.iframe);
130 //Initiliazing views and hiding
131 if (this.model.views.design.initialize(this.model.parentContainer)) {
132 //Hiding iFrame, just initiliazing
133 this.model.views.design.hide();
134 //Setting the iFrame property for reference in helper class
135 this.model.webGlHelper.iframe = this.model.views.design.iframe;
136 } else {
137 //ERROR: Design View not initialized
138 }
139 //
140 if (view === 'design') {
141 //TODO: Remove reference and use as part of model
142 this.currentView = 'design';
143 //Setting current view object to design
144 this.model.currentView = this.model.views.design;
145 //Showing design iFrame
146 this.model.views.design.show();
147 this.model.views.design.iframe.style.opacity = 0;
148 this.model.views.design.content = this.model.file.content;
149 //TODO: Improve reference (probably through binding values)
150 this.model.views.design._webGlHelper = this.model.webGlHelper;
151 //Rendering design view, using observers to know when template is ready
152 this.model.views.design.render(function () {
153 //Adding observer to know when template is ready
154 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
155 this._observer.observe(this.model.views.design.document.head, {childList: true});
156 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
157 } else {
158 //TODO: Identify default view (probably code)
159 }
160 }
161 },
162 ////////////////////////////////////////////////////////////////////
125 // 163 //
126 handleTemplateReady: { 164 handleTemplateReady: {
127 value: function (e) { 165 value: function (e) {
@@ -130,6 +168,8 @@ exports.HtmlDocument = Montage.create(Component, {
130 this._observer = null; 168 this._observer = null;
131 } 169 }
132 }, 170 },
171 ////////////////////////////////////////////////////////////////////
172 //
133 handleViewReady: { 173 handleViewReady: {
134 value: function(mObjects) { 174 value: function(mObjects) {
135 this.model.mObjects = mObjects; 175 this.model.mObjects = mObjects;
@@ -138,7 +178,6 @@ exports.HtmlDocument = Montage.create(Component, {
138 if(typeof this.model.domContainer !== "undefined") { 178 if(typeof this.model.domContainer !== "undefined") {
139 this.model.domContainer = this.model.documentRoot; 179 this.model.domContainer = this.model.documentRoot;
140 } 180 }
141
142 //Making callback after view is loaded 181 //Making callback after view is loaded
143 this.loaded.callback.call(this.loaded.context, this); 182 this.loaded.callback.call(this.loaded.context, this);
144 } 183 }
diff --git a/js/document/models/base.js b/js/document/models/base.js
index c7e2de69..a9bbd6db 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -91,6 +91,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
91 _selection: { 91 _selection: {
92 value: [] 92 value: []
93 }, 93 },
94 ////////////////////////////////////////////////////////////////////
95 //
94 domContainer: { 96 domContainer: {
95 value: null 97 value: null
96 }, 98 },
@@ -120,7 +122,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
120 libs: { 122 libs: {
121 value: null 123 value: null
122 }, 124 },
123 125 ////////////////////////////////////////////////////////////////////
126 //
124 _mObjects: { 127 _mObjects: {
125 value: [] 128 value: []
126 }, 129 },
@@ -138,6 +141,23 @@ exports.BaseDocumentModel = Montage.create(Component, {
138 switchViewTo: { 141 switchViewTo: {
139 value: function (view) { 142 value: function (view) {
140 // 143 //
144 switch (view) {
145 case 'design':
146 //
147 if (this.views.design) this.views.design.show();
148 if (this.views.code) this.views.code.hide();
149 this.currentView = this.views.design;
150 break;
151 case 'code':
152 //
153 if (this.views.code) this.views.code.show();
154 if (this.views.design) this.views.design.hide();
155 this.currentView = this.views.code;
156 break;
157 default:
158 //Error
159 break;
160 }
141 } 161 }
142 }, 162 },
143 //////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////