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

Unminify using 1.5.323

Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
Vasily 2019-01-10 15:39:37 +03:00
parent 4678528d00
commit de6ac33ec1
289 changed files with 78483 additions and 54701 deletions

View file

@ -1,64 +1,175 @@
define(["connectionManager", "serverNotifications", "events", "globalize", "emby-button"], function(connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
"use strict";
define(['connectionManager', 'serverNotifications', 'events', 'globalize', 'emby-button'], function (connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
'use strict';
function addNotificationEvent(instance, name, handler) {
var localHandler = handler.bind(instance);
events.on(serverNotifications, name, localHandler), instance[name] = localHandler
events.on(serverNotifications, name, localHandler);
instance[name] = localHandler;
}
function removeNotificationEvent(instance, name) {
var handler = instance[name];
handler && (events.off(serverNotifications, name, handler), instance[name] = null)
if (handler) {
events.off(serverNotifications, name, handler);
instance[name] = null;
}
}
function onClick(e) {
var button = this,
id = button.getAttribute("data-id"),
serverId = button.getAttribute("data-serverid"),
apiClient = connectionManager.getApiClient(serverId);
button.classList.contains("playstatebutton-played") ? (apiClient.markUnplayed(apiClient.getCurrentUserId(), id, new Date), setState(button, !1)) : (apiClient.markPlayed(apiClient.getCurrentUserId(), id, new Date), setState(button, !0))
var button = this;
var id = button.getAttribute('data-id');
var serverId = button.getAttribute('data-serverid');
var apiClient = connectionManager.getApiClient(serverId);
if (!button.classList.contains('playstatebutton-played')) {
apiClient.markPlayed(apiClient.getCurrentUserId(), id, new Date());
setState(button, true);
} else {
apiClient.markUnplayed(apiClient.getCurrentUserId(), id, new Date());
setState(button, false);
}
}
function onUserDataChanged(e, apiClient, userData) {
var button = this;
userData.ItemId === button.getAttribute("data-id") && setState(button, userData.Played)
if (userData.ItemId === button.getAttribute('data-id')) {
setState(button, userData.Played);
}
}
function setState(button, played, updateAttribute) {
var icon = button.iconElement;
icon || (button.iconElement = button.querySelector("i"), icon = button.iconElement), played ? (button.classList.add("playstatebutton-played"), icon && (icon.classList.add("playstatebutton-icon-played"), icon.classList.remove("playstatebutton-icon-unplayed"))) : (button.classList.remove("playstatebutton-played"), icon && (icon.classList.remove("playstatebutton-icon-played"), icon.classList.add("playstatebutton-icon-unplayed"))), !1 !== updateAttribute && button.setAttribute("data-played", played)
if (!icon) {
button.iconElement = button.querySelector('i');
icon = button.iconElement;
}
if (played) {
button.classList.add('playstatebutton-played');
if (icon) {
icon.classList.add('playstatebutton-icon-played');
icon.classList.remove('playstatebutton-icon-unplayed');
}
} else {
button.classList.remove('playstatebutton-played');
if (icon) {
icon.classList.remove('playstatebutton-icon-played');
icon.classList.add('playstatebutton-icon-unplayed');
}
}
if (updateAttribute !== false) {
button.setAttribute('data-played', played);
}
}
function setTitle(button, itemType) {
button.title = "AudioBook" !== itemType && "AudioPodcast" !== itemType ? globalize.translate("sharedcomponents#Watched") : globalize.translate("sharedcomponents#Played");
var text = button.querySelector(".button-text");
text && (text.innerHTML = button.title)
if (itemType !== 'AudioBook' && itemType !== 'AudioPodcast') {
button.title = globalize.translate('sharedcomponents#Watched');
} else {
button.title = globalize.translate('sharedcomponents#Played');
}
var text = button.querySelector('.button-text');
if (text) {
text.innerHTML = button.title;
}
}
function clearEvents(button) {
button.removeEventListener("click", onClick), removeNotificationEvent(button, "UserDataChanged")
button.removeEventListener('click', onClick);
removeNotificationEvent(button, 'UserDataChanged');
}
function bindEvents(button) {
clearEvents(button), button.addEventListener("click", onClick), addNotificationEvent(button, "UserDataChanged", onUserDataChanged)
clearEvents(button);
button.addEventListener('click', onClick);
addNotificationEvent(button, 'UserDataChanged', onUserDataChanged);
}
var EmbyPlaystateButtonPrototype = Object.create(EmbyButtonPrototype);
EmbyPlaystateButtonPrototype.createdCallback = function() {
EmbyButtonPrototype.createdCallback && EmbyButtonPrototype.createdCallback.call(this)
}, EmbyPlaystateButtonPrototype.attachedCallback = function() {
EmbyButtonPrototype.attachedCallback && EmbyButtonPrototype.attachedCallback.call(this);
var itemId = this.getAttribute("data-id"),
serverId = this.getAttribute("data-serverid");
itemId && serverId && (setState(this, "true" === this.getAttribute("data-played"), !1), bindEvents(this), setTitle(this, this.getAttribute("data-type")))
}, EmbyPlaystateButtonPrototype.detachedCallback = function() {
EmbyButtonPrototype.detachedCallback && EmbyButtonPrototype.detachedCallback.call(this), clearEvents(this), this.iconElement = null
}, EmbyPlaystateButtonPrototype.setItem = function(item) {
EmbyPlaystateButtonPrototype.createdCallback = function () {
// base method
if (EmbyButtonPrototype.createdCallback) {
EmbyButtonPrototype.createdCallback.call(this);
}
};
EmbyPlaystateButtonPrototype.attachedCallback = function () {
// base method
if (EmbyButtonPrototype.attachedCallback) {
EmbyButtonPrototype.attachedCallback.call(this);
}
var itemId = this.getAttribute('data-id');
var serverId = this.getAttribute('data-serverid');
if (itemId && serverId) {
setState(this, this.getAttribute('data-played') === 'true', false);
bindEvents(this);
setTitle(this, this.getAttribute('data-type'));
}
};
EmbyPlaystateButtonPrototype.detachedCallback = function () {
// base method
if (EmbyButtonPrototype.detachedCallback) {
EmbyButtonPrototype.detachedCallback.call(this);
}
clearEvents(this);
this.iconElement = null;
};
EmbyPlaystateButtonPrototype.setItem = function (item) {
if (item) {
this.setAttribute("data-id", item.Id), this.setAttribute("data-serverid", item.ServerId);
setState(this, item.UserData && item.UserData.Played), bindEvents(this), setTitle(this, item.Type)
} else this.removeAttribute("data-id"), this.removeAttribute("data-serverid"), this.removeAttribute("data-played"), clearEvents(this)
}, document.registerElement("emby-playstatebutton", {
this.setAttribute('data-id', item.Id);
this.setAttribute('data-serverid', item.ServerId);
var played = item.UserData && item.UserData.Played;
setState(this, played);
bindEvents(this);
setTitle(this, item.Type);
} else {
this.removeAttribute('data-id');
this.removeAttribute('data-serverid');
this.removeAttribute('data-played');
clearEvents(this);
}
};
document.registerElement('emby-playstatebutton', {
prototype: EmbyPlaystateButtonPrototype,
extends: "button"
})
extends: 'button'
});
});

View file

@ -1,78 +1,204 @@
define(["connectionManager", "serverNotifications", "events", "globalize", "emby-button"], function(connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
"use strict";
define(['connectionManager', 'serverNotifications', 'events', 'globalize', 'emby-button'], function (connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
'use strict';
function addNotificationEvent(instance, name, handler) {
var localHandler = handler.bind(instance);
events.on(serverNotifications, name, localHandler), instance[name] = localHandler
events.on(serverNotifications, name, localHandler);
instance[name] = localHandler;
}
function removeNotificationEvent(instance, name) {
var handler = instance[name];
handler && (events.off(serverNotifications, name, handler), instance[name] = null)
if (handler) {
events.off(serverNotifications, name, handler);
instance[name] = null;
}
}
function showPicker(button, apiClient, itemId, likes, isFavorite) {
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), itemId, !isFavorite)
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), itemId, !isFavorite);
}
function onClick(e) {
var button = this,
id = button.getAttribute("data-id"),
serverId = button.getAttribute("data-serverid"),
apiClient = connectionManager.getApiClient(serverId),
likes = this.getAttribute("data-likes"),
isFavorite = "true" === this.getAttribute("data-isfavorite");
likes = "true" === likes || "false" !== likes && null, showPicker(button, apiClient, id, likes, isFavorite).then(function(userData) {
setState(button, userData.Likes, userData.IsFavorite)
})
var button = this;
var id = button.getAttribute('data-id');
var serverId = button.getAttribute('data-serverid');
var apiClient = connectionManager.getApiClient(serverId);
var likes = this.getAttribute('data-likes');
var isFavorite = this.getAttribute('data-isfavorite') === 'true';
if (likes === 'true') {
likes = true;
}
else if (likes === 'false') {
likes = false;
} else {
likes = null;
}
showPicker(button, apiClient, id, likes, isFavorite).then(function (userData) {
setState(button, userData.Likes, userData.IsFavorite);
});
}
function onUserDataChanged(e, apiClient, userData) {
var button = this;
userData.ItemId === button.getAttribute("data-id") && setState(button, userData.Likes, userData.IsFavorite)
if (userData.ItemId === button.getAttribute('data-id')) {
setState(button, userData.Likes, userData.IsFavorite);
}
}
function setState(button, likes, isFavorite, updateAttribute) {
var icon = button.querySelector("i");
isFavorite ? (icon && (icon.innerHTML = "", icon.classList.add("ratingbutton-icon-withrating")), button.classList.add("ratingbutton-withrating")) : (icon && (icon.innerHTML = "", icon.classList.remove("ratingbutton-icon-withrating")), button.classList.remove("ratingbutton-withrating")), !1 !== updateAttribute && (button.setAttribute("data-isfavorite", isFavorite), button.setAttribute("data-likes", null === likes ? "" : likes))
var icon = button.querySelector('i');
if (isFavorite) {
if (icon) {
icon.innerHTML = '';
icon.classList.add('ratingbutton-icon-withrating');
}
button.classList.add('ratingbutton-withrating');
} else if (likes) {
if (icon) {
icon.innerHTML = '';
icon.classList.remove('ratingbutton-icon-withrating');
//icon.innerHTML = '';
}
button.classList.remove('ratingbutton-withrating');
} else if (likes === false) {
if (icon) {
icon.innerHTML = '';
icon.classList.remove('ratingbutton-icon-withrating');
//icon.innerHTML = '';
}
button.classList.remove('ratingbutton-withrating');
} else {
if (icon) {
icon.innerHTML = '';
icon.classList.remove('ratingbutton-icon-withrating');
//icon.innerHTML = '';
}
button.classList.remove('ratingbutton-withrating');
}
if (updateAttribute !== false) {
button.setAttribute('data-isfavorite', isFavorite);
button.setAttribute('data-likes', (likes === null ? '' : likes));
}
}
function setTitle(button) {
button.title = globalize.translate("sharedcomponents#Favorite");
var text = button.querySelector(".button-text");
text && (text.innerHTML = button.title)
button.title = globalize.translate('sharedcomponents#Favorite');
var text = button.querySelector('.button-text');
if (text) {
text.innerHTML = button.title;
}
}
function clearEvents(button) {
button.removeEventListener("click", onClick), removeNotificationEvent(button, "UserDataChanged")
button.removeEventListener('click', onClick);
removeNotificationEvent(button, 'UserDataChanged');
}
function bindEvents(button) {
clearEvents(button), button.addEventListener("click", onClick), addNotificationEvent(button, "UserDataChanged", onUserDataChanged)
clearEvents(button);
button.addEventListener('click', onClick);
addNotificationEvent(button, 'UserDataChanged', onUserDataChanged);
}
var EmbyRatingButtonPrototype = Object.create(EmbyButtonPrototype);
EmbyRatingButtonPrototype.createdCallback = function() {
EmbyButtonPrototype.createdCallback && EmbyButtonPrototype.createdCallback.call(this)
}, EmbyRatingButtonPrototype.attachedCallback = function() {
EmbyButtonPrototype.attachedCallback && EmbyButtonPrototype.attachedCallback.call(this);
var itemId = this.getAttribute("data-id"),
serverId = this.getAttribute("data-serverid");
if (itemId && serverId) {
var likes = this.getAttribute("data-likes"),
isFavorite = "true" === this.getAttribute("data-isfavorite");
likes = "true" === likes || "false" !== likes && null, setState(this, likes, isFavorite, !1), bindEvents(this)
EmbyRatingButtonPrototype.createdCallback = function () {
// base method
if (EmbyButtonPrototype.createdCallback) {
EmbyButtonPrototype.createdCallback.call(this);
}
setTitle(this)
}, EmbyRatingButtonPrototype.detachedCallback = function() {
EmbyButtonPrototype.detachedCallback && EmbyButtonPrototype.detachedCallback.call(this), clearEvents(this)
}, EmbyRatingButtonPrototype.setItem = function(item) {
};
EmbyRatingButtonPrototype.attachedCallback = function () {
// base method
if (EmbyButtonPrototype.attachedCallback) {
EmbyButtonPrototype.attachedCallback.call(this);
}
var itemId = this.getAttribute('data-id');
var serverId = this.getAttribute('data-serverid');
if (itemId && serverId) {
var likes = this.getAttribute('data-likes');
var isFavorite = this.getAttribute('data-isfavorite') === 'true';
if (likes === 'true') {
likes = true;
}
else if (likes === 'false') {
likes = false;
} else {
likes = null;
}
setState(this, likes, isFavorite, false);
bindEvents(this);
}
setTitle(this);
};
EmbyRatingButtonPrototype.detachedCallback = function () {
// base method
if (EmbyButtonPrototype.detachedCallback) {
EmbyButtonPrototype.detachedCallback.call(this);
}
clearEvents(this);
};
EmbyRatingButtonPrototype.setItem = function (item) {
if (item) {
this.setAttribute("data-id", item.Id), this.setAttribute("data-serverid", item.ServerId);
this.setAttribute('data-id', item.Id);
this.setAttribute('data-serverid', item.ServerId);
var userData = item.UserData || {};
setState(this, userData.Likes, userData.IsFavorite), bindEvents(this)
} else this.removeAttribute("data-id"), this.removeAttribute("data-serverid"), this.removeAttribute("data-likes"), this.removeAttribute("data-isfavorite"), clearEvents(this)
}, document.registerElement("emby-ratingbutton", {
setState(this, userData.Likes, userData.IsFavorite);
bindEvents(this);
} else {
this.removeAttribute('data-id');
this.removeAttribute('data-serverid');
this.removeAttribute('data-likes');
this.removeAttribute('data-isfavorite');
clearEvents(this);
}
};
document.registerElement('emby-ratingbutton', {
prototype: EmbyRatingButtonPrototype,
extends: "button"
})
extends: 'button'
});
});

