Ghost/core/client/app/views/settings/navigation.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-02-13 07:22:32 +03:00
import Ember from 'ember';
import BaseView from 'ghost/views/settings/content-base';
var SettingsNavigationView = BaseView.extend({
didInsertElement: function () {
2015-02-25 20:20:42 +03:00
var navContainer = Ember.$('.js-settings-navigation'),
navElements = '.navigation-item:not(.navigation-item:last-child)',
self = this;
navContainer.sortable({
handle: '.navigation-item-drag-handle',
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.get('controller').send('moveItem', ui.item.data('start-index'), ui.item.index());
ui.item.remove();
});
}
});
},
willDestroyElement: function () {
Ember.$('.js-settings-navigation').sortable('destroy');
}
});
export default SettingsNavigationView;