mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
fb239054a0
follow up from #95 - converts components to use ember-cli-shims
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import Component from 'ember-component';
|
|
import run from 'ember-runloop';
|
|
|
|
export default Component.extend({
|
|
tagName: 'section',
|
|
classNames: 'gh-view',
|
|
|
|
didInsertElement() {
|
|
let navContainer = this.$('.js-gh-blognav');
|
|
let navElements = '.gh-blognav-item:not(.gh-blognav-item:last-child)';
|
|
// needed because jqueryui sortable doesn't trigger babel's autoscoping
|
|
let _this = this;
|
|
|
|
this._super(...arguments);
|
|
|
|
navContainer.sortable({
|
|
handle: '.gh-blognav-grab',
|
|
items: navElements,
|
|
|
|
start(event, ui) {
|
|
run(() => {
|
|
ui.item.data('start-index', ui.item.index());
|
|
});
|
|
},
|
|
|
|
update(event, ui) {
|
|
run(() => {
|
|
_this.sendAction('moveItem', ui.item.data('start-index'), ui.item.index());
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
willDestroyElement() {
|
|
this._super(...arguments);
|
|
this.$('.ui-sortable').sortable('destroy');
|
|
}
|
|
});
|