FEATURE: Use ACE for badge queries (#5269)

* FEATURE: Use ACE for badge queries

* Forgot disabled

* When disabled, cursor should be `not-allowed`

* Tests + prefix custom attribute with `data-`
This commit is contained in:
OsamaSayegh
2017-10-30 10:07:49 +03:00
committed by Sam
parent fab3e25101
commit 55095bc44e
4 changed files with 74 additions and 2 deletions

View File

@ -1,13 +1,14 @@
import loadScript from 'discourse/lib/load-script';
import { observes } from 'ember-addons/ember-computed-decorators';
const LOAD_ASYNC = !Ember.Test;
const LOAD_ASYNC = !Ember.testing;
export default Ember.Component.extend({
mode: 'css',
classNames: ['ace-wrapper'],
_editor: null,
_skipContentChangeEvent: null,
disabled: false,
@observes('editorId')
editorIdChanged() {
@ -30,6 +31,24 @@ export default Ember.Component.extend({
}
},
@observes('disabled')
disabledStateChanged() {
this.changeDisabledState();
},
changeDisabledState() {
const editor = this._editor;
if (editor) {
const disabled = this.get('disabled');
editor.setOptions({
readOnly: disabled,
highlightActiveLine: !disabled,
highlightGutterLine: !disabled
});
editor.container.parentNode.setAttribute("data-disabled", disabled);
}
},
_destroyEditor: function() {
if (this._editor) {
this._editor.destroy();
@ -76,6 +95,7 @@ export default Ember.Component.extend({
this.$().data('editor', editor);
this._editor = editor;
this.changeDisabledState();
$(window).off('ace:resize').on('ace:resize', ()=>{
this.appEvents.trigger('ace:resize');