2013-06-22 06:24:24 +00:00
|
|
|
|
'use strict';
|
2013-06-21 01:43:58 +00:00
|
|
|
|
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'marionette',
|
|
|
|
|
'AddSeries/RootFolders/CollectionView',
|
|
|
|
|
'AddSeries/RootFolders/Collection',
|
2013-06-21 05:19:41 +00:00
|
|
|
|
'AddSeries/RootFolders/Model',
|
2013-06-21 01:43:58 +00:00
|
|
|
|
'Mixins/AutoComplete'
|
|
|
|
|
], function (Marionette, RootFolderCollectionView, RootFolderCollection, RootFolderModel) {
|
|
|
|
|
|
|
|
|
|
return Marionette.Layout.extend({
|
|
|
|
|
template: 'AddSeries/RootFolders/LayoutTemplate',
|
|
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
|
pathInput: '.x-path input'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
currentDirs: '#current-dirs'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-06-28 00:00:55 +00:00
|
|
|
|
'click .x-add': '_addFolder'
|
2013-06-21 01:43:58 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
|
this.collection = RootFolderCollection;
|
|
|
|
|
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
|
|
|
|
|
this.rootfolderListView.on('itemview:folderSelected', this._onFolderSelected, this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
|
|
|
|
|
this.currentDirs.show(this.rootfolderListView);
|
|
|
|
|
this.ui.pathInput.autoComplete('/directories');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_onFolderSelected: function (options) {
|
|
|
|
|
this.trigger('folderSelected', options);
|
|
|
|
|
},
|
|
|
|
|
|
2013-06-28 00:00:55 +00:00
|
|
|
|
_addFolder: function () {
|
2013-06-21 01:43:58 +00:00
|
|
|
|
var newDir = new RootFolderModel({
|
|
|
|
|
Path: this.ui.pathInput.val()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
RootFolderCollection.create(newDir, {
|
|
|
|
|
wait: true, success: function () {
|
|
|
|
|
RootFolderCollection.fetch();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|