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