mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update live tv filters
This commit is contained in:
parent
71cc832d1c
commit
6fb474ce5f
6 changed files with 134 additions and 121 deletions
|
@ -1,15 +1,25 @@
|
|||
define(['paperdialoghelper', 'events', 'paper-checkbox'], function (paperDialogHelper, events) {
|
||||
|
||||
function updateFilterControls(context, query) {
|
||||
function updateFilterControls(context, options) {
|
||||
|
||||
$('.chkStandardFilter', context).each(function () {
|
||||
var query = options.query;
|
||||
|
||||
var filters = "," + (query.Filters || "");
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
if (options.mode == 'livetvchannels') {
|
||||
|
||||
this.checked = filters.indexOf(',' + filterName) != -1;
|
||||
$('.chkFavorite', context).checked(query.IsFavorite == true);
|
||||
$('.chkLikes', context).checked(query.IsLiked == true);
|
||||
$('.chkDislikes', context).checked(query.IsDisliked == true);
|
||||
|
||||
});
|
||||
} else {
|
||||
$('.chkStandardFilter', context).each(function () {
|
||||
|
||||
var filters = "," + (query.Filters || "");
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
|
||||
this.checked = filters.indexOf(',' + filterName) != -1;
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function triggerChange(instance) {
|
||||
|
@ -17,23 +27,67 @@
|
|||
events.trigger(instance, 'filterchange');
|
||||
}
|
||||
|
||||
function bindEvents(instance, context, query) {
|
||||
|
||||
$('.chkStandardFilter', context).on('change', function () {
|
||||
function bindEvents(instance, context, options) {
|
||||
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
var filters = query.Filters || "";
|
||||
var query = options.query;
|
||||
|
||||
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
||||
if (options.mode == 'livetvchannels') {
|
||||
|
||||
if (this.checked) {
|
||||
filters = filters ? (filters + ',' + filterName) : filterName;
|
||||
}
|
||||
$('.chkFavorite', context).on('change', function () {
|
||||
query.StartIndex = 0;
|
||||
query.IsFavorite = this.checked ? true : null;
|
||||
triggerChange(instance);
|
||||
});
|
||||
|
||||
query.StartIndex = 0;
|
||||
query.Filters = filters;
|
||||
triggerChange(instance);
|
||||
});
|
||||
|
||||
$('.chkLikes', context).on('change', function () {
|
||||
|
||||
query.StartIndex = 0;
|
||||
query.IsLiked = this.checked ? true : null;
|
||||
triggerChange(instance);
|
||||
});
|
||||
|
||||
$('.chkDislikes', context).on('change', function () {
|
||||
|
||||
query.StartIndex = 0;
|
||||
query.IsDisliked = this.checked ? true : null;
|
||||
triggerChange(instance);
|
||||
});
|
||||
|
||||
} else {
|
||||
$('.chkStandardFilter', context).on('change', function () {
|
||||
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
var filters = query.Filters || "";
|
||||
|
||||
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
||||
|
||||
if (this.checked) {
|
||||
filters = filters ? (filters + ',' + filterName) : filterName;
|
||||
}
|
||||
|
||||
query.StartIndex = 0;
|
||||
query.Filters = filters;
|
||||
triggerChange(instance);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setVisibility(context, options) {
|
||||
|
||||
if (options.mode == 'livetvchannels') {
|
||||
hideByClass(context, 'nolivetvchannels');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function hideByClass(context, className) {
|
||||
|
||||
var elems = context.querySelectorAll('.' + className);
|
||||
|
||||
for (var i = 0, length = elems.length; i < length; i++) {
|
||||
elems[i].classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
return function (options) {
|
||||
|
@ -57,8 +111,8 @@
|
|||
exitAnimationDuration: 200
|
||||
});
|
||||
|
||||
dlg.classList.add('ui-body-b');
|
||||
dlg.classList.add('background-theme-b');
|
||||
dlg.classList.add('ui-body-a');
|
||||
dlg.classList.add('background-theme-a');
|
||||
|
||||
dlg.classList.add('formDialog');
|
||||
|
||||
|
@ -67,14 +121,15 @@
|
|||
html += Globalize.translateDocument(template);
|
||||
|
||||
dlg.innerHTML = html;
|
||||
setVisibility(dlg, options);
|
||||
document.body.appendChild(dlg);
|
||||
|
||||
paperDialogHelper.open(dlg);
|
||||
|
||||
dlg.addEventListener('iron-overlay-closed', resolve);
|
||||
|
||||
updateFilterControls(dlg, options.query);
|
||||
bindEvents(self, dlg, options.query);
|
||||
updateFilterControls(dlg, options);
|
||||
bindEvents(self, dlg, options);
|
||||
}
|
||||
|
||||
xhr.send();
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<div style="margin: 0;padding:1.5em 2em;">
|
||||
<h1>
|
||||
<h2 style="margin-bottom: .5em;">
|
||||
${HeaderFilters}
|
||||
</h1>
|
||||
|
||||
</h2>
|
||||
<div class="paperCheckboxList">
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="IsPlayed">${OptionPlayed}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="IsUnPlayed">${OptionUnplayed}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="IsResumable">${OptionResumable}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="IsFavorite">${OptionFavorite}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="Likes">${OptionLikes}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter" data-filter="Dislikes">${OptionDislikes}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter nolivetvchannels" data-filter="IsPlayed">${OptionPlayed}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter nolivetvchannels" data-filter="IsUnPlayed">${OptionUnplayed}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter nolivetvchannels" data-filter="IsResumable">${OptionResumable}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter chkFavorite" data-filter="IsFavorite">${OptionFavorite}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter chkLikes" data-filter="Likes">${OptionLikes}</paper-checkbox>
|
||||
<paper-checkbox class="chkStandardFilter chkDislikes" data-filter="Dislikes">${OptionDislikes}</paper-checkbox>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue