Commit c907cf75 by cahrens

Add ACE Editors.

parent 1e68834e
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="value"> <div class="value">
<label for="course-advanced-policy-value">Policy Value:</label> <label for="course-advanced-policy-value">Policy Value:</label>
<div class="field"> <div class="field">
<textarea class="ace text" id="course-advanced-policy-value"><%= value %></textarea> <div class="ace text" id="course-advanced-policy-value"><%= value %></div>
</div> </div>
</div> </div>
</div> <a href="#" class="delete-button standard remove-item advanced-policy-data"> </div> <a href="#" class="delete-button standard remove-item advanced-policy-data">
......
...@@ -42,16 +42,18 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -42,16 +42,18 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var self = this; var self = this;
_.each(_.sortBy(_.keys(this.model.attributes), _.identity), _.each(_.sortBy(_.keys(this.model.attributes), _.identity),
function(key) { function(key) {
// TODO: working here listEle$.append(self.template({ key : key, value : JSON.stringify(self.model.get(key))}));
var newEl = self.template({ key : key, value : self.model.get(key)});
listEle$.append(newEl);
self.fieldToSelectorMap[key] = key; self.fieldToSelectorMap[key] = key;
});
// var editor = ace.edit('course-advanced-policy-1-value'); // Swap in ACE Editor for all the value (JSON) fields.
// editor.setTheme("ace/theme/chrome"); var policyValueDivs = listEle$.find('.ace');
// editor.getSession().setMode("ace/mode/json"); _.each(policyValueDivs,
function (div) {
var editor = ace.edit(div);
editor.setTheme("ace/theme/chrome");
editor.getSession().setMode("ace/mode/json");
editor.setHighlightActiveLine(false);
}); });
return this; return this;
}, },
...@@ -106,7 +108,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -106,7 +108,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var newKey = $(event.currentTarget).val(); var newKey = $(event.currentTarget).val();
console.log('update ', oldKey, newKey); // TODO: REMOVE ME console.log('update ', oldKey, newKey); // TODO: REMOVE ME
if (oldKey !== newKey) { if (oldKey !== newKey) {
// may erase other errors but difficult to just remove these // TODO: is it OK to erase other validation messages?
this.clearValidationErrors(); this.clearValidationErrors();
if (!this.validateKey(oldKey, newKey)) return; if (!this.validateKey(oldKey, newKey)) return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment