mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
68eb6b67b0
Closes #4540 - Implements drag & drop to reorder navigation items - Adds a `sort` property to navigation items - Adds a tiny library to enable touch events for drag & drop. It hooks onto jQuery UI. - Sort nav items before being saved - Adds `settings-view-navigation` to route for body class
31 lines
944 B
JavaScript
31 lines
944 B
JavaScript
import BaseView from 'ghost/views/settings/content-base';
|
|
|
|
var SettingsNavigationView = BaseView.extend({
|
|
|
|
didInsertElement: function () {
|
|
var controller = this.get('controller'),
|
|
navContainer = Ember.$('.js-settings-navigation'),
|
|
navElements = '.navigation-item:not(.navigation-item:last-child)';
|
|
|
|
navContainer.sortable({
|
|
handle: '.navigation-item-drag-handle',
|
|
items: navElements,
|
|
|
|
update: function () {
|
|
var indexes = [];
|
|
navContainer.find(navElements).each(function () {
|
|
var order = Ember.$(this).data('order');
|
|
indexes.push(order);
|
|
});
|
|
controller.updateOrder(indexes);
|
|
}
|
|
});
|
|
},
|
|
|
|
willDestroyElement: function () {
|
|
Ember.$('.js-settings-navigation').sortable('destroy');
|
|
}
|
|
|
|
});
|
|
|
|
export default SettingsNavigationView;
|