Ghost/core/client/app/components/gh-navigation.js

34 lines
937 B
JavaScript
Raw Normal View History

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