View file

@ -1,3 +1,3 @@
.btnUserDataOn {
color: #c33 !important
color: #cc3333 !important;
}

View file

@ -1,110 +1,251 @@
define(["connectionManager", "globalize", "dom", "itemHelper", "paper-icon-button-light", "material-icons", "emby-button", "css!./userdatabuttons"], function(connectionManager, globalize, dom, itemHelper) {
"use strict";
define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-button-light', 'material-icons', 'emby-button', 'css!./userdatabuttons'], function (connectionManager, globalize, dom, itemHelper) {
'use strict';
function getUserDataButtonHtml(method, itemId, serverId, buttonCssClass, iconCssClass, icon, tooltip, style) {
"fab-mini" === style && (style = "fab", buttonCssClass = buttonCssClass ? buttonCssClass + " mini" : "mini");
var is = "fab" === style ? "emby-button" : "paper-icon-button-light",
className = "fab" === style ? "autoSize fab" : "autoSize";
return buttonCssClass && (className += " " + buttonCssClass), iconCssClass ? iconCssClass += " " : iconCssClass = "", iconCssClass += "md-icon", '<button title="' + tooltip + '" data-itemid="' + itemId + '" data-serverid="' + serverId + '" is="' + is + '" data-method="' + method + '" class="' + className + '"><i class="' + iconCssClass + '">' + icon + "</i></button>"
}
function onContainerClick(e) {
var btnUserData = dom.parentWithClass(e.target, "btnUserData");
if (btnUserData) {
var method = btnUserData.getAttribute("data-method");
userDataMethods[method](btnUserData)
}
}
function fill(options) {
var html = getIconsHtml(options);
"insertAdjacent" === options.fillMode ? options.element.insertAdjacentHTML(options.insertLocation || "beforeend", html) : options.element.innerHTML = html, dom.removeEventListener(options.element, "click", onContainerClick, {
passive: !0
}), dom.addEventListener(options.element, "click", onContainerClick, {
passive: !0
})
}
function destroy(options) {
options.element.innerHTML = "", dom.removeEventListener(options.element, "click", onContainerClick, {
passive: !0
})
}
function getIconsHtml(options) {
var item = options.item,
includePlayed = options.includePlayed,
cssClass = options.cssClass,
style = options.style,
html = "",
userData = item.UserData || {},
itemId = item.Id;
if (itemHelper.isLocalItem(item)) return html;
var btnCssClass = "btnUserData";
cssClass && (btnCssClass += " " + cssClass);
var iconCssClass = options.iconCssClass,
serverId = item.ServerId;
if (!1 !== includePlayed) {
var tooltipPlayed = globalize.translate("sharedcomponents#MarkPlayed");
itemHelper.canMarkPlayed(item) && (html += userData.Played ? getUserDataButtonHtml("markPlayed", itemId, serverId, btnCssClass + " btnUserDataOn", iconCssClass, "&#xE5CA;", tooltipPlayed, style) : getUserDataButtonHtml("markPlayed", itemId, serverId, btnCssClass, iconCssClass, "&#xE5CA;", tooltipPlayed, style))
}
var tooltipFavorite = globalize.translate("sharedcomponents#Favorite");
return html += userData.IsFavorite ? getUserDataButtonHtml("markFavorite", itemId, serverId, btnCssClass + " btnUserData btnUserDataOn", iconCssClass, "&#xE87D;", tooltipFavorite, style) : getUserDataButtonHtml("markFavorite", itemId, serverId, btnCssClass + " btnUserData", iconCssClass, "&#xE87D;", tooltipFavorite, style)
}
function markFavorite(link) {
var id = link.getAttribute("data-itemid"),
serverId = link.getAttribute("data-serverid"),
markAsFavorite = !link.classList.contains("btnUserDataOn");
favorite(id, serverId, markAsFavorite), markAsFavorite ? link.classList.add("btnUserDataOn") : link.classList.remove("btnUserDataOn")
}
function markLike(link) {
var id = link.getAttribute("data-itemid"),
serverId = link.getAttribute("data-serverid");
link.classList.contains("btnUserDataOn") ? (clearLike(id, serverId), link.classList.remove("btnUserDataOn")) : (likes(id, serverId, !0), link.classList.add("btnUserDataOn")), link.parentNode.querySelector(".btnDislike").classList.remove("btnUserDataOn")
}
function markDislike(link) {
var id = link.getAttribute("data-itemid"),
serverId = link.getAttribute("data-serverid");
link.classList.contains("btnUserDataOn") ? (clearLike(id, serverId), link.classList.remove("btnUserDataOn")) : (likes(id, serverId, !1), link.classList.add("btnUserDataOn")), link.parentNode.querySelector(".btnLike").classList.remove("btnUserDataOn")
}
function markPlayed(link) {
var id = link.getAttribute("data-itemid"),
serverId = link.getAttribute("data-serverid");
link.classList.contains("btnUserDataOn") ? (played(id, serverId, !1), link.classList.remove("btnUserDataOn")) : (played(id, serverId, !0), link.classList.add("btnUserDataOn"))
}
function likes(id, serverId, isLiked) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateUserItemRating(apiClient.getCurrentUserId(), id, isLiked)
}
function played(id, serverId, isPlayed) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient[isPlayed ? "markPlayed" : "markUnplayed"](apiClient.getCurrentUserId(), id, new Date)
}
function favorite(id, serverId, isFavorite) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), id, isFavorite)
}
function clearLike(id, serverId) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.clearUserItemRating(apiClient.getCurrentUserId(), id)
}
var userDataMethods = {
markPlayed: markPlayed,
markDislike: markDislike,
markLike: markLike,
markFavorite: markFavorite
};
function getUserDataButtonHtml(method, itemId, serverId, buttonCssClass, iconCssClass, icon, tooltip, style) {
if (style === 'fab-mini') {
style = 'fab';
buttonCssClass = buttonCssClass ? (buttonCssClass + ' mini') : 'mini';
}
var is = style === 'fab' ? 'emby-button' : 'paper-icon-button-light';
var className = style === 'fab' ? 'autoSize fab' : 'autoSize';
if (buttonCssClass) {
className += ' ' + buttonCssClass;
}
if (iconCssClass) {
iconCssClass += ' ';
} else {
iconCssClass = '';
}
iconCssClass += 'md-icon';
return '<button title="' + tooltip + '" data-itemid="' + itemId + '" data-serverid="' + serverId + '" is="' + is + '" data-method="' + method + '" class="' + className + '"><i class="' + iconCssClass + '">' + icon + '</i></button>';
}
function onContainerClick(e) {
var btnUserData = dom.parentWithClass(e.target, 'btnUserData');
if (!btnUserData) {
return;
}
var method = btnUserData.getAttribute('data-method');
userDataMethods[method](btnUserData);
}
function fill(options) {
var html = getIconsHtml(options);
if (options.fillMode === 'insertAdjacent') {
options.element.insertAdjacentHTML(options.insertLocation || 'beforeend', html);
} else {
options.element.innerHTML = html;
}
dom.removeEventListener(options.element, 'click', onContainerClick, {
passive: true
});
dom.addEventListener(options.element, 'click', onContainerClick, {
passive: true
});
}
function destroy(options) {
options.element.innerHTML = '';
dom.removeEventListener(options.element, 'click', onContainerClick, {
passive: true
});
}
function getIconsHtml(options) {
var item = options.item;
var includePlayed = options.includePlayed;
var cssClass = options.cssClass;
var style = options.style;
var html = '';
var userData = item.UserData || {};
var itemId = item.Id;
if (itemHelper.isLocalItem(item)) {
return html;
}
var btnCssClass = "btnUserData";
if (cssClass) {
btnCssClass += " " + cssClass;
}
var iconCssClass = options.iconCssClass;
var serverId = item.ServerId;
if (includePlayed !== false) {
var tooltipPlayed = globalize.translate('sharedcomponents#MarkPlayed');
if (itemHelper.canMarkPlayed(item)) {
if (userData.Played) {
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass + ' btnUserDataOn', iconCssClass, '&#xE5CA;', tooltipPlayed, style);
} else {
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass, iconCssClass, '&#xE5CA;', tooltipPlayed, style);
}
}
}
//var tooltipLike = globalize.translate('sharedcomponents#Like');
//var tooltipDislike = globalize.translate('sharedcomponents#Dislike');
//if (typeof userData.Likes == "undefined") {
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
//}
//else if (userData.Likes) {
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike btnUserDataOn', 'thumb-up', tooltipLike);
//}
//else {
// html += getUserDataButtonHtml('markDislike', itemId, serverId, btnCssClass + ' btnUserData btnDislike btnUserDataOn', 'thumb-down', tooltipDislike);
// html += getUserDataButtonHtml('markLike', itemId, serverId, btnCssClass + ' btnUserData btnLike', 'thumb-up', tooltipLike);
//}
var tooltipFavorite = globalize.translate('sharedcomponents#Favorite');
if (userData.IsFavorite) {
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData btnUserDataOn', iconCssClass, '&#xE87D;', tooltipFavorite, style);
} else {
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData', iconCssClass, '&#xE87D;', tooltipFavorite, style);
}
return html;
}
function markFavorite(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
var markAsFavorite = !link.classList.contains('btnUserDataOn');
favorite(id, serverId, markAsFavorite);
if (markAsFavorite) {
link.classList.add('btnUserDataOn');
} else {
link.classList.remove('btnUserDataOn');
}
}
function markLike(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
likes(id, serverId, true);
link.classList.add('btnUserDataOn');
} else {
clearLike(id, serverId);
link.classList.remove('btnUserDataOn');
}
link.parentNode.querySelector('.btnDislike').classList.remove('btnUserDataOn');
}
function markDislike(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
likes(id, serverId, false);
link.classList.add('btnUserDataOn');
} else {
clearLike(id, serverId);
link.classList.remove('btnUserDataOn');
}
link.parentNode.querySelector('.btnLike').classList.remove('btnUserDataOn');
}
function markPlayed(link) {
var id = link.getAttribute('data-itemid');
var serverId = link.getAttribute('data-serverid');
if (!link.classList.contains('btnUserDataOn')) {
played(id, serverId, true);
link.classList.add('btnUserDataOn');
} else {
played(id, serverId, false);
link.classList.remove('btnUserDataOn');
}
}
function likes(id, serverId, isLiked) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateUserItemRating(apiClient.getCurrentUserId(), id, isLiked);
}
function played(id, serverId, isPlayed) {
var apiClient = connectionManager.getApiClient(serverId);
var method = isPlayed ? 'markPlayed' : 'markUnplayed';
return apiClient[method](apiClient.getCurrentUserId(), id, new Date());
}
function favorite(id, serverId, isFavorite) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), id, isFavorite);
}
function clearLike(id, serverId) {
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.clearUserItemRating(apiClient.getCurrentUserId(), id);
}
return {
fill: fill,
destroy: destroy,
getIconsHtml: getIconsHtml
}
};
});