aboutsummaryrefslogtreecommitdiff
path: root/js/document/models/base.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/models/base.js')
-rwxr-xr-xjs/document/models/base.js37
1 files changed, 21 insertions, 16 deletions
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 }