aboutsummaryrefslogtreecommitdiff
path: root/js/document/models
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-31 15:18:51 -0700
committerValerio Virgillito2012-07-31 15:18:51 -0700
commit4343e1f92547df9f7d42eecdf7e4feb47ad960e8 (patch)
tree27913b22fc5a899ae679013427d3cfe4b497837a /js/document/models
parentd68ad5c4aa404f66303833367700983b8d7f5303 (diff)
parentb391dde5f319bf4c534e9fce523c22be3bb16ace (diff)
downloadninja-4343e1f92547df9f7d42eecdf7e4feb47ad960e8.tar.gz
Merge pull request #422 from joseeight/Document
Document Code View
Diffstat (limited to 'js/document/models')
-rwxr-xr-xjs/document/models/base.js57
1 files changed, 54 insertions, 3 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index c7e2de69..d51806b2 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -88,9 +88,26 @@ exports.BaseDocumentModel = Montage.create(Component, {
88 }, 88 },
89 //////////////////////////////////////////////////////////////////// 89 ////////////////////////////////////////////////////////////////////
90 // 90 //
91 _currentViewIdentifier: {
92 value: ""
93 },
94 ////////////////////////////////////////////////////////////////////
95 //
96 currentViewIdentifier: {
97 get: function() {
98 return this._currentViewIdentifier;
99 },
100 set: function(value) {
101 this._currentViewIdentifier = value;
102 }
103 },
104 ////////////////////////////////////////////////////////////////////
105 //
91 _selection: { 106 _selection: {
92 value: [] 107 value: []
93 }, 108 },
109 ////////////////////////////////////////////////////////////////////
110 //
94 domContainer: { 111 domContainer: {
95 value: null 112 value: null
96 }, 113 },
@@ -120,7 +137,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
120 libs: { 137 libs: {
121 value: null 138 value: null
122 }, 139 },
123 140 ////////////////////////////////////////////////////////////////////
141 //
124 _mObjects: { 142 _mObjects: {
125 value: [] 143 value: []
126 }, 144 },
@@ -138,6 +156,23 @@ exports.BaseDocumentModel = Montage.create(Component, {
138 switchViewTo: { 156 switchViewTo: {
139 value: function (view) { 157 value: function (view) {
140 // 158 //
159 switch (view) {
160 case 'design':
161 //
162 if (this.views.design) this.views.design.show();
163 if (this.views.code) this.views.code.hide();
164 this.currentView = this.views.design;
165 break;
166 case 'code':
167 //
168 if (this.views.code) this.views.code.show();
169 if (this.views.design) this.views.design.hide();
170 this.currentView = this.views.code;
171 break;
172 default:
173 //Error
174 break;
175 }
141 } 176 }
142 }, 177 },
143 //////////////////////////////////////////////////////////////////// 178 ////////////////////////////////////////////////////////////////////
@@ -201,6 +236,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
201 // 236 //
202 save: { 237 save: {
203 value: function (callback, libCopyCallback) { 238 value: function (callback, libCopyCallback) {
239 var self = this;
240
204 //TODO: Implement on demand logic 241 //TODO: Implement on demand logic
205 if (this.needsSave) { 242 if (this.needsSave) {
206 //Save 243 //Save
@@ -233,8 +270,19 @@ exports.BaseDocumentModel = Montage.create(Component, {
233 this.libs.canvas = true; 270 this.libs.canvas = true;
234 } 271 }
235 } 272 }
273 } else if (this.currentView === this.views.code) {
274 //TODO: Add save logic for code view
275 //save to textarea
276 self.views.code.editor.save();
277 //save to disk
278 this.application.ninja.ioMediator.fileSave({
279 mode: 'html-text',
280 file: self.file,
281 content:self.views.code.textArea.value
282 }, this.handleSaved.bind({callback: callback, model: this}));
283
236 } else { 284 } else {
237 //TODO: Add logic to save code view data 285 //TODO: Error handle
238 } 286 }
239 } 287 }
240 }, 288 },
@@ -274,8 +322,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
274 this.libs.canvas = true; 322 this.libs.canvas = true;
275 } 323 }
276 } 324 }
325 } else if (this.currentView === this.views.code) {
326 //TODO: Add save logic for code view (this is a temp patch)
327 this.save(libCopyCallback);
277 } else { 328 } else {
278 //TODO: Add logic to save code view data 329 //TODO: Error handle
279 } 330 }
280 331
281 } 332 }