mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-23 22:45:06 -04:00
Helper for configuring naming
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'vent',
|
||||
'marionette',
|
||||
'Settings/MediaManagement/Naming/NamingSampleModel',
|
||||
'Mixins/AsModelBoundView'
|
||||
], function (vent, Marionette, NamingSampleModel, AsModelBoundView) {
|
||||
], function ($, vent, Marionette, NamingSampleModel, AsModelBoundView) {
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/MediaManagement/Naming/NamingViewTemplate',
|
||||
@@ -15,12 +16,14 @@ define(
|
||||
renameEpisodesCheckbox: '.x-rename-episodes',
|
||||
singleEpisodeExample : '.x-single-episode-example',
|
||||
multiEpisodeExample : '.x-multi-episode-example',
|
||||
dailyEpisodeExample : '.x-daily-episode-example'
|
||||
dailyEpisodeExample : '.x-daily-episode-example',
|
||||
namingTokenHelper : '.x-naming-token-helper'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .x-rename-episodes': '_setFailedDownloadOptionsVisibility',
|
||||
'click .x-show-wizard' : '_showWizard'
|
||||
'change .x-rename-episodes' : '_setFailedDownloadOptionsVisibility',
|
||||
'click .x-show-wizard' : '_showWizard',
|
||||
'click .x-naming-token-helper a' : '_addToken'
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
@@ -58,6 +61,28 @@ define(
|
||||
|
||||
_showWizard: function () {
|
||||
vent.trigger(vent.Commands.ShowNamingWizard, { model: this.model });
|
||||
},
|
||||
|
||||
_addToken: function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var target = e.target;
|
||||
var token = '';
|
||||
var input = $(target).closest('.x-helper-input').children('input');
|
||||
|
||||
if ($(target).attr('data-token')) {
|
||||
token = '{{0}}'.format($(target).attr('data-token'));
|
||||
}
|
||||
|
||||
else {
|
||||
token = $(target).attr('data-separator');
|
||||
}
|
||||
|
||||
input.val(input.val() + token);
|
||||
|
||||
this.ui.namingTokenHelper.removeClass('open');
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user