2013-07-14 10:00:50 +03:00
|
|
|
'use strict';
|
2013-07-05 06:26:07 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Mixins/AsModelBoundView'
|
|
|
|
], function (Marionette, AsModelBoundView) {
|
|
|
|
|
|
|
|
var view = Marionette.ItemView.extend({
|
|
|
|
template: 'Settings/MediaManagement/Naming/ViewTemplate',
|
|
|
|
|
|
|
|
ui: {
|
2013-07-14 10:00:50 +03:00
|
|
|
namingOptions : '.x-naming-options',
|
2013-08-12 03:42:11 +03:00
|
|
|
renameEpisodesCheckbox: '.x-rename-episodes',
|
|
|
|
singleEpisodeExample : '.x-single-episode-example',
|
|
|
|
multiEpisodeExample : '.x-multi-episode-example'
|
2013-07-05 06:26:07 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
2013-07-14 10:00:50 +03:00
|
|
|
'change .x-rename-episodes': '_setNamingOptionsVisibility'
|
2013-07-05 06:26:07 +03:00
|
|
|
},
|
|
|
|
|
2013-07-14 10:00:50 +03:00
|
|
|
onRender: function(){
|
|
|
|
if(!this.model.get('renameEpisodes')){
|
|
|
|
this.ui.namingOptions.hide();
|
|
|
|
}
|
2013-08-12 03:42:11 +03:00
|
|
|
|
|
|
|
this.listenTo(this.model, 'change', this._buildExamples);
|
|
|
|
this._buildExamples();
|
2013-07-05 06:26:07 +03:00
|
|
|
},
|
|
|
|
|
2013-07-14 10:00:50 +03:00
|
|
|
_setNamingOptionsVisibility: function () {
|
2013-07-05 06:26:07 +03:00
|
|
|
var checked = this.ui.renameEpisodesCheckbox.prop('checked');
|
2013-07-14 10:00:50 +03:00
|
|
|
if (checked) {
|
|
|
|
this.ui.namingOptions.slideDown();
|
2013-07-05 06:26:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2013-07-14 10:00:50 +03:00
|
|
|
this.ui.namingOptions.slideUp();
|
2013-07-05 06:26:07 +03:00
|
|
|
}
|
2013-08-12 03:42:11 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
_buildExamples: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
var data = this.model.toJSON();
|
|
|
|
data.id = 0;
|
|
|
|
|
|
|
|
var promise = $.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url : window.ApiRoot + '/naming',
|
|
|
|
data: JSON.stringify(data)
|
|
|
|
});
|
|
|
|
|
|
|
|
promise.done(function (result) {
|
|
|
|
self.ui.singleEpisodeExample.html(result.singleEpisodeExample);
|
|
|
|
self.ui.multiEpisodeExample.html(result.multiEpisodeExample);
|
|
|
|
});
|
2013-07-05 06:26:07 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return AsModelBoundView.call(view);
|
|
|
|
});
|