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