Skip to content

Commit

Permalink
Trigger the form field's change() method so the CMS edit button highl…
Browse files Browse the repository at this point in the history
…ight appropriately
  • Loading branch information
nathancox committed Jun 16, 2017
1 parent 7c250e8 commit 4f34cc7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions javascript/CodeEditorField.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(function($) {

$.entwine('ss', function($) {
$('textarea.codeeditor').entwine({
Editor: false,

onmatch: function() {
onmatch: function(e) {
var textarea = this;

// hide the textarea
Expand All @@ -13,10 +12,8 @@
// create the editor div
var divID = this.attr('id') + '_Ace';
var $div = this.getEditorEl();

$div.insertAfter(this);


$div.insertAfter(this);
ace.config.set('modePath', this.data('ace-path'));
ace.config.set('workerPath', this.data('ace-path'));
ace.config.set('themePath', this.data('ace-path'));
Expand All @@ -28,6 +25,7 @@
editor.getSession().setValue(textarea.val());
editor.getSession().on('change', function(){
textarea.val(editor.getSession().getValue());
textarea.change();
});

editor.setAutoScrollEditorIntoView(false);
Expand All @@ -42,14 +40,16 @@
if (this.data('theme')) {
editor.setTheme('ace/theme/' + this.data('theme'));
}

var lineHeight = (editor.renderer.lineHeight > 1 ? editor.renderer.lineHeight : 16)

$div.css('min-height', lineHeight * textarea.attr('rows') + 35 + 'px');

editor.resize(true);
this.setEditor(editor);
this.addClass('done');

this._super(e);
},

getEditorEl: function() {
Expand Down

0 comments on commit 4f34cc7

Please sign in to comment.