This commit is contained in:
Mark McDowall
2013-11-20 17:44:32 -08:00
parent 7a5cee5b8e
commit 9d94c4490f
9 changed files with 74 additions and 60 deletions

View File

@@ -1,13 +1,13 @@
'use strict';
define(
[
'jquery',
'vent',
'marionette',
'Settings/MediaManagement/Naming/NamingSampleModel',
'Settings/MediaManagement/Naming/Wizard/NamingWizardView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function ($, vent, Marionette, NamingSampleModel, AsModelBoundView, AsValidatedView) {
], function (vent, Marionette, NamingSampleModel, NamingWizardView, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/MediaManagement/Naming/NamingViewTemplate',
@@ -28,7 +28,7 @@ define(
},
onRender: function () {
if (!this.model.get('renameEpisodes')) {
if (!this.model.has('renameEpisodes')) {
this.ui.namingOptions.hide();
}
@@ -61,6 +61,10 @@ define(
},
_showWizard: function () {
var modalView = new NamingWizardView();
vent.trigger(vent.Commands.OpenModalCommand, modalView);
this.listenTo(modalView, modalView.formatsUpdated, this._updateFormats);
vent.trigger(vent.Commands.ShowNamingWizard, { model: this.model });
},
@@ -70,20 +74,26 @@ define(
var target = e.target;
var token = '';
var input = $(target).closest('.x-helper-input').children('input');
var input = this.$(target).closest('.x-helper-input').children('input');
if ($(target).attr('data-token')) {
token = '{{0}}'.format($(target).attr('data-token'));
if (this.$(target).attr('data-token')) {
token = '{{0}}'.format(this.$(target).attr('data-token'));
}
else {
token = $(target).attr('data-separator');
token = this.$(target).attr('data-separator');
}
input.val(input.val() + token);
this.ui.namingTokenHelper.removeClass('open');
input.focus();
},
_updateFormats: function (options) {
this.model.set('standardEpisodeFormat', options.standardEpisodeFormat);
this.model.set('dailyEpisodeFormat', options.dailyEpisodeFormat);
this.model.set('multiEpisodeStyle', options.multiEpisodeStyle);
}
});

View File

@@ -10,7 +10,7 @@ define(
includeQuality : true,
replaceSpaces : false,
separator : ' - ',
numberStyle : '2',
numberStyle : 'S{season:00}E{episode:00}',
multiEpisodeStyle : 0
}
});

View File

@@ -22,17 +22,14 @@ define(
'click .x-apply': '_applyNaming'
},
initialize: function (options) {
formatsUpdated: 'formatsUpdated',
initialize: function () {
this.model = new NamingWizardModel();
this.namingModel = options.model;
this.namingSampleModel = new NamingSampleModel();
},
onRender: function () {
if (!this.model.get('renameEpisodes')) {
this.ui.namingOptions.hide();
}
this.listenTo(this.model, 'change', this._buildFormat);
this.listenTo(this.namingSampleModel, 'sync', this._showSamples);
this._buildFormat();
@@ -56,9 +53,14 @@ define(
},
_applyNaming: function () {
this.namingModel.set('standardEpisodeFormat', this.standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', this.dailyEpisodeFormat);
this.namingModel.set('multiEpisodeStyle', this.model.get('multiEpisodeStyle'));
var options = {
standardEpisodeFormat: this.standardEpisodeFormat,
dailyEpisodeFormat: this.dailyEpisodeFormat,
multiEpisodeStyle: this.model.get('multiEpisodeStyle')
};
this.trigger(this.formatsUpdated, options);
vent.trigger(vent.Commands.CloseModalCommand);
},
@@ -82,23 +84,7 @@ define(
this.dailyEpisodeFormat += this.model.get('separator');
}
switch (this.model.get('numberStyle')) {
case '0':
this.standardEpisodeFormat += '{season}x{episode:00}';
break;
case '1':
this.standardEpisodeFormat += '{season:00}x{episode:00}';
break;
case '2':
this.standardEpisodeFormat += 'S{season:00}E{episode:00}';
break;
case '3':
this.standardEpisodeFormat += 's{season:00}e{episode:00}';
break;
default:
this.standardEpisodeFormat += 'Unknown Number Pattern';
}
this.standardEpisodeFormat += this.model.get('numberStyle');
this.dailyEpisodeFormat += '{Air-Date}';
if (this.model.get('includeEpisodeTitle')) {

View File

@@ -89,10 +89,10 @@
<div class="controls">
<select class="inputClass" name="numberStyle">
<option value="0">1x05</option>
<option value="1">01x05</option>
<option value="2">S01E05</option>
<option value="3">s01e05</option>
<option value="{season}x{episode:00}">1x05</option>
<option value="{season:00}x{episode:00}">01x05</option>
<option value="S{season:00}E{episode:00}">S01E05</option>
<option value="s{season:00}e{episode:00}">s01e05</option>
</select>
</div>
</div>

View File

@@ -9,19 +9,22 @@ define(
'Episode/EpisodeDetailsLayout',
'History/Details/HistoryDetailsView',
'System/Logs/Table/Details/LogDetailsView',
'Settings/MediaManagement/Naming/Wizard/NamingWizardView'
], function (vent, AppLayout, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView, LogDetailsView, NamingWizardView) {
], function (vent, AppLayout, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView, LogDetailsView) {
return Marionette.AppRouter.extend({
initialize: function () {
vent.on(vent.Commands.OpenModalCommand, this._openModal, this);
vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
vent.on(vent.Commands.ShowLogDetails, this._showLogDetails, this);
vent.on(vent.Commands.ShowNamingWizard, this._showNamingWizard, this);
},
_openModal: function (view) {
AppLayout.modalRegion.show(view);
},
_closeModal: function () {
@@ -51,11 +54,6 @@ define(
_showLogDetails: function (options) {
var view = new LogDetailsView({ model: options.model });
AppLayout.modalRegion.show(view);
},
_showNamingWizard: function (options) {
var view = new NamingWizardView({ model: options.model });
AppLayout.modalRegion.show(view);
}
});
});

View File

@@ -18,6 +18,7 @@ define(
vent.Commands = {
EditSeriesCommand : 'EditSeriesCommand',
DeleteSeriesCommand: 'DeleteSeriesCommand',
OpenModalCommand : 'OpenModalCommand',
CloseModalCommand : 'CloseModalCommand',
ShowEpisodeDetails : 'ShowEpisodeDetails',
ShowHistoryDetails : 'ShowHistoryDetails',