2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2015-01-11 22:55:52 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {Component, run} = Ember;
|
|
|
|
|
|
|
|
export default Component.extend({
|
2015-06-13 17:34:09 +03:00
|
|
|
tagName: 'section',
|
|
|
|
classNames: 'gh-view',
|
2015-02-03 19:29:01 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
didInsertElement() {
|
|
|
|
let navContainer = this.$('.js-gh-blognav');
|
|
|
|
let navElements = '.gh-blognav-item:not(.gh-blognav-item:last-child)';
|
2015-12-28 03:25:36 +03:00
|
|
|
// needed because jqueryui sortable doesn't trigger babel's autoscoping
|
|
|
|
let _this = this;
|
2015-02-03 19:29:01 +03:00
|
|
|
|
2015-09-16 20:02:06 +03:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2015-02-03 19:29:01 +03:00
|
|
|
navContainer.sortable({
|
2015-05-25 16:17:14 +03:00
|
|
|
handle: '.gh-blognav-grab',
|
2015-02-03 19:29:01 +03:00
|
|
|
items: navElements,
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
start(event, ui) {
|
|
|
|
run(() => {
|
2015-02-25 20:20:42 +03:00
|
|
|
ui.item.data('start-index', ui.item.index());
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
update(event, ui) {
|
|
|
|
run(() => {
|
2015-12-28 03:25:36 +03:00
|
|
|
_this.sendAction('moveItem', ui.item.data('start-index'), ui.item.index());
|
2015-02-03 19:29:01 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
willDestroyElement() {
|
2015-11-15 14:06:49 +03:00
|
|
|
this._super(...arguments);
|
2015-09-16 20:02:06 +03:00
|
|
|
this.$('.ui-sortable').sortable('destroy');
|
2015-02-03 19:29:01 +03:00
|
|
|
}
|
2015-01-14 17:46:29 +03:00
|
|
|
});
|