diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 3 | ||||
-rwxr-xr-x | js/document/document-text.js | 52 | ||||
-rwxr-xr-x | js/document/models/text.js | 57 | ||||
-rwxr-xr-x | js/document/views/base.js | 2 | ||||
-rwxr-xr-x | js/document/views/code.js | 152 |
5 files changed, 253 insertions, 13 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index ae5b73b6..d6b4ba95 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -158,9 +158,6 @@ exports.HtmlDocument = Montage.create(Component, { | |||
158 | // Pause the videos | 158 | // Pause the videos |
159 | //TODO: Move these to be handled on the show/hide methods in the view | 159 | //TODO: Move these to be handled on the show/hide methods in the view |
160 | this.model.views.design.pauseVideos(); | 160 | this.model.views.design.pauseVideos(); |
161 | |||
162 | //TODO: Move this to the document controller | ||
163 | this.model.isActive = false; | ||
164 | } | 161 | } |
165 | }, | 162 | }, |
166 | //////////////////////////////////////////////////////////////////// | 163 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/document/document-text.js b/js/document/document-text.js index 2a469144..bb63f5f8 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js | |||
@@ -7,7 +7,9 @@ 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 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component, |
11 | TextDocumentModel = require("js/document/models/text").TextDocumentModel, | ||
12 | CodeDocumentView = require("js/document/views/code").CodeDocumentView; | ||
11 | //////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////// |
12 | // | 14 | // |
13 | exports.TextDocument = Montage.create(Component, { | 15 | exports.TextDocument = Montage.create(Component, { |
@@ -16,9 +18,53 @@ exports.TextDocument = Montage.create(Component, { | |||
16 | hasTemplate: { | 18 | hasTemplate: { |
17 | enumerable: false, | 19 | enumerable: false, |
18 | value: false | 20 | value: false |
19 | } | 21 | }, |
20 | //////////////////////////////////////////////////////////////////// | ||
21 | //////////////////////////////////////////////////////////////////// | 22 | //////////////////////////////////////////////////////////////////// |
23 | // | ||
24 | model: { | ||
25 | value: null | ||
26 | }, | ||
27 | //////////////////////////////////////////////////////////////////// | ||
28 | // | ||
29 | |||
30 | init:{ | ||
31 | enumerable: false, | ||
32 | value : function(file, context, callback, view){ | ||
33 | var codeDocumentView = CodeDocumentView.create(), container = null; | ||
34 | |||
35 | //Creating instance of Text Document Model | ||
36 | this.model = Montage.create(TextDocumentModel,{ | ||
37 | file: {value: file}, | ||
38 | parentContainer: {value: document.getElementById("codeViewContainer")}, | ||
39 | views: {value: {'code': codeDocumentView, 'design': null}} | ||
40 | }); | ||
41 | |||
42 | codeDocumentView.initialize(this.model.parentContainer); | ||
43 | |||
44 | codeDocumentView.textArea.value = file.content; | ||
45 | codeDocumentView.initializeTextView(file, this); | ||
46 | |||
47 | if (view === 'code') { | ||
48 | //TODO: Remove reference and use as part of model | ||
49 | this.currentView = 'code'; | ||
50 | //Setting current view object to design | ||
51 | this.model.currentView = this.model.views.code; | ||
52 | } | ||
53 | |||
54 | |||
55 | callback.call(context, this); | ||
56 | } | ||
57 | }, | ||
58 | //////////////////////////////////////////////////////////////////// | ||
59 | // | ||
60 | closeDocument: { | ||
61 | value: function (context, callback) { | ||
62 | var closed = this.model.close(null); | ||
63 | |||
64 | callback.call(context, this); | ||
65 | } | ||
66 | } | ||
67 | //////////////////////////////////////////////////////////////////// | ||
22 | }); | 68 | }); |
23 | //////////////////////////////////////////////////////////////////////// | 69 | //////////////////////////////////////////////////////////////////////// |
24 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 70 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |
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 |
diff --git a/js/document/views/base.js b/js/document/views/base.js index d1c65b5e..db72cc60 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js | |||
@@ -39,6 +39,7 @@ exports.BaseDocumentView = Montage.create(Component, { | |||
39 | value: function (callback) { | 39 | value: function (callback) { |
40 | if (this.iframe) { | 40 | if (this.iframe) { |
41 | this.iframe.style.display = 'block'; | 41 | this.iframe.style.display = 'block'; |
42 | this.iframe.style.opacity = 1; | ||
42 | } else { | 43 | } else { |
43 | console.log('Error: View has no iframe to show!'); | 44 | console.log('Error: View has no iframe to show!'); |
44 | } | 45 | } |
@@ -52,6 +53,7 @@ exports.BaseDocumentView = Montage.create(Component, { | |||
52 | value: function (callback) { | 53 | value: function (callback) { |
53 | if (this.iframe) { | 54 | if (this.iframe) { |
54 | this.iframe.style.display = 'none'; | 55 | this.iframe.style.display = 'none'; |
56 | this.iframe.style.opacity = 0; | ||
55 | } else { | 57 | } else { |
56 | console.log('Error: View has no iframe to hide!'); | 58 | console.log('Error: View has no iframe to hide!'); |
57 | } | 59 | } |
diff --git a/js/document/views/code.js b/js/document/views/code.js index cd3e02d4..66d1c702 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js | |||
@@ -11,15 +11,161 @@ var Montage = require("montage/core/core").Montage, | |||
11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; | 11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; |
12 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
13 | // | 13 | // |
14 | exports.CodeDocumentView = Montage.create(BaseDocumentView, { | 14 | var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, { |
15 | //////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////// |
16 | // | 16 | // |
17 | hasTemplate: { | 17 | hasTemplate: { |
18 | enumerable: false, | 18 | enumerable: false, |
19 | value: false | 19 | value: false |
20 | }, | ||
21 | |||
22 | //////////////////////////////////////////////////////////////////// | ||
23 | // | ||
24 | _editor: { | ||
25 | value: null | ||
26 | }, | ||
27 | //////////////////////////////////////////////////////////////////// | ||
28 | // | ||
29 | editor: { | ||
30 | get: function() {return this._editor;}, | ||
31 | set: function(value) {this._editor= value;} | ||
32 | }, | ||
33 | //////////////////////////////////////////////////////////////////// | ||
34 | // | ||
35 | _textArea: { | ||
36 | value: null | ||
37 | }, | ||
38 | //////////////////////////////////////////////////////////////////// | ||
39 | // | ||
40 | textArea: { | ||
41 | get: function() {return this._textArea;}, | ||
42 | set: function(value) {this._textArea= value;} | ||
43 | }, | ||
44 | //////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | _textViewContainer: { | ||
47 | value: null | ||
48 | }, | ||