a little more jquery removal

This commit is contained in:
Luke Pulverenti 2016-06-02 02:08:47 -04:00
parent 31b057360f
commit 471d0fbefc
11 changed files with 202 additions and 122 deletions

View File

@ -810,7 +810,7 @@
Events.on(MediaController, 'playerchange', onPlayerChange); Events.on(MediaController, 'playerchange', onPlayerChange);
$(context.querySelector('.itemsContainer')).createCardMenus(); libraryBrowser.createCardMenus(context.querySelector('.itemsContainer'));
} }

View File

@ -147,7 +147,7 @@
function initPage(tabContent) { function initPage(tabContent) {
$('.itemsContainer', tabContent).on('needsrefresh', function () { tabContent.querySelector('.itemsContainer').addEventListener('needsrefresh', function () {
reloadItems(tabContent); reloadItems(tabContent);
}); });

View File

@ -338,7 +338,7 @@
itemsContainer.innerHTML = html; itemsContainer.innerHTML = html;
ImageLoader.lazyChildren(itemsContainer); ImageLoader.lazyChildren(itemsContainer);
$(itemsContainer).createCardMenus(); LibraryBrowser.createCardMenus(itemsContainer);
}); });
} }
@ -368,7 +368,7 @@
} else { } else {
$('#childrenCollapsible', page).removeClass('hide'); $('#childrenCollapsible', page).removeClass('hide');
} }
renderChildren(page, item, user, context); renderChildren(page, item);
} }
else { else {
$('#childrenCollapsible', page).addClass('hide'); $('#childrenCollapsible', page).addClass('hide');
@ -757,7 +757,10 @@
}); });
html += '</div>'; html += '</div>';
$('#similarContent', page).html(html).lazyChildren().createCardMenus(); var similarContent = page.querySelector('#similarContent');
similarContent.innerHTML = html;
ImageLoader.lazyChildren(similarContent);
LibraryBrowser.createCardMenus(similarContent);
}); });
} }
@ -859,7 +862,7 @@
} }
var _childrenItemsFunction = null; var _childrenItemsFunction = null;
function renderChildren(page, item, user, context) { function renderChildren(page, item) {
_childrenItemsFunction = null; _childrenItemsFunction = null;
@ -875,13 +878,14 @@
query.SortBy = "SortName"; query.SortBy = "SortName";
} }
var userId = Dashboard.getCurrentUserId();
var promise; var promise;
if (item.Type == "Series") { if (item.Type == "Series") {
promise = ApiClient.getSeasons(item.Id, { promise = ApiClient.getSeasons(item.Id, {
userId: user.Id, userId: userId,
Fields: fields Fields: fields
}); });
} }
@ -891,14 +895,14 @@
promise = ApiClient.getEpisodes(item.SeriesId, { promise = ApiClient.getEpisodes(item.SeriesId, {
seasonId: item.Id, seasonId: item.Id,
userId: user.Id, userId: userId,
Fields: fields Fields: fields
}); });
_childrenItemsFunction = getEpisodesFunction(item.SeriesId, { _childrenItemsFunction = getEpisodesFunction(item.SeriesId, {
seasonId: item.Id, seasonId: item.Id,
userId: user.Id, userId: userId,
Fields: fields Fields: fields
}); });
} }
@ -977,7 +981,7 @@
elem.classList.remove('hiddenScrollX'); elem.classList.remove('hiddenScrollX');
} }
$(elem).createCardMenus(); LibraryBrowser.createCardMenus(elem);
if (item.Type == "BoxSet") { if (item.Type == "BoxSet") {
@ -989,7 +993,7 @@
{ name: Globalize.translate('HeaderBooks'), type: 'Book' } { name: Globalize.translate('HeaderBooks'), type: 'Book' }
]; ];
renderCollectionItems(page, item, collectionItemTypes, result.Items, user, context); renderCollectionItems(page, item, collectionItemTypes, result.Items);
} }
}); });
@ -1043,12 +1047,13 @@
}); });
} }
function renderCollectionItems(page, parentItem, types, items, user) { function renderCollectionItems(page, parentItem, types, items) {
// First empty out existing content // First empty out existing content
page.querySelector('.collectionItems').innerHTML = ''; page.querySelector('.collectionItems').innerHTML = '';
var i, length;
for (var i = 0, length = types.length; i < length; i++) { for (i = 0, length = types.length; i < length; i++) {
var type = types[i]; var type = types[i];
@ -1059,7 +1064,7 @@
}); });
if (typeItems.length) { if (typeItems.length) {
renderCollectionItemType(page, parentItem, type, typeItems, user); renderCollectionItemType(page, parentItem, type, typeItems);
} }
} }
@ -1076,17 +1081,20 @@
}); });
if (otherTypeItems.length) { if (otherTypeItems.length) {
renderCollectionItemType(page, parentItem, otherType, otherTypeItems, user); renderCollectionItemType(page, parentItem, otherType, otherTypeItems);
} }
if (!items.length) { if (!items.length) {
renderCollectionItemType(page, parentItem, { name: Globalize.translate('HeaderItems') }, items, user); renderCollectionItemType(page, parentItem, { name: Globalize.translate('HeaderItems') }, items);
} }
$('.collectionItems .itemsContainer', page).createCardMenus(); var containers = page.querySelectorAll('.collectionItems .itemsContainer');
for (i = 0, length = containers.length; i < length; i++) {
LibraryBrowser.createCardMenus(containers[i]);
}
} }
function renderCollectionItemType(page, parentItem, type, items, user, context) { function renderCollectionItemType(page, parentItem, type, items) {
var html = ''; var html = '';
@ -1109,7 +1117,6 @@
shape: shape, shape: shape,
showTitle: true, showTitle: true,
centerText: true, centerText: true,
context: context,
lazy: true, lazy: true,
showDetailsMenu: true, showDetailsMenu: true,
overlayMoreButton: true, overlayMoreButton: true,
@ -1121,14 +1128,9 @@
html += '</div>'; html += '</div>';
var collectionItems = page.querySelector('.collectionItems'); var collectionItems = page.querySelector('.collectionItems');
$(collectionItems).append(html); collectionItems.insertAdjacentHTML('beforeend', html);
ImageLoader.lazyChildren(collectionItems); ImageLoader.lazyChildren(collectionItems);
$(collectionItems).off('removefromcollection').on('removefromcollection', function (e, itemId) {
removeFromCollection(page, parentItem, [itemId], user, context);
});
collectionItems.querySelector('.btnAddToCollection').addEventListener('click', function () { collectionItems.querySelector('.btnAddToCollection').addEventListener('click', function () {
require(['alert'], function (alert) { require(['alert'], function (alert) {
alert({ alert({
@ -1139,7 +1141,7 @@
}); });
} }
function removeFromCollection(page, parentItem, itemIds, user, context) { function removeFromCollection(page, parentItem, itemIds) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -1154,7 +1156,7 @@
}).then(function () { }).then(function () {
renderChildren(page, parentItem, user, context); renderChildren(page, parentItem);
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
} }
@ -2113,6 +2115,13 @@
renderCriticReviews(view, currentItem); renderCriticReviews(view, currentItem);
}); });
view.querySelector('.collectionItems').addEventListener('removefromcollection', function (e) {
var itemId = e.detail.itemId;
removeFromCollection(view, currentItem, [itemId]);
});
//var btnMore = page.querySelectorAll('.btnMoreCommands iron-icon'); //var btnMore = page.querySelectorAll('.btnMoreCommands iron-icon');
//for (var i = 0, length = btnMore.length; i < length; i++) { //for (var i = 0, length = btnMore.length; i < length; i++) {
// btnMore[i].icon = AppInfo.moreIcon; // btnMore[i].icon = AppInfo.moreIcon;

View File

@ -15,7 +15,7 @@
function fadeInRight(elem) { function fadeInRight(elem) {
var pct = browserInfo.mobile ? '2%' : '0.5%'; var pct = browserInfo.mobile ? '2.5%' : '0.5%';
var keyframes = [ var keyframes = [
{ opacity: '0', transform: 'translate3d(' + pct + ', 0, 0)', offset: 0 }, { opacity: '0', transform: 'translate3d(' + pct + ', 0, 0)', offset: 0 },

View File

@ -1,4 +1,4 @@
define(['appSettings', 'appStorage', 'libraryBrowser', 'apphost', 'jQuery', 'itemHelper', 'mediaInfo'], function (appSettings, appStorage, LibraryBrowser, appHost, $, itemHelper, mediaInfo) { define(['appSettings', 'appStorage', 'libraryBrowser', 'apphost', 'itemHelper', 'mediaInfo'], function (appSettings, appStorage, LibraryBrowser, appHost, itemHelper, mediaInfo) {
var showOverlayTimeout; var showOverlayTimeout;
@ -242,9 +242,7 @@
}); });
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
itemsContainer.dispatchEvent(new CustomEvent('timercancelled', { itemsContainer.dispatchEvent(new CustomEvent('timercancelled', {}));
bubbles: true
}));
}); });
}); });
}); });
@ -255,7 +253,7 @@
var displayContextItem = card; var displayContextItem = card;
if (!card.classList.contains('card') && !card.classList.contains('listItem')) { if (!card.classList.contains('card') && !card.classList.contains('listItem')) {
card = $(card).parents('.listItem,.card')[0]; card = parentWithAnyClass(card, ['listItem', 'card']);
} }
var itemId = card.getAttribute('data-itemid'); var itemId = card.getAttribute('data-itemid');
@ -637,13 +635,23 @@
case 'removefromplaylist': case 'removefromplaylist':
var itemsContainer = parentWithClass(card, 'itemsContainer'); var itemsContainer = parentWithClass(card, 'itemsContainer');
if (itemsContainer) { if (itemsContainer) {
$(itemsContainer).trigger('removefromplaylist', [playlistItemId]); itemsContainer.dispatchEvent(new CustomEvent('removefromplaylist', {
detail: {
playlistItemId: playlistItemId
},
cancelable: false
}));
} }
break; break;
case 'removefromcollection': case 'removefromcollection':
var itemsContainer = parentWithClass(card, 'itemsContainer'); var itemsContainer = parentWithClass(card, 'collectionItems');
if (itemsContainer) { if (itemsContainer) {
$(card).parents('.collectionItems').trigger('removefromcollection', [itemId]); itemsContainer.dispatchEvent(new CustomEvent('removefromcollection', {
detail: {
itemId: itemId
},
cancelable: false
}));
} }
break; break;
default: default:
@ -661,7 +669,7 @@
var card = e.target; var card = e.target;
if (!card.classList.contains('card') && !card.classList.contains('listItem')) { if (!card.classList.contains('card') && !card.classList.contains('listItem')) {
card = $(card).parents('.listItem,.card')[0]; card = parentWithAnyClass(card, ['listItem', 'card']);
} }
var id = card.getAttribute('data-itemid'); var id = card.getAttribute('data-itemid');
@ -779,6 +787,25 @@
return false; return false;
} }
function hasAnyClass(elem, classNames) {
return classNames.filter(function (c) {
return elem.classList.contains(c);
}).length > 0;
}
function parentWithAnyClass(elem, classNames) {
while (!elem.classList || !hasAnyClass(elem, classNames)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
function parentWithClass(elem, className) { function parentWithClass(elem, className) {
while (!elem.classList || !elem.classList.contains(className)) { while (!elem.classList || !elem.classList.contains(className)) {
@ -911,17 +938,6 @@
initTapHoldMenus(curr); initTapHoldMenus(curr);
}; };
$.fn.createCardMenus = function (options) {
for (var i = 0, length = this.length; i < length; i++) {
var curr = this[i];
LibraryBrowser.createCardMenus(curr, options);
}
return this;
};
function initTapHoldMenus(elem) { function initTapHoldMenus(elem) {
if (elem.classList.contains('itemsContainer')) { if (elem.classList.contains('itemsContainer')) {
@ -1367,7 +1383,7 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
hideSelections(); hideSelections();
$('.itemsContainer', page).trigger('needsrefresh'); page.querySelector('.itemsContainer').dispatchEvent(new CustomEvent('needsrefresh', {}));
}); });
}); });
}); });
@ -1427,16 +1443,18 @@
function playAllFromHere(index, itemsContainer, method) { function playAllFromHere(index, itemsContainer, method) {
var ids = $('.mediaItem', itemsContainer).get().map(function (i) { var ids = [];
var node = i; var mediaItems = itemsContainer.querySelectorAll('.mediaItem');
for (var i = 0, length = mediaItems.length; i < length; i++) {
var node = mediaItems[i];
var id = node.getAttribute('data-itemid'); var id = node.getAttribute('data-itemid');
while (!id) { while (!id) {
node = node.parentNode; node = node.parentNode;
id = node.getAttribute('data-itemid'); id = node.getAttribute('data-itemid');
} }
return id; ids.push(id);
}); }
ids = ids.slice(index); ids = ids.slice(index);
@ -1468,16 +1486,20 @@
SupportsSync: true SupportsSync: true
}; };
var categorySyncButtons = page.querySelectorAll('.categorySyncButton');
for (var i = 0, length = categorySyncButtons.length; i < length; i++) {
if (LibraryBrowser.enableSync(item, user)) { if (LibraryBrowser.enableSync(item, user)) {
$('.categorySyncButton', page).removeClass('hide'); categorySyncButtons[i].classList.remove('hide');
} else { } else {
$('.categorySyncButton', page).addClass('hide'); categorySyncButtons[i].classList.add('hide');
}
} }
}); });
} }
function onCategorySyncButtonClick(page, button) { function onCategorySyncButtonClick(e) {
var button = this;
var category = button.getAttribute('data-category'); var category = button.getAttribute('data-category');
var parentId = LibraryMenu.getTopParentId(); var parentId = LibraryMenu.getTopParentId();
@ -1496,15 +1518,15 @@
page.addEventListener('click', onItemWithActionClick); page.addEventListener('click', onItemWithActionClick);
var itemsContainers = page.querySelectorAll('.itemsContainer:not(.noautoinit)'); var itemsContainers = page.querySelectorAll('.itemsContainer:not(.noautoinit)');
for (var i = 0, length = itemsContainers.length; i < length; i++) { var i, length;
for (i = 0, length = itemsContainers.length; i < length; i++) {
LibraryBrowser.createCardMenus(itemsContainers[i]); LibraryBrowser.createCardMenus(itemsContainers[i]);
} }
$('.categorySyncButton', page).on('click', function () { var categorySyncButtons = page.querySelectorAll('.categorySyncButton');
for (i = 0, length = categorySyncButtons.length; i < length; i++) {
onCategorySyncButtonClick(page, this); categorySyncButtons[i].addEventListener('click', onCategorySyncButtonClick);
}); }
}); });
pageClassOn('pageshow', "libraryPage", function () { pageClassOn('pageshow', "libraryPage", function () {
@ -1578,18 +1600,21 @@
function onUserDataChanged(userData) { function onUserDataChanged(userData) {
$(document.querySelectorAll("*[data-itemid='" + userData.ItemId + "']")).each(function () { var elems = document.querySelectorAll("*[data-itemid='" + userData.ItemId + "']");
var mediaType = this.getAttribute('data-mediatype'); for (var i = 0, length = elems.length; i < length; i++) {
var elem = elems[i];
var mediaType = elem.getAttribute('data-mediatype');
if (mediaType == 'Video') { if (mediaType == 'Video') {
this.setAttribute('data-positionticks', (userData.PlaybackPositionTicks || 0)); elem.setAttribute('data-positionticks', (userData.PlaybackPositionTicks || 0));
if (this.classList.contains('card')) { if (elem.classList.contains('card')) {
renderUserDataChanges(this, userData); renderUserDataChanges(elem, userData);
}
} }
} }
});
} }
function onWebSocketMessage(e, data) { function onWebSocketMessage(e, data) {

View File

@ -124,10 +124,16 @@
self.initTab = function () { self.initTab = function () {
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']'); var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']');
var containers = tabContent.querySelectorAll('.itemsContainer');
for (var i = 0, length = containers.length; i < length; i++) {
if (enableScrollX()) { if (enableScrollX()) {
$('.itemsContainer', tabContent).addClass('hiddenScrollX').createCardMenus(); containers[i].classList.add('hiddenScrollX');
} else { } else {
$('.itemsContainer', tabContent).removeClass('hiddenScrollX').createCardMenus(); containers[i].classList.remove('hiddenScrollX');
}
LibraryBrowser.createCardMenus(containers[i]);
} }
}; };

View File

@ -291,7 +291,7 @@
reloadItems(context); reloadItems(context);
}); });
$('.itemsContainer', context).on('needsrefresh', function () { context.querySelector('.itemsContainer').addEventListener('needsrefresh', function () {
reloadItems(context); reloadItems(context);
}); });

