From 7fa0c53c14e9029d2e3960cc81edf91592fd1768 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:26:20 -0700 Subject: added save for code view, fixed code view editor bug, reuse code editor options component in document bar Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- .../code-editor-view-options.js | 19 ++++++++++++++++--- .../layout/document-bar.reel/document-bar.html | 16 ++++++++++++++-- js/document/models/base.js | 11 +++++++++++ js/document/views/design-code.js | 5 +---- 4 files changed, 42 insertions(+), 9 deletions(-) (limited to 'js') 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, { this._currentDocument = value; - if(!value || (this._currentDocument.currentView === "design") || ((this._currentDocument.model.views.design !== null))) { + if(!value || (this._currentDocument.currentView === "design")) { this.visible = false; - } else { - this.visible = true; + } else if(this._currentDocument.currentView === "code") { + + if(this._currentDocument.model.views.design){//code view of design document + this.application.ninja.editorViewOptions.visible = false; + this.application.ninja.documentBar.codeEditorControls.visible = true; + }else if(!this._currentDocument.model.views.design){//code view for text document + this.application.ninja.editorViewOptions.visible = true; + this.application.ninja.documentBar.codeEditorControls.visible = false; + } + this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; this._currentDocument.model.views.code.editor.automaticCodeHint = this.codeCompleteCheck.checked; } @@ -200,6 +208,11 @@ exports.CodeEditorViewOptions = Montage.create(Component, { } else { this.autoCompleteLabel.classList.remove("disabled"); } + + //hide the zoom hottext if it is code view of a design file + if (this._currentDocument && this._currentDocument.model && this._currentDocument.model.views.design){ + this.zoomHottext.element.style.display = "none"; + } } }, 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. "label": "Preview" } }, + + "codeEditorControls":{ + "prototype": "js/code-editor/ui/code-editor-view-options.reel", + "properties": { + "element": {"#": "codeViewOptions"} + } + }, "owner": { "prototype": "js/components/layout/document-bar.reel", @@ -85,7 +92,8 @@ POSSIBILITY OF SUCH DAMAGE. "zoomControl": {"@": "hottext1"}, "btnDesign": {"#": "buttonDesign"}, "btnCode": {"#": "buttonCode"}, - "btnPreview": {"#": "buttonPreview"} + "btnPreview": {"#": "buttonPreview"}, + "codeEditorControls": {"@": "codeEditorControls"} } } } @@ -129,7 +137,11 @@ POSSIBILITY OF SUCH DAMAGE. -
+
+ +
+ +
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, { // save: { value: function (callback, libCopyCallback) { + var self = this; + //TODO: Implement on demand logic if (this.needsSave) { //Save @@ -270,6 +272,15 @@ exports.BaseDocumentModel = Montage.create(Component, { } } else if (this.currentView === this.views.code) { //TODO: Add save logic for code view + //save to textarea + self.views.code.editor.save(); + //save to disk + this.application.ninja.ioMediator.fileSave({ + mode: 'html-text', + file: self.file, + content:self.views.code.textArea.value + }, this.handleSaved.bind({callback: callback, model: this})); + } else { //TODO: Error handle } 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, { // show: { value: function (callback) { - - this.textViewContainer.style.display = "block"; - this.textViewContainer.style.background = "white"; - this.textViewContainer.style.height = "100%"; + this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); //todo : update options bar -- cgit v1.2.3 From 0262cbeccef538d3aa125eb7cd16d8ca758c82b1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:27:40 -0700 Subject: added save for code view, fixed code view editor bug, reuse code editor options component in document bar Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- js/document/views/design-code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 8ad6d555..70afe785 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -72,7 +72,7 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { value: function (callback) { this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); - //todo : update options bar + //todo : update options bar // if (callback) callback(); -- cgit v1.2.3 From fa2e82cf10aaa4900a462410cbb99b5b0433a1b1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:28:58 -0700 Subject: fixing code editor double vertical scrollbar bug Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- .../code-editor-view-options.html | 2 +- .../code-editor-view-options.js | 30 +++++++++++++++++----- .../layout/document-bar.reel/document-bar.html | 9 +------ .../layout/document-bar.reel/document-bar.js | 6 +++++ js/document/views/design-code.js | 4 ++- js/stage/stage.reel/stage.css | 6 ++++- 6 files changed, 39 insertions(+), 18 deletions(-) (limited to 'js') diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html index 476db181..e6cc3763 100644 --- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html +++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html @@ -80,7 +80,7 @@ POSSIBILITY OF SUCH DAMAGE.
- +
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 5ad36db5..70d033fb 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 @@ -57,16 +57,25 @@ exports.CodeEditorViewOptions = Montage.create(Component, { if(this._currentDocument.model.views.design){//code view of design document this.application.ninja.editorViewOptions.visible = false; - this.application.ninja.documentBar.codeEditorControls.visible = true; + //this.application.ninja.documentBar.codeEditorControls.visible = false;//todo }else if(!this._currentDocument.model.views.design){//code view for text document this.application.ninja.editorViewOptions.visible = true; - this.application.ninja.documentBar.codeEditorControls.visible = false; + //this.application.ninja.documentBar.codeEditorControls.visible = false; } this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; this._currentDocument.model.views.code.editor.automaticCodeHint = this.codeCompleteCheck.checked; } + if(this._currentDocument && (this._currentDocument.currentView === "design")) { + this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); + } + + //hide the zoom hottext if it is code view of a design file + if (this._currentDocument && this._currentDocument.model && this._currentDocument.model.views.code){ + this.zoomHottext.element.style.display = "block"; + } + } }, @@ -208,11 +217,6 @@ exports.CodeEditorViewOptions = Montage.create(Component, { } else { this.autoCompleteLabel.classList.remove("disabled"); } - - //hide the zoom hottext if it is code view of a design file - if (this._currentDocument && this._currentDocument.model && this._currentDocument.model.views.design){ - this.zoomHottext.element.style.display = "none"; - } } }, @@ -222,6 +226,18 @@ exports.CodeEditorViewOptions = Montage.create(Component, { } }, + handleChange: { + value: function(notification) { + if(notification.currentPropertyPath === "model.currentViewIdentifier") { + if(this.currentDocument.model.currentView.identifier === "design-code") { + //this.application.ninja.documentBar.codeEditorControls.visible = false;//todo + } else { + //this.application.ninja.documentBar.codeEditorControls.visible = false; + } + } + } + }, + handleFormat:{ value: function(evt){ var range = this.getSelectedRange(this.currentDocument.model.views.code.editor); diff --git a/js/components/layout/document-bar.reel/document-bar.html b/js/components/layout/document-bar.reel/document-bar.html index fb505a7c..f073b0e7 100755 --- a/js/components/layout/document-bar.reel/document-bar.html +++ b/js/components/layout/document-bar.reel/document-bar.html @@ -78,12 +78,6 @@ POSSIBILITY OF SUCH DAMAGE. } }, - "codeEditorControls":{ - "prototype": "js/code-editor/ui/code-editor-view-options.reel", - "properties": { - "element": {"#": "codeViewOptions"} - } - }, "owner": { "prototype": "js/components/layout/document-bar.reel", @@ -92,8 +86,7 @@ POSSIBILITY OF SUCH DAMAGE. "zoomControl": {"@": "hottext1"}, "btnDesign": {"#": "buttonDesign"}, "btnCode": {"#": "buttonCode"}, - "btnPreview": {"#": "buttonPreview"}, - "codeEditorControls": {"@": "codeEditorControls"} + "btnPreview": {"#": "buttonPreview"} } } } diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index bf84c652..c1d77668 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -217,6 +217,9 @@ exports.DocumentBar = Montage.create(Component, { value: function () { // this.showView('design', this.renderDesignView, this.btnDesign, this.btnCode); + + //todo - temp + this.application.ninja.documentBar.codeEditorControls.visible = false; } }, //////////////////////////////////////////////////////////////////// @@ -225,6 +228,9 @@ exports.DocumentBar = Montage.create(Component, { value: function () { // this.showView('code', this.renderCodeView, this.btnCode, this.btnDesign); + + //todo - temp + this.application.ninja.documentBar.codeEditorControls.visible = true; } }, //////////////////////////////////////////////////////////////////// diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 70afe785..bf6e186f 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -72,7 +72,9 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { value: function (callback) { this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); - //todo : update options bar + this.textViewContainer.style.display = "block"; + + //todo : update options bar // if (callback) callback(); diff --git a/js/stage/stage.reel/stage.css b/js/stage/stage.reel/stage.css index 56b4c58c..d1277ef1 100755 --- a/js/stage/stage.reel/stage.css +++ b/js/stage/stage.reel/stage.css @@ -68,7 +68,11 @@ POSSIBILITY OF SUCH DAMAGE. .codeViewContainer .CodeMirror-scroll { height: 100%; - overflow: auto; + overflow-y: hidden; +} + +.codeViewContainer .CodeMirror-scrollbar { + display:none; } .codeViewContainer>div{ -- cgit v1.2.3 From e7509af2b2fad6ab23ea07e6e46e88a4ee0d03f1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:29:16 -0700 Subject: adding null check for currentDocument to prevent error Signed-off-by: Ananya Sen --- .../ui/code-editor-view-options.reel/code-editor-view-options.js | 2 +- js/components/layout/document-bar.reel/document-bar.js | 6 ------ js/controllers/styles-controller.js | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) (limited to 'js') 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 70d033fb..2ca6118b 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 @@ -53,7 +53,7 @@ exports.CodeEditorViewOptions = Montage.create(Component, { if(!value || (this._currentDocument.currentView === "design")) { this.visible = false; - } else if(this._currentDocument.currentView === "code") { + } else if(this._currentDocument && this._currentDocument.currentView === "code") { if(this._currentDocument.model.views.design){//code view of design document this.application.ninja.editorViewOptions.visible = false; diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index c1d77668..bf84c652 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -217,9 +217,6 @@ exports.DocumentBar = Montage.create(Component, { value: function () { // this.showView('design', this.renderDesignView, this.btnDesign, this.btnCode); - - //todo - temp - this.application.ninja.documentBar.codeEditorControls.visible = false; } }, //////////////////////////////////////////////////////////////////// @@ -228,9 +225,6 @@ exports.DocumentBar = Montage.create(Component, { value: function () { // this.showView('code', this.renderCodeView, this.btnCode, this.btnDesign); - - //todo - temp - this.application.ninja.documentBar.codeEditorControls.visible = true; } }, //////////////////////////////////////////////////////////////////// diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 0e1df1e9..e95c6614 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -131,7 +131,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { handleChange: { value: function(notification) { if(notification.currentPropertyPath === "model.currentViewIdentifier") { - if(this.currentDocument.model.currentView.identifier === "design") { + if(this.currentDocument && this.currentDocument.model.currentView.identifier === "design") { ///// Stage stylesheet should always be found this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); // Returns null if sheet not found (as in non-ninja projects) -- cgit v1.2.3