aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-06 13:46:02 -0700
committerJose Antonio Marquez2012-06-06 13:46:02 -0700
commit6a0f150f49be656e0725bc77b452a3141dddd47c (patch)
tree4d9d946c73c138ce5d6bca04872d7fe9385f4093 /js
parent18e212dca48066d1ddaca96875a3f40adcc859b6 (diff)
downloadninja-6a0f150f49be656e0725bc77b452a3141dddd47c.tar.gz
Cleaning up
Removed reference of model in design view, clean up slightly, need to implement binding later.
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/document-html.js4
-rwxr-xr-xjs/document/models/base.js37
-rwxr-xr-xjs/document/models/html.js25
-rwxr-xr-xjs/document/views/design.js46
4 files changed, 72 insertions, 40 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 33a41a8e..c9acd2e0 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -68,6 +68,8 @@ exports.HtmlDocument = Montage.create(Component, {
68 if (this.model.views.design.initialize(this.model.parentContainer)) { 68 if (this.model.views.design.initialize(this.model.parentContainer)) {
69 //Hiding iFrame, just initiliazing 69 //Hiding iFrame, just initiliazing
70 this.model.views.design.hide(); 70 this.model.views.design.hide();
71 //Setting the iFrame property for reference in helper class
72 this.model.webGlHelper.iframe = this.model.views.design.iframe;
71 } else { 73 } else {
72 //ERROR: Design View not initialized 74 //ERROR: Design View not initialized
73 } 75 }
@@ -82,7 +84,7 @@ exports.HtmlDocument = Montage.create(Component, {
82 this.model.views.design.iframe.style.opacity = 0; 84 this.model.views.design.iframe.style.opacity = 0;
83 this.model.views.design.content = this.model.file.content; 85 this.model.views.design.content = this.model.file.content;
84 //TODO: Improve reference (probably through binding values) 86 //TODO: Improve reference (probably through binding values)
85 this.model.views.design.model = this.model; 87 this.model.views.design._webGlHelper = this.model.webGlHelper;
86 //Rendering design view, using observers to know when template is ready 88 //Rendering design view, using observers to know when template is ready
87 this.model.views.design.render(function () { 89 this.model.views.design.render(function () {
88 //Adding observer to know when template is ready 90 //Adding observer to know when template is ready
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 0957145a..a3644815 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -65,7 +65,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
65 _selection: { 65 _selection: {
66 value: [] 66 value: []
67 }, 67 },
68 68 ////////////////////////////////////////////////////////////////////
69 //
69 selection: { 70 selection: {
70 get: function() { 71 get: function() {
71 return this._selection; 72 return this._selection;
@@ -134,20 +135,22 @@ exports.BaseDocumentModel = Montage.create(Component, {
134 } 135 }
135 }, 136 },
136 //////////////////////////////////////////////////////////////////// 137 ////////////////////////////////////////////////////////////////////
137 // 138 //Gets all stylesheets in document
138 getStyleSheets: { 139 getStyleSheets: {
139 value: function () { 140 value: function () {
140 // 141 //Array to store styles (style and link tags)
141 var styles = []; 142 var styles = [];
142 // 143 //Looping through document sytles
143 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { 144 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) {
145 //Check for styles to has proper propeties
144 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { 146 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) {
147 //Check for ninja-template styles, if so, exclude
145 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { 148 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) {
146 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); 149 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]);
147 } 150 }
148 } 151 }
149 } 152 }
150 // 153 //Returning filtered results
151 return styles; 154 return styles;
152 } 155 }
153 }, 156 },
@@ -155,7 +158,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
155 // 158 //
156 save: { 159 save: {
157 value: function (callback, libCopyCallback) { 160 value: function (callback, libCopyCallback) {
158 // 161 //TODO: Implement on demand logic
159 if (this.needsSave) { 162 if (this.needsSave) {
160 //Save 163 //Save
161 } else { 164 } else {
@@ -184,7 +187,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
184 // 187 //
185 saveAll: { 188 saveAll: {
186 value: function (callback, libCopyCallback) { 189 value: function (callback, libCopyCallback) {
187 // 190 //TODO: Implement on demand logic
188 if (this.needsSave) { 191 if (this.needsSave) {
189 //Save 192 //Save
190 } else { 193 } else {
@@ -214,47 +217,49 @@ exports.BaseDocumentModel = Montage.create(Component, {
214 // 217 //
215 saveAs: { 218 saveAs: {
216 value: function (callback) { 219 value: function (callback) {
217 // 220 //TODO: Implement on demand logic
218 if (this.needsSave) { 221 if (this.needsSave) {
219 //Save current file on memory 222 //Save current file on memory
220 } else { 223 } else {
221 //Copy file from disk 224 //Copy file from disk
222 } 225 }
226 //TODO: Add functionality
223 } 227 }
224 }, 228 },
225 //////////////////////////////////////////////////////////////////// 229 ////////////////////////////////////////////////////////////////////
226 // 230 //
227 handleSaved: { 231 handleSaved: {
228 value: function (result) { 232 value: function (result) {
229 // 233 //Checking for success code in save
230 if (result.status === 204) { 234 if (result.status === 204) {
235 //Clearing flag with successful save
231 this.model.needsSave = false; 236 this.model.needsSave = false;
232 } 237 }
233 // 238 //Making callback call if specifed with results of operation
234 if (this.callback) this.callback(result); 239 if (this.callback) this.callback(result);
235 } 240 }
236 }, 241 },
237 //////////////////////////////////////////////////////////////////// 242 ////////////////////////////////////////////////////////////////////
238 // 243 //TODO: Implement better logic to include different views on single document
239 close: { 244 close: {
240 value: function (view, callback) { 245 value: function (view, callback) {
241 //Outcome of close (pending on save logic) 246 //Outcome of close (pending on save logic)
242 var success; 247 var success;
243 // 248 //
244 if (this.needsSave) { 249 if (this.needsSave) {
245 //Prompt user to save of lose data 250 //TODO: Prompt user to save or lose data
246 } else { 251 } else {
247 //Close file 252 //Close file
248 success = true; 253 success = true;
249 } 254 }
250 // 255 //Checking for view mode to close
251 if (this.views.design && (!view || view === 'design')) { 256 if (this.views.design && (!view || view === 'design')) {
252 // 257 //TODO: Create a destroy method, this is messy
258 this.views.design.pauseAndStopVideos();
253 this.parentContainer.removeChild(this.views.design.iframe); 259 this.parentContainer.removeChild(this.views.design.iframe);
254 this.views.design.pauseAndStopVideos();
255 this.views.design = null; 260 this.views.design = null;
256 } 261 }
257 // 262 //Returning result of operation
258 return success; 263 return success;
259 } 264 }
260 } 265 }
diff --git a/js/document/models/html.js b/js/document/models/html.js
index 9aa0d27e..0f88229d 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -40,22 +40,32 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
40 scrollLeft: { 40 scrollLeft: {
41 value: null 41 value: null
42 }, 42 },
43 43 ////////////////////////////////////////////////////////////////////
44 //
44 scrollTop: { 45 scrollTop: {
45 value: null 46 value: null
46 }, 47 },
47 48 ////////////////////////////////////////////////////////////////////
49 //
48 userContentLeft: { 50 userContentLeft: {
49 value: null 51 value: null
50 }, 52 },
51 53 ////////////////////////////////////////////////////////////////////
54 //
52 userContentTop: { 55 userContentTop: {
53 value: null 56 value: null
54 }, 57 },
55 //////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////
56 // 59 //TODO: Convert to bindings
60 documentRoot: {
61 get: function() {return this.views.design._documentRoot;},
62 set: function(value) {this.views.design._documentRoot = value;}
63 },
64 ////////////////////////////////////////////////////////////////////
65 //TODO: Convert to bindings
57 baseHref: { 66 baseHref: {
58 value: null 67 get: function() {return this.views.design._baseHref;},
68 set: function(value) {this.views.design._baseHref = value;}
59 }, 69 },
60 //////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////
61 // 71 //
@@ -67,11 +77,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
67 userComponents: { 77 userComponents: {
68 value: {} 78 value: {}
69 }, 79 },
70 ////////////////////////////////////////////////////////////////////
71 //
72 documentRoot: {
73 value: null
74 },
75 //////////////////////////////////////////////////////////////////// 80 ////////////////////////////////////////////////////////////////////
76 //Add a reference to a component instance to the userComponents hash using the element UUID 81 //Ad