diff options
Diffstat (limited to 'js/document/models')
-rwxr-xr-x | js/document/models/base.js | 22 | ||||
-rwxr-xr-x | js/document/models/html.js | 22 | ||||
-rwxr-xr-x | js/document/models/text.js | 57 |
3 files changed, 92 insertions, 9 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js index 649539ea..6d9d2e89 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -30,7 +30,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
30 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
31 | // | 31 | // |
32 | _isActive: { | 32 | _isActive: { |
33 | value: null | 33 | value: true |
34 | }, | 34 | }, |
35 | //////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////// |
36 | // | 36 | // |
@@ -100,7 +100,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
100 | } | 100 | } |
101 | break; | 101 | break; |
102 | default: | 102 | default: |
103 | if (this.template.type === 'banner' || this.template.type === 'animation') { | 103 | if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { |
104 | window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); | 104 | window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); |
105 | } else { | 105 | } else { |
106 | window.open(this.url); | 106 | window.open(this.url); |
@@ -151,7 +151,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
151 | head: this.views.design.iframe.contentWindow.document.head, | 151 | head: this.views.design.iframe.contentWindow.document.head, |
152 | body: this.views.design.iframe.contentWindow.document.body, | 152 | body: this.views.design.iframe.contentWindow.document.body, |
153 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator | 153 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator |
154 | }, callback.bind(this)); | 154 | }, this.handleSaved.bind({callback: callback, model: this})); |
155 | } else { | 155 | } else { |
156 | //TODO: Add logic to save code view data | 156 | //TODO: Add logic to save code view data |
157 | } | 157 | } |
@@ -180,7 +180,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
180 | head: this.views.design.iframe.contentWindow.document.head, | 180 | head: this.views.design.iframe.contentWindow.document.head, |
181 | body: this.views.design.iframe.contentWindow.document.body, | 181 | body: this.views.design.iframe.contentWindow.document.body, |
182 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator | 182 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator |
183 | }, callback.bind(this)); | 183 | }, this.handleSaved.bind({callback: callback, model: this})); |
184 | } else { | 184 | } else { |
185 | //TODO: Add logic to save code view data | 185 | //TODO: Add logic to save code view data |
186 | } | 186 | } |
@@ -190,7 +190,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
190 | //////////////////////////////////////////////////////////////////// | 190 | //////////////////////////////////////////////////////////////////// |
191 | // | 191 | // |
192 | saveAs: { | 192 | saveAs: { |
193 | value: function () { | 193 | value: function (callback) { |
194 | // | 194 | // |
195 | if (this.needsSave) { | 195 | if (this.needsSave) { |
196 | //Save current file on memory | 196 | //Save current file on memory |
@@ -201,6 +201,18 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
201 | }, | 201 | }, |
202 | //////////////////////////////////////////////////////////////////// | 202 | //////////////////////////////////////////////////////////////////// |
203 | // | 203 | // |
204 | handleSaved: { | ||
205 | value: function (result) { | ||
206 | // | ||
207 | if (result.status === 204) { | ||
208 | this.model.needsSave = false; | ||
209 | } | ||
210 | // | ||
211 | if (this.callback) this.callback(result); | ||
212 | } | ||
213 | }, | ||
214 | //////////////////////////////////////////////////////////////////// | ||
215 | // | ||
204 | close: { | 216 | close: { |
205 | value: function (view, callback) { | 217 | value: function (view, callback) { |
206 | //Outcome of close (pending on save logic) | 218 | //Outcome of close (pending on save logic) |
diff --git a/js/document/models/html.js b/js/document/models/html.js index 67457863..9cc8ce92 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -22,12 +22,34 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
22 | selection: { | 22 | selection: { |
23 | value: [] | 23 | value: [] |
24 | }, | 24 | }, |
25 | //////////////////////////////////////////////////////////////////// | ||
26 | // | ||
27 | selectionContainer: { | ||
28 | value: [] | ||
29 | }, | ||
25 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
26 | // | 31 | // |
27 | draw3DGrid: { | 32 | draw3DGrid: { |
28 | value: false | 33 | value: false |
29 | }, | 34 | }, |
30 | //////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////// |
36 | // | ||
37 | scrollLeft: { | ||
38 | value: null | ||
39 | }, | ||
40 | |||
41 | scrollTop: { | ||
42 | value: null | ||
43 | }, | ||
44 | |||
45 | userContentLeft: { | ||
46 | value: null | ||
47 | }, | ||
48 | |||
49 | userContentTop: { | ||
50 | value: null | ||
51 | }, | ||
52 | //////////////////////////////////////////////////////////////////// | ||
31 | // | 53 | // |
32 | baseHref: { | 54 | baseHref: { |
33 | value: null | 55 | value: null |
diff --git a/js/document/models/text.js b/js/document/models/text.js index ebf9993e..d1252b7d 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js | |||
@@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | BaseDocumentModel = require("js/document/models/text").BaseDocumentModel; | 10 | BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; |
11 | //////////////////////////////////////////////////////////////////////// | 11 | //////////////////////////////////////////////////////////////////////// |
12 | // | 12 | // |
13 | exports.TextDocumentModel = Montage.create(BaseDocumentModel, { | 13 | exports.TextDocumentModel = Montage.create(BaseDocumentModel, { |
@@ -16,9 +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 | //////////////////////////////////////////////////////////////////// | 20 | //////////////////////////////////////////////////////////////////// |
21 | //////////////////////////////////////////////////////////////////// | 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.parentContainer.removeChild(this.views.code.textViewContainer); | ||
63 | this.application.ninja.stage.showCodeViewBar(false); | ||
64 | this.application.ninja.stage.restoreAllPanels(); | ||
65 | this.views.code = null; | ||
66 | |||
67 | // | ||
68 | return success; | ||
69 | } | ||
70 | } | ||
22 | }); | 71 | }); |
23 | //////////////////////////////////////////////////////////////////////// | 72 | //////////////////////////////////////////////////////////////////////// |
24 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 73 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |