0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/views/settings/navigation.js
Paul Adam Davis 68eb6b67b0 Drag & Drop Navigation Reordering
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
2015-02-12 17:02:46 +00:00

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;