2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2015-01-11 19:55:52 +00:00
|
|
|
|
2015-06-13 09:34:09 -05:00
|
|
|
export default Ember.Component.extend({
|
|
|
|
tagName: 'section',
|
|
|
|
classNames: 'gh-view',
|
2015-02-03 16:29:01 +00:00
|
|
|
|
|
|
|
didInsertElement: function () {
|
2015-06-13 09:34:09 -05:00
|
|
|
var navContainer = this.$('.js-gh-blognav'),
|
2015-05-25 14:17:14 +01:00
|
|
|
navElements = '.gh-blognav-item:not(.gh-blognav-item:last-child)',
|
2015-02-25 17:20:42 +00:00
|
|
|
self = this;
|
2015-02-03 16:29:01 +00:00
|
|
|
|
2015-09-16 18:02:06 +01:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2015-02-03 16:29:01 +00:00
|
|
|
navContainer.sortable({
|
2015-05-25 14:17:14 +01:00
|
|
|
handle: '.gh-blognav-grab',
|
2015-02-03 16:29:01 +00:00
|
|
|
items: navElements,
|
|
|
|
|
2015-02-25 17:20:42 +00:00
|
|
|
start: function (event, ui) {
|
|
|
|
Ember.run(function () {
|
|
|
|
ui.item.data('start-index', ui.item.index());
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
update: function (event, ui) {
|
|
|
|
Ember.run(function () {
|
2015-06-13 09:34:09 -05:00
|
|
|
self.sendAction('moveItem', ui.item.data('start-index'), ui.item.index());
|
2015-02-03 16:29:01 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement: function () {
|
2015-09-16 18:02:06 +01:00
|
|
|
this.$('.ui-sortable').sortable('destroy');
|
2015-02-03 16:29:01 +00:00
|
|
|
}
|
2015-01-14 14:46:29 +00:00
|
|
|
});
|