2015-01-11 22:55:52 +03:00
|
|
|
import BaseView from 'ghost/views/settings/content-base';
|
|
|
|
|
2015-01-14 17:46:29 +03:00
|
|
|
var SettingsNavigationView = BaseView.extend({
|
2015-02-03 19:29:01 +03:00
|
|
|
|
|
|
|
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;
|
2015-02-03 19:29:01 +03:00
|
|
|
|
|
|
|
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();
|
2015-02-03 19:29:01 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement: function () {
|
|
|
|
Ember.$('.js-settings-navigation').sortable('destroy');
|
|
|
|
}
|
|
|
|
|
2015-01-14 17:46:29 +03:00
|
|
|
});
|
2015-01-11 22:55:52 +03:00
|
|
|
|
|
|
|
export default SettingsNavigationView;
|