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-05-25 14:17:14 +01:00
|
|
|
var navContainer = Ember.$('.js-gh-blognav'),
|
|
|
|
navElements = '.gh-blognav-item:not(.gh-blognav-item:last-child)',
|
2015-02-25 17:20:42 +00:00
|
|
|
self = this;
|
2015-02-03 16:29:01 +00:00
|
|
|
|
|
|
|
navContainer.sortable({
|
2015-05-25 14:17:14 +01:00
|
|
|
handle: '.gh-blognav-grab',
|
2015-02-03 16:29:01 +00:00
|
|
|
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 () {
|
2015-05-25 14:17:14 +01:00
|
|
|
Ember.$('.js-gh-blognav').sortable('destroy');
|
2015-02-03 16:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 14:46:29 +00:00
|
|
|
});
|
2015-01-11 19:55:52 +00:00
|
|
|
|
|
|
|
export default SettingsNavigationView;
|