Skip to content

Commit

Permalink
Turn editor features (Behave) on/off via settings
Browse files Browse the repository at this point in the history
refs #3.
  • Loading branch information
rwstauner committed Sep 30, 2014
1 parent ccd1c9b commit 939261f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/scripts/view/request.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
define([
"underscore",
"view",
"settings",
"behave",
"highlight",
"tpl!template/request.htm",
"bootstrap-dropdown"
], function(_, View, Behave, hljs, template) {
], function(_, View, settings, Behave, hljs, template) {
return View.extend({
name: "request",
template: template,
Expand Down Expand Up @@ -35,6 +36,7 @@ define([
this.$body.val(this.model.get("body"));
this.validateBody();
});
this.listenTo(settings, 'change:editorFeatures', this._setEditorFeatures);
},
updateResponse: function() {
var res = _.escape(this.model.get("response"));
Expand All @@ -47,12 +49,22 @@ define([
this.$label = this.$(".editor .label").hide();
this.$body = this.$("textarea");
this.$response = this.$('pre code');
new Behave({
textarea: this.$("textarea").get(0),
tabSize: 2
});
this._setEditorFeatures(null, settings.get('editorFeatures'));
this.updateResponse();
return this;
},

_setEditorFeatures: function(m, enabled, o) {
if( this.behave ){
this.behave.destroy();
this.behave = null;
}
if( enabled ){
this.behave = new Behave({
textarea: this.$body.get(0),
tabSize: 2
});
}
}
});
});

0 comments on commit 939261f

Please sign in to comment.