@ -1,145 +1,139 @@
'use strict' ;
define ( [ 'app' , 'AddSeries/RootFolders/RootFolderCollection' , 'AddSeries/Existing/UnmappedFolderModel' , 'AddSeries/SearchResultCollection' , 'Series/SeriesModel' ] , function ( app , rootFolders ) {
define ( [
'app' ,
'AddSeries/RootFolders/RootFolderCollection' ,
'Quality/QualityProfileCollection' ,
'Shared/NotificationCollection' ,
'AddSeries/Existing/UnmappedFolderModel' ,
'AddSeries/SearchResultCollection' ,
'Series/SeriesModel' ] ,
function ( app , rootFolders , qualityProfileCollection , notificationCollection ) {
NzbDrone . AddSeries . Existing . FolderMatchResultView = Backbone . Marionette . ItemView . extend ( {
template : 'AddSeries/Existing/FolderMatchResultViewTemplatate' ,
events : {
'click .x-btn-add' : 'addSeries'
} ,
addSeries : function ( ) {
var seriesId = this . model . get ( 'id' ) ;
var title = this . model . get ( 'seriesName' ) ;
var quality = this . options . qualityProfile . val ( ) ;
var path = this . options . rootFolder + "\\" + title ;
var model = new NzbDrone . Series . SeriesModel ( {
seriesId : seriesId ,
title : title ,
qualityProfileId : quality ,
path : path
} ) ;
var self = this ;
model . save ( undefined , {
success : function ( ) {
var notificationModel = new NzbDrone . Shared . NotificationModel ( {
title : 'Added' ,
message : title ,
level : 'success'
} ) ;
notificationCollection . push ( notificationModel ) ;
self . close ( ) ;
}
} ) ;
}
NzbDrone . AddSeries . Existing . FolderMatchResultView = Backbone . Marionette . ItemView . extend ( {
template : 'AddSeries/Existing/FolderMatchResultViewTemplatate' ,
} ) ;
events : {
'click .x-btn-add' : 'addSeries'
} ,
NzbDrone . AddSeries . Existing . UnmappedFolderCompositeView = Backbone . Marionette . CompositeView . extend ( {
addSeries : function ( ) {
template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate' ,
itemViewContainer : '.x-folder-name-match-results' ,
itemView : NzbDrone . AddSeries . Existing . FolderMatchResultView ,
var seriesId = this . model . get ( 'id' ) ;
var title = this . model . get ( 'seriesName' ) ;
var quality = this . options . qualityProfile . val ( ) ;
var path = this . options . rootFolder + "\\" + title ;
events : {
'click .x-btn-search' : 'search'
} ,
var model = new NzbDrone . Series . SeriesModel ( {
seriesId : seriesId ,
title : title ,
qualityProfileId : quality ,
path : path
} ) ;
ui : {
searchButton : '.x-btn-search' ,
searchText : '.x-txt-search' ,
profileList : '.x-lst-quality-profile'
} ,
var self = this ;
initialize : function ( ) {
this . collection = new NzbDrone . AddSeries . SearchResultCollection ( ) ;
} ,
model . save ( undefined , {
success : function ( ) {
var notificationModel = new NzbDrone . Shared . NotificationModel ( {
title : 'Added' ,
message : title ,
level : 'success'
} ) ;
search : function ( ) {
NzbDrone . Shared . NotificationCollectionView . Instance . collection . add ( notificationModel ) ;
self . close ( ) ;
}
} ) ;
}
var icon = this . ui . searchButton . find ( 'icon' ) ;
} ) ;
icon . removeClass ( 'icon-search' ) . addClass ( 'icon-spin icon-spinner disabled' ) ;
NzbDrone . AddSeries . Existing . UnmappedFolderCompositeView = Backbone . Marionette . CompositeView . extend ( {
var self = this ;
template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate' ,
itemViewContainer : '.x-folder-name-match-results' ,
itemView : NzbDrone . AddSeries . Existing . FolderMatchResultView ,
this . collection . fetch ( {
data : $ . param ( { term : this . ui . searchText . val ( ) } ) ,
success : function ( model ) {
icon . removeClass ( 'icon-spin icon-spinner disabled' ) . addClass ( 'icon-search' ) ;
events : {
'click .x-btn-search' : 'search'
} ,
} ,
fail : function ( ) {
icon . removeClass ( 'icon-spin icon-spinner disabled' ) . addClass ( 'icon-search' ) ;
}
} ) ;
} ,
ui : {
searchButton : '.x-btn-search' ,
searchText : '.x-txt-search' ,
profileList : '.x-lst-quality-profile'
} ,
itemViewOptions : function ( ) {
return {
qualityProfile : this . ui . profileList ,
rootFolder : this . model . get ( 'rootFolder' )
} ;
}
initialize : function ( ) {
this . collection = new NzbDrone . AddSeries . SearchResultCollection ( ) ;
} ,
search : function ( ) {
var icon = this . ui . searchButton . find ( 'icon' ) ;
} ) ;
icon . removeClass ( 'icon-search' ) . addClass ( 'icon-spin icon-spinner disabled' ) ;
NzbDrone . AddSeries . Existing . RootFolderCompositeView = Backbone . Marionette . CompositeView . extend ( {
var self = this ;
template : "AddSeries/Existing/RootFolderCompositeViewTemplate" ,
itemViewContainer : ".x-existing-folder-container" ,
itemView : NzbDrone . AddSeries . Existing . UnmappedFolderCompositeView ,
this . collection . fetch ( {
data : $ . param ( { term : this . ui . searchText . val ( ) } ) ,
success : function ( model ) {
icon . removeClass ( 'icon-spin icon-spinner disabled' ) . addClass ( 'icon-search' ) ;
initialize : function ( ) {
} ,
fail : function ( ) {
icon . removeClass ( 'icon-spin icon-spinner disabled' ) . addClass ( 'icon-search' ) ;
if ( ! this . model ) {
throw "model is required." ;
}
} ) ;
} ,
itemViewOptions : function ( ) {
return {
qualityProfile : this . ui . profileList ,
rootFolder : this . model . get ( 'rootFolder' )
} ;
}
} ) ;
NzbDrone . AddSeries . Existing . RootFolderCompositeView = Backbone . Marionette . CompositeView . extend ( {
template : "AddSeries/Existing/RootFolderCompositeViewTemplate" ,
itemViewContainer : ".x-existing-folder-container" ,
itemView : NzbDrone . AddSeries . Existing . UnmappedFolderCompositeView ,
this . collection = new NzbDrone . AddSeries . Existing . UnmappedFolderCollection ( ) ;
this . refreshItems ( ) ;
this . listenTo ( qualityProfileCollection , 'reset' , this . refreshItems , this ) ;
} ,
initialize : function ( ) {
refreshItems : function ( ) {
this . collection . importItems ( this . model , qualityProfileCollection ) ;
if ( ! this . model ) {
throw "model is required." ;
}
if ( ! this . options . quality ) {
throw "quality collection is required." ;
}
this . collection = new NzbDrone . AddSeries . Existing . UnmappedFolderCollection ( ) ;
this . refreshItems ( ) ;
this . listenTo ( this . options . quality , 'reset' , this . refreshItems , this ) ;
} ,
refreshItems : function ( ) {
this . collection . importItems ( this . model , this . options . quality ) ;
} ,
} ) ;
NzbDrone . AddSeries . Existing . ImportSeriesView = Backbone . Marionette . CollectionView . extend ( {
itemView : NzbDrone . AddSeries . Existing . RootFolderCompositeView ,
} ) ;
initialize: function ( ) {
NzbDrone . AddSeries . Existing . ImportSeriesView = Backbone . Marionette . CollectionView . extend ( {
this . collection = rootFolders ;
itemView : NzbDrone . AddSeries . Existing . RootFolderCompositeView ,
if ( ! this . options . quality ) {
th row "quality collection is required." ;
initialize : function ( ) {
this . collection = rootFolders ;
}
this . itemViewOptions = {
quality : this . options . quality
} ;
}
} ) ;
} ) ;
} ) ;