View File

@ -180,7 +180,7 @@
reloadItems(tabContent); reloadItems(tabContent);
}); });
$('.itemsContainer', tabContent).on('needsrefresh', function () { tabContent.querySelector('.itemsContainer').addEventListener('needsrefresh', function () {
reloadItems(tabContent); reloadItems(tabContent);

View File

@ -258,7 +258,9 @@
$(containers).removeClass('hiddenScrollX'); $(containers).removeClass('hiddenScrollX');
} }
$(containers).createCardMenus(); for (var i = 0, length = containers.length; i < length; i++) {
LibraryBrowser.createCardMenus(containers[i]);
}
}; };
self.renderTab = function () { self.renderTab = function () {

View File

@ -1,4 +1,4 @@
define(['datetime', 'jQuery', 'paper-icon-button-light'], function (datetime, $) { define(['datetime', 'paper-icon-button-light'], function (datetime) {
var currentPlayer; var currentPlayer;
@ -9,8 +9,8 @@
var unmuteButton; var unmuteButton;
var muteButton; var muteButton;
var volumeSlider; var volumeSlider;
var unpauseButton; var unpauseButtons;
var pauseButton; var pauseButtons;
var positionSlider; var positionSlider;
var toggleRepeatButton; var toggleRepeatButton;
var toggleRepeatButtonIcon; var toggleRepeatButtonIcon;
@ -127,6 +127,18 @@
}); });
} }
function onPauseClick() {
if (currentPlayer) {
currentPlayer.pause();
}
}
function onUnpauseClick() {
if (currentPlayer) {
currentPlayer.unpause();
}
}
function bindEvents(elem) { function bindEvents(elem) {
currentTimeElement = elem.querySelector('.nowPlayingBarCurrentTime'); currentTimeElement = elem.querySelector('.nowPlayingBarCurrentTime');
@ -134,49 +146,49 @@
nowPlayingTextElement = elem.querySelector('.nowPlayingBarText'); nowPlayingTextElement = elem.querySelector('.nowPlayingBarText');
nowPlayingUserData = elem.querySelector('.nowPlayingBarUserDataButtons'); nowPlayingUserData = elem.querySelector('.nowPlayingBarUserDataButtons');
unmuteButton = $('.unmuteButton', elem).on('click', function () { unmuteButton = elem.querySelector('.unmuteButton');
unmuteButton.addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.unMute(); currentPlayer.unMute();
} }
}); });
muteButton = $('.muteButton', elem).on('click', function () { muteButton = elem.querySelector('.muteButton');
muteButton.addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.mute(); currentPlayer.mute();
} }
}); });
$('.stopButton', elem).on('click', function () { elem.querySelector('.stopButton').addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.stop(); currentPlayer.stop();
} }
}); });
pauseButton = $('.pauseButton', elem).on('click', function () { var i, length;
pauseButtons = elem.querySelectorAll('.pauseButton');
if (currentPlayer) { for (i = 0, length = pauseButtons.length; i < length; i++) {
currentPlayer.pause(); pauseButtons[i].addEventListener('click', onPauseClick);
} }
}); unpauseButtons = elem.querySelectorAll('.unpauseButton');
for (i = 0, length = unpauseButtons.length; i < length; i++) {
unpauseButton = $('.unpauseButton', elem).on('click', function () { unpauseButtons[i].addEventListener('click', onUnpauseClick);
if (currentPlayer) {
currentPlayer.unpause();
} }
});
$('.nextTrackButton', elem).on('click', function () { elem.querySelector('.nextTrackButton').addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.nextTrack(); currentPlayer.nextTrack();
} }
}); });
$('.previousTrackButton', elem).on('click', function () { elem.querySelector('.previousTrackButton').addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.previousTrack(); currentPlayer.previousTrack();
@ -193,7 +205,8 @@
showRemoteControl(2); showRemoteControl(2);
}); });
toggleRepeatButton = $('.toggleRepeatButton', elem).on('click', function () { toggleRepeatButton = elem.querySelector('.toggleRepeatButton');
toggleRepeatButton.addEventListener('click', function () {
if (currentPlayer) { if (currentPlayer) {
var state = lastPlayerState || {}; var state = lastPlayerState || {};
@ -210,21 +223,24 @@
break; break;
} }
} }
})[0]; });
toggleRepeatButtonIcon = toggleRepeatButton.querySelector('iron-icon'); toggleRepeatButtonIcon = toggleRepeatButton.querySelector('iron-icon');
// Unfortunately this is necessary because the polymer elements might not be ready immediately and there doesn't seem to be an event-driven way to find out when // Unfortunately this is necessary because the polymer elements might not be ready immediately and there doesn't seem to be an event-driven way to find out when
setTimeout(function () { setTimeout(function () {
volumeSlider = $('.nowPlayingBarVolumeSlider', elem).on('change', function () {
volumeSlider = elem.querySelector('.nowPlayingBarVolumeSlider');
volumeSlider.addEventListener('change', function () {
if (currentPlayer) { if (currentPlayer) {
currentPlayer.setVolume(this.value); currentPlayer.setVolume(this.value);
} }
})[0]; });
positionSlider = $('.nowPlayingBarPositionSlider', elem).on('change', function () { positionSlider = elem.querySelector('.nowPlayingBarPositionSlider');
positionSlider.addEventListener('change', function () {
if (currentPlayer && lastPlayerState) { if (currentPlayer && lastPlayerState) {
@ -234,7 +250,7 @@
currentPlayer.seek(Math.floor(newPositionTicks)); currentPlayer.seek(Math.floor(newPositionTicks));
} }
})[0]; });
positionSlider._setPinValue = function (value) { positionSlider._setPinValue = function (value) {
@ -273,7 +289,7 @@
return; return;
} }
require(['jQuery', 'css!css/nowplayingbar.css', 'paper-slider'], function ($) { require(['css!css/nowplayingbar.css', 'paper-slider'], function () {
nowPlayingBarElement = document.querySelector('.nowPlayingBar'); nowPlayingBarElement = document.querySelector('.nowPlayingBar');
@ -282,7 +298,8 @@
return; return;
} }
nowPlayingBarElement = $(getNowPlayingBarHtml()).appendTo(document.body)[0]; document.body.insertAdjacentHTML('beforeend', getNowPlayingBarHtml());
nowPlayingBarElement = document.querySelector('.nowPlayingBar');
if ((browserInfo.safari || !AppInfo.isNativeApp) && browserInfo.mobile) { if ((browserInfo.safari || !AppInfo.isNativeApp) && browserInfo.mobile) {
// Not handled well here. The wrong elements receive events, bar doesn't update quickly enough, etc. // Not handled well here. The wrong elements receive events, bar doesn't update quickly enough, etc.
@ -296,11 +313,11 @@
} }
function showButton(button) { function showButton(button) {
button.removeClass('hide'); button.classList.remove('hide');
} }
function hideButton(button) { function hideButton(button) {
button.addClass('hide'); button.classList.add('hide');
} }
var lastUpdateTime = 0; var lastUpdateTime = 0;
@ -341,16 +358,25 @@
var playerInfo = MediaController.getPlayerInfo(); var playerInfo = MediaController.getPlayerInfo();
var playState = state.PlayState || {}; var playState = state.PlayState || {};
var i, length;
if (playState.IsPaused) { if (playState.IsPaused) {
hideButton(pauseButton); for (i = 0, length = pauseButtons.length; i < length; i++) {
showButton(unpauseButton); hideButton(pauseButtons[i]);
}
for (i = 0, length = unpauseButtons.length; i < length; i++) {
showButton(unpauseButtons[i]);
}
} else { } else {
showButton(pauseButton); for (i = 0, length = pauseButtons.length; i < length; i++) {
hideButton(unpauseButton); showButton(pauseButtons[i]);
}
for (i = 0, length = unpauseButtons.length; i < length; i++) {
hideButton(unpauseButtons[i]);
}
} }
updatePlayerVolumeState(state, playerInfo); updatePlayerVolumeState(state, playerInfo);

View File

@ -100,16 +100,7 @@
} }
ImageLoader.lazyChildren(elem); ImageLoader.lazyChildren(elem);
$(elem).createCardMenus(); LibraryBrowser.createCardMenus(elem);
$(elem).off('needsrefresh').on('needsrefresh', function () {
reloadItems(page, item);
}).off('removefromplaylist').on('removefromplaylist', function (e, playlistItemId) {
removeFromPlaylist(page, item, [playlistItemId]);
});
$('.btnNextPage', elem).on('click', function () { $('.btnNextPage', elem).on('click', function () {
query.StartIndex += query.Limit; query.StartIndex += query.Limit;
@ -189,9 +180,30 @@
}); });
} }
function init(page, item) {
var elem = page.querySelector('#childrenContent .itemsContainer');
elem.addEventListener('removefromplaylist', function (e) {
var playlistItemId = e.detail.playlistItemId;
removeFromPlaylist(page, item, [playlistItemId]);
});
elem.addEventListener('needsrefresh', function () {
reloadItems(page, item);
});
}
window.PlaylistViewer = { window.PlaylistViewer = {
render: function (page, item) { render: function (page, item) {
if (!page.playlistInit) {
page.playlistInit = true;
init(page, item);
}
reloadItems(page, item); reloadItems(page, item);
showDragAndDropHelp(); showDragAndDropHelp();
} }