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