diff options
author | Ananya Sen | 2012-05-18 18:38:09 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-18 18:38:09 -0700 |
commit | 6f5ffa17c72dd0aef7a02e3496154514750143c2 (patch) | |
tree | d9a6e2b33ad6dcdd308869cfdf9014ae720d8fe6 /js/document | |
parent | bddbcd15c165ac0731de204b023a1e60d71b5d79 (diff) | |
download | ninja-6f5ffa17c72dd0aef7a02e3496154514750143c2.tar.gz |
save for code view documents in the new dom architecture
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-text.js | 10 | ||||
-rwxr-xr-x | js/document/models/text.js | 53 |
2 files changed, 61 insertions, 2 deletions
diff --git a/js/document/document-text.js b/js/document/document-text.js index 533b32c9..09525f4e 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js | |||
@@ -53,8 +53,16 @@ exports.TextDocument = Montage.create(Component, { | |||
53 | 53 | ||
54 | callback.call(context, this); | 54 | callback.call(context, this); |
55 | } | 55 | } |
56 | } | 56 | }, |
57 | //////////////////////////////////////////////////////////////////// | 57 | //////////////////////////////////////////////////////////////////// |
58 | // | ||
59 | closeDocument: { | ||
60 | value: function (context, callback) { | ||
61 | var closed = this.model.close(null); | ||
62 | |||
63 | callback.call(context, this); | ||
64 | } | ||
65 | } | ||
58 | //////////////////////////////////////////////////////////////////// | 66 | //////////////////////////////////////////////////////////////////// |
59 | }); | 67 | }); |
60 | //////////////////////////////////////////////////////////////////////// | 68 | //////////////////////////////////////////////////////////////////////// |
diff --git a/js/document/models/text.js b/js/document/models/text.js index 5a5e86ef..d21666d0 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js | |||
@@ -16,7 +16,58 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { | |||
16 | hasTemplate: { | 16 | hasTemplate: { |
17 | enumerable: false, | 17 | enumerable: false, |
18 | value: false | 18 | value: false |
19 | } | 19 | }, |
20 | //////////////////////////////////////////////////////////////////// | ||
21 | // | ||
22 | save: { | ||
23 | enumerable: false, | ||
24 | value: function (callback) { | ||
25 | this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea | ||
26 | |||
27 | var self = this; | ||
28 | |||
29 | this.application.ninja.ioMediator.fileSave({ | ||
30 | mode: ""+ self.file.extension, | ||
31 | file: self.file, | ||
32 | content:self.views.code.textArea.value | ||
33 | }, this.handleSaved.bind({callback: callback, model: this})); | ||
34 | } | ||
35 | }, | ||
36 | //////////////////////////////////////////////////////////////////// | ||
37 | // | ||
38 | handleSaved: { | ||
39 | value: function (result) { | ||
40 | // | ||
41 | if (result.status === 204) { | ||
42 | this.model.needsSave = false; | ||
43 | } | ||
44 | // | ||
45 | if (this.callback) this.callback(result); | ||
46 | } | ||
47 | }, | ||
48 | //////////////////////////////////////////////////////////////////// | ||
49 | // | ||
50 | close: { | ||
51 | value: function (view, callback) { | ||
52 | //Outcome of close (pending on save logic) | ||
53 | var success; | ||
54 | // | ||
55 | if (this.needsSave) { | ||
56 | //Prompt user to save of lose data | ||
57 | } else { | ||
58 | //Close file | ||
59 | success = true; | ||
60 | } | ||
61 | // | ||
62 | this.views.code.textParentContainer.removeChild(this.views.code.textViewContainer); | ||
63 | this.views.code.restoreAllPanels(); | ||
64 | this.views.code.showCodeViewBar(false); | ||
65 | this.views.code = null; | ||
66 | |||
67 | // | ||
68 | return success; | ||
69 | } | ||
70 | } | ||
20 | }); | 71 | }); |
21 | //////////////////////////////////////////////////////////////////////// | 72 | //////////////////////////////////////////////////////////////////////// |
22 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 73 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |