1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-navigation.js
Austin Burdine 820c86219f fix autoscoping of _this in settings/navigation
closes #6267
- adds a hardcoded this because babel's autoscoping isn't triggered by default
2015-12-27 17:25:36 -07:00

39 lines
1 KiB
JavaScript

import Ember from 'ember';
const {Component, run} = Ember;
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');
}
});