1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update selection checkboxes

This commit is contained in:
Luke Pulverenti 2016-04-25 14:02:33 -04:00
parent 67bc4c227e
commit 7e7ff80468

View file

@ -671,7 +671,7 @@
if (itemSelectionPanel) {
return onItemSelectionPanelClick(e, itemSelectionPanel);
}
if (card.classList.contains('groupedCard')) {
else if (card.classList.contains('groupedCard')) {
return onGroupedCardClick(e, card);
}
}
@ -891,7 +891,6 @@
element.classList.add('hasTapHold');
manager.on('press', onTapHold);
manager.on('pressup', onTapHoldUp);
});
showTapHoldHelp(element);
@ -952,23 +951,6 @@
return false;
}
function onTapHoldUp(e) {
var itemSelectionPanel = parentWithClass(e.target, 'itemSelectionPanel');
if (itemSelectionPanel) {
if (!parentWithClass(e.target, 'chkItemSelect')) {
var chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
if (chkItemSelect) {
chkItemSelect.checked = !chkItemSelect.checked;
}
}
e.preventDefault();
return false;
}
}
function onItemSelectionPanelClick(e, itemSelectionPanel) {
// toggle the checkbox, if it wasn't clicked on
@ -976,9 +958,14 @@
var chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
if (chkItemSelect) {
var newValue = !chkItemSelect.checked;
chkItemSelect.checked = newValue;
updateItemSelection(chkItemSelect, newValue);
if (chkItemSelect.classList.contains('checkedInitial')) {
chkItemSelect.classList.remove('checkedInitial');
} else {
var newValue = !chkItemSelect.checked;
chkItemSelect.checked = newValue;
updateItemSelection(chkItemSelect, newValue);
}
}
}
@ -991,7 +978,7 @@
updateItemSelection(this, this.checked);
}
function showSelection(item) {
function showSelection(item, isChecked) {
var itemSelectionPanel = item.querySelector('.itemSelectionPanel');
@ -1002,12 +989,16 @@
item.querySelector('.cardContent').appendChild(itemSelectionPanel);
var chkItemSelect = document.createElement('paper-checkbox');
chkItemSelect.classList.add('chkItemSelect');
$(chkItemSelect).on('change', onSelectionChange);
itemSelectionPanel.appendChild(chkItemSelect);
var cssClass = 'chkItemSelect';
if (isChecked && !browserInfo.firefox) {
// In firefox, the initial tap hold doesnt' get treated as a click
// In other browsers it does, so we need to make sure that initial click is ignored
cssClass += ' checkedInitial';
}
var checkedAttribute = isChecked ? ' checked' : '';
itemSelectionPanel.innerHTML = '<paper-checkbox class="' + cssClass + '"' + checkedAttribute + '></paper-checkbox>';
var chkItemSelect = itemSelectionPanel.querySelector('paper-checkbox');
chkItemSelect.addEventListener('change', onSelectionChange);
}
}
@ -1059,7 +1050,10 @@
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.9 },
{ transform: 'translate3d(0, 0, 0)', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
if (elem.animate) {
elem.animate(keyframes, timing);
}
}
function showSelections(initialCard) {
@ -1067,11 +1061,10 @@
require(['paper-checkbox'], function () {
var cards = document.querySelectorAll('.card');
for (var i = 0, length = cards.length; i < length; i++) {
showSelection(cards[i]);
showSelection(cards[i], initialCard == cards[i]);
}
showSelectionCommands();
initialCard.querySelector('.chkItemSelect').checked = true;
updateItemSelection(initialCard, true);
});
}