diff --git a/ghost/admin/app/components/gh-activating-list-item.js b/ghost/admin/app/components/gh-activating-list-item.js index ee3e480ed4..06fbec9b74 100644 --- a/ghost/admin/app/components/gh-activating-list-item.js +++ b/ghost/admin/app/components/gh-activating-list-item.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -const {Component, on, run} = Ember; +const {Component, run} = Ember; export default Component.extend({ tagName: 'li', @@ -8,9 +8,9 @@ export default Component.extend({ active: false, linkClasses: null, - unfocusLink: on('click', function () { + click() { this.$('a').blur(); - }), + }, actions: { setActive(value) { diff --git a/ghost/admin/app/components/gh-selectize.js b/ghost/admin/app/components/gh-selectize.js index a354af1f27..3f3cfa0b5e 100644 --- a/ghost/admin/app/components/gh-selectize.js +++ b/ghost/admin/app/components/gh-selectize.js @@ -2,7 +2,7 @@ import Ember from 'ember'; import EmberSelectizeComponent from 'ember-cli-selectize/components/ember-selectize'; -const {computed, isArray, isBlank, get, on, run} = Ember; +const {computed, isArray, isBlank, get, run} = Ember; const emberA = Ember.A; export default EmberSelectizeComponent.extend({ @@ -15,28 +15,6 @@ export default EmberSelectizeComponent.extend({ return options; }), - _dontOpenWhenBlank: on('didInsertElement', function () { - let openOnFocus = this.get('openOnFocus'); - - if (!openOnFocus) { - run.schedule('afterRender', this, function () { - let selectize = this._selectize; - if (selectize) { - selectize.on('dropdown_open', function () { - if (isBlank(selectize.$control_input.val())) { - selectize.close(); - } - }); - selectize.on('type', function (filter) { - if (isBlank(filter)) { - selectize.close(); - } - }); - } - }); - } - }), - /** * Event callback that is triggered when user creates a tag * - modified to pass the caret position to the action @@ -105,9 +83,7 @@ export default EmberSelectizeComponent.extend({ // we have a re-order, update the selection args.forEach((value) => { let obj = selection.find(function (item) { - // jscs:disable - return (get(item, valuePath) + '') === value; - // jscs:enable + return `${get(item, valuePath)}` === value; }); if (obj) { @@ -116,6 +92,33 @@ export default EmberSelectizeComponent.extend({ }); this.set('selection', reorderedSelection); + }, + + _preventOpeningWhenBlank() { + let openOnFocus = this.get('openOnFocus'); + + if (!openOnFocus) { + run.schedule('afterRender', this, function () { + let selectize = this._selectize; + if (selectize) { + selectize.on('dropdown_open', function () { + if (isBlank(selectize.$control_input.val())) { + selectize.close(); + } + }); + selectize.on('type', function (filter) { + if (isBlank(filter)) { + selectize.close(); + } + }); + } + }); + } + }, + + didInsertElement() { + this._super(...arguments); + this._preventOpeningWhenBlank(); } }); diff --git a/ghost/admin/app/components/gh-skip-link.js b/ghost/admin/app/components/gh-skip-link.js index 275ddd10d3..960ba08b81 100644 --- a/ghost/admin/app/components/gh-skip-link.js +++ b/ghost/admin/app/components/gh-skip-link.js @@ -1,7 +1,7 @@ /*jshint scripturl:true*/ import Ember from 'ember'; -const {$, Component, on} = Ember; +const {$, Component} = Ember; export default Component.extend({ tagName: 'a', @@ -15,7 +15,7 @@ export default Component.extend({ // anchor behaviors or ignored href: Ember.String.htmlSafe('javascript:;'), - scrollTo: on('click', function () { + click() { let anchor = this.get('anchor'); let $el = Ember.$(anchor); @@ -32,5 +32,5 @@ export default Component.extend({ $(this).removeAttr('tabindex'); }).focus(); } - }) + } }); diff --git a/ghost/admin/app/components/gh-trim-focus-input.js b/ghost/admin/app/components/gh-trim-focus-input.js index ddd1645d13..14edd47123 100644 --- a/ghost/admin/app/components/gh-trim-focus-input.js +++ b/ghost/admin/app/components/gh-trim-focus-input.js @@ -1,7 +1,7 @@ /*global device*/ import Ember from 'ember'; -const {TextField, computed, on} = Ember; +const {TextField, computed} = Ember; export default TextField.extend({ focus: true, @@ -16,16 +16,26 @@ export default TextField.extend({ return false; }), - focusField: on('didInsertElement', function () { + _focusField() { // This fix is required until Mobile Safari has reliable // autofocus, select() or focus() support if (this.get('focus') && !device.ios()) { this.$().val(this.$().val()).focus(); } - }), + }, - trimValue: on('focusOut', function () { + _trimValue() { let text = this.$().val(); this.$().val(text.trim()); - }) + }, + + didInsertElement() { + this._super(...arguments); + this._focusField(); + }, + + focusOut() { + this._super(...arguments); + this._trimValue(); + } });