aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnanya Sen2012-07-25 12:26:20 -0700
committerAnanya Sen2012-07-25 12:26:20 -0700
commit7fa0c53c14e9029d2e3960cc81edf91592fd1768 (patch)
treedb4449120f73539dc647fd5d331c0af7a5a50336
parentbb2f1d0e9a559f44348e95ad726801a5031aea3a (diff)
downloadninja-7fa0c53c14e9029d2e3960cc81edf91592fd1768.tar.gz
added save for code view, fixed code view editor bug, reuse code editor options component in document bar
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com> Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js19
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.html16
-rwxr-xr-xjs/document/models/base.js11
-rw-r--r--js/document/views/design-code.js5
4 files changed, 42 insertions, 9 deletions
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
index e2632d35..5ad36db5 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
@@ -51,10 +51,18 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
51 51
52 this._currentDocument = value; 52 this._currentDocument = value;
53 53
54 if(!value || (this._currentDocument.currentView === "design") || ((this._currentDocument.model.views.design !== null))) { 54 if(!value || (this._currentDocument.currentView === "design")) {
55 this.visible = false; 55 this.visible = false;
56 } else { 56 } else if(this._currentDocument.currentView === "code") {
57 this.visible = true; 57
58 if(this._currentDocument.model.views.design){//code view of design document
59 this.application.ninja.editorViewOptions.visible = false;
60 this.application.ninja.documentBar.codeEditorControls.visible = true;
61 }else if(!this._currentDocument.model.views.design){//code view for text document
62 this.application.ninja.editorViewOptions.visible = true;
63 this.application.ninja.documentBar.codeEditorControls.visible = false;
64 }
65
58 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; 66 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension];
59 this._currentDocument.model.views.code.editor.automaticCodeHint = this.codeCompleteCheck.checked; 67 this._currentDocument.model.views.code.editor.automaticCodeHint = this.codeCompleteCheck.checked;
60 } 68 }
@@ -200,6 +208,11 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
200 } else { 208 } else {
201 this.autoCompleteLabel.classList.remove("disabled"); 209 this.autoCompleteLabel.classList.remove("disabled");
202 } 210 }
211
212 //hide the zoom hottext if it is code view of a design file
213 if (this._currentDocument && this._currentDocument.model && this._currentDocument.model.views.design){
214 this.zoomHottext.element.style.display = "none";
215 }
203 } 216 }
204 }, 217 },
205 218
diff --git a/js/components/layout/document-bar.reel/document-bar.html b/js/components/layout/document-bar.reel/document-bar.html
index 3e3ac936..fb505a7c 100755
--- a/js/components/layout/document-bar.reel/document-bar.html
+++ b/js/components/layout/document-bar.reel/document-bar.html
@@ -77,6 +77,13 @@ POSSIBILITY OF SUCH DAMAGE.
77 "label": "Preview" 77 "label": "Preview"
78 } 78 }
79 }, 79 },
80
81 "codeEditorControls":{
82 "prototype": "js/code-editor/ui/code-editor-view-options.reel",
83 "properties": {
84 "element": {"#": "codeViewOptions"}
85 }
86 },
80 87
81 "owner": { 88 "owner": {
82 "prototype": "js/components/layout/document-bar.reel", 89 "prototype": "js/components/layout/document-bar.reel",
@@ -85,7 +92,8 @@ POSSIBILITY OF SUCH DAMAGE.
85 "zoomControl": {"@": "hottext1"}, 92 "zoomControl": {"@": "hottext1"},
86 "btnDesign": {"#": "buttonDesign"}, 93 "btnDesign": {"#": "buttonDesign"},
87 "btnCode": {"#": "buttonCode"}, 94 "btnCode": {"#": "buttonCode"},
88 "btnPreview": {"#": "buttonPreview"} 95 "btnPreview": {"#": "buttonPreview"},
96 "codeEditorControls": {"@": "codeEditorControls"}
89 } 97 }
90 } 98 }
91 } 99 }
@@ -129,7 +137,11 @@ POSSIBILITY OF SUCH DAMAGE.
129 137
130 </section> 138 </section>
131 139
132 <div data-montage-id="disabledCondition" class="panelDisabled"></div> 140 <div data-montage-id="disabledCondition" class="panelDisabled">
141
142 </div>
143
144 <div data-montage-id="codeViewOptions" class="viewOptions"></div>
133 145
134 </div> 146 </div>
135 147
diff --git a/js/document/models/base.js b/js/document/models/base.js
index c44123c3..a73b8b20 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -236,6 +236,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
236 // 236 //
237 save: { 237 save: {
238 value: function (callback, libCopyCallback) { 238 value: function (callback, libCopyCallback) {
239 var self = this;
240
239 //TODO: Implement on demand logic 241 //TODO: Implement on demand logic
240 if (this.needsSave) { 242 if (this.needsSave) {
241 //Save 243 //Save
@@ -270,6 +272,15 @@ exports.BaseDocumentModel = Montage.create(Component, {
270 } 272 }
271 } else if (this.currentView === this.views.code) { 273 } else if (this.currentView === this.views.code) {
272 //TODO: Add save logic for code view 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
273 } else { 284 } else {
274 //TODO: Error handle 285 //TODO: Error handle
275 } 286 }
diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js
index 44d12549..8ad6d555 100644
--- a/js/document/views/design-code.js
+++ b/js/document/views/design-code.js
@@ -70,10 +70,7 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, {
70 // 70 //
71 show: { 71 show: {
72 value: function (callback) { 72 value: function (callback) {
73 73 this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default");
74 this.textViewContainer.style.display = "block";
75 this.textViewContainer.style.background = "white";
76 this.textViewContainer.style.height = "100%";
77 74
78 //todo : update options bar 75 //todo : update options bar
79 76