diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-10-30 15:41:53 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-10-30 15:42:26 +0200 |
commit | bc36f64ef7c374f4abb404b578f87fdae8575efa (patch) | |
tree | a2b2abfa7a529951c55c13281aee01e5898855ae | |
parent | 5b8fb9c322951adb08ea9aa4f2fa68b94fb013e0 (diff) | |
download | couchdb-1911-ace-editor.tar.gz |
Improvements to views editor1911-ace-editor
-rw-r--r-- | src/fauxton/app/modules/documents/views.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js index 2994556d5..5c22504c8 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -1378,6 +1378,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) { if ($targetId === 'index-nav') { if (this.newView) { return; } $index.toggle('slow'); + this.showEditors(); } else { $index.removeAttr('style'); } @@ -1446,37 +1447,37 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, resizeColumns) { }, afterRender: function() { - var that = this, - mapFun = this.$("#map-function"), - reduceFun = this.$("#reduce-function"); + if (this.params) { + this.advancedOptions.updateFromParams(this.params); + } + this.designDocSelector.updateDesignDoc(); if (this.newView) { - mapFun.val(this.langTemplates[this.defaultLang].map); - reduceFun.val(this.langTemplates[this.defaultLang].reduce); + this.showEditors(); } else { this.$('#index').hide(); this.$('#index-nav').parent().removeClass('active'); } + }, - this.designDocSelector.updateDesignDoc(); - + showEditors: function () { this.mapEditor = new Components.Editor({ editorId: "map-function", mode: "javascript", couchJSHINT: true }); this.mapEditor.render(); - // We can make this better + if (this.hasCustomReduce()) { this.createReduceEditor(); } else { $(".control-group.reduce-function").hide(); } - if (this.params) { - this.advancedOptions.updateFromParams(this.params); - } - + if (this.newView) { + this.mapEditor.setValue(this.langTemplates[this.defaultLang].map); + this.reduceEditor.setValue(this.langTemplates[this.defaultLang].reduce); + } } }); |