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

update components

This commit is contained in:
Luke Pulverenti 2017-08-04 15:18:28 -04:00
parent 7553189c01
commit c3cf40b750
43 changed files with 47 additions and 76 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -14,7 +14,7 @@
<button type="button" is="emby-button" class="btnBrowseAllImages fab mini autoSize" style="margin-left: 1em;">
<i class="md-icon">search</i>
</button>
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini autoSize" style="margin-left: .5em;">
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini hide" style="margin-left: .5em;">
<i class="md-icon">add</i>
</button>
</div>
@ -29,7 +29,7 @@
<button type="button" is="emby-button" class="btnBrowseAllImages fab mini autoSize" style="margin-left: 1em;" data-imagetype="Backdrop">
<i class="md-icon">search</i>
</button>
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini autoSize" style="margin-left: .5em;" data-imagetype="Backdrop">
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini hide" style="margin-left: .5em;" data-imagetype="Backdrop">
<i class="md-icon">add</i>
</button>
</div>
@ -44,7 +44,7 @@
<button type="button" is="emby-button" class="btnBrowseAllImages fab mini autoSize" style="margin-left: 1em;" data-imagetype="Screenshot">
<i class="md-icon">search</i>
</button>
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini autoSize" style="margin-left: .5em;" data-imagetype="Screenshot">
<button type="button" is="emby-button" class="btnOpenUploadMenu fab mini hide" style="margin-left: .5em;" data-imagetype="Screenshot">
<i class="md-icon">add</i>
</button>
</div>

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
<div class="convertRecordingsContainer hide" style="padding: 1.25em 1.5em; background: #242424; border-radius: 3px; margin: 1em 0 2em;">
<div class="convertRecordingsContainer hide infoBanner" style="margin: 1em 0 2em;">
<h1 style="margin: .25em 0 .5em;">${HeaderConvertYourRecordings}</h1>
<div class="fieldDescription">${PromoConvertRecordingsToStreamingFormat}</div>
<br />
@ -6,7 +6,7 @@
<span>${HeaderLearnMore}</span>
</button>
</div>
<div class="supporterContainer hide" style="padding: 1.25em 1.5em; background: #242424; border-radius: 3px; margin: 1em 0 2em;">
<div class="supporterContainer hide infoBanner" style="margin: 1em 0 2em;">
<div class="supporterContainerText"></div>
<br />
<button is="emby-button" type="button" class="btnSupporter raised button-submit block">

View file

@ -1 +1 @@
define(["userSettings","events","pluginManager","backdrop","globalize","require"],function(userSettings,events,pluginManager,backdrop,globalize,require){"use strict";function getCurrentSkin(){return currentSkin}function getRequirePromise(deps){return new Promise(function(resolve,reject){require(deps,resolve)})}function loadSkin(id){var newSkin=pluginManager.plugins().filter(function(p){return p.id===id})[0];newSkin||(newSkin=pluginManager.plugins().filter(function(p){return"defaultskin"===p.id})[0]);var unloadPromise;if(currentSkin){if(currentSkin.id===newSkin.id)return Promise.resolve(currentSkin);unloadPromise=unloadSkin(currentSkin)}else unloadPromise=Promise.resolve();return unloadPromise.then(function(){var deps=newSkin.getDependencies();return console.log("Loading skin dependencies"),getRequirePromise(deps).then(function(){console.log("Skin dependencies loaded");var strings=newSkin.getTranslations?newSkin.getTranslations():[];return globalize.loadStrings({name:newSkin.id,strings:strings}).then(function(){return globalize.defaultModule(newSkin.id),loadSkinHeader(newSkin)})})})}function unloadSkin(skin){return unloadTheme(),backdrop.clear(),console.log("Unloading skin: "+skin.name),skin.unload().then(function(){document.dispatchEvent(new CustomEvent("skinunload",{detail:{name:skin.name}}))})}function loadSkinHeader(skin){return getSkinHeader(skin).then(function(headerHtml){return document.querySelector(".skinHeader").innerHTML=headerHtml,currentSkin=skin,skin.load(),skin})}function getSkinHeader(skin){return new Promise(function(resolve,reject){if(!skin.getHeaderTemplate)return void resolve("");var xhr=new XMLHttpRequest,url=skin.getHeaderTemplate();url+=url.indexOf("?")===-1?"?":"&",url+="v="+cacheParam,xhr.open("GET",url,!0),xhr.onload=function(e){resolve(this.status<400?this.response:"")},xhr.send()})}function loadUserSkin(){var skin=userSettings.get("skin",!1)||"defaultskin";loadSkin(skin).then(function(skin){Emby.Page.goHome()})}function getStylesheetPath(stylesheetPath){var embyWebComponentsBowerPath="bower_components/emby-webcomponents";return require.toUrl(embyWebComponentsBowerPath+"/themes/"+stylesheetPath+"/theme.css")}function unloadTheme(){var elem=themeStyleElement;elem&&(elem.parentNode.removeChild(elem),themeStyleElement=null,currentThemeStylesheet=null)}function setTheme(stylesheetPath){return new Promise(function(resolve,reject){var linkUrl=getStylesheetPath(stylesheetPath);if(currentThemeStylesheet===linkUrl)return void resolve();unloadTheme();var link=document.createElement("link");link.setAttribute("rel","stylesheet"),link.setAttribute("type","text/css"),link.onload=resolve,link.setAttribute("href",linkUrl),document.head.appendChild(link),themeStyleElement=link,currentThemeStylesheet=linkUrl})}var currentSkin,cacheParam=(new Date).getTime();events.on(userSettings,"change",function(e,name){"skin"!==name&&"language"!==name||loadUserSkin()});var themeStyleElement,currentThemeStylesheet;return{getCurrentSkin:getCurrentSkin,loadSkin:loadSkin,loadUserSkin:loadUserSkin,setTheme:setTheme}});
define(["userSettings","events","pluginManager","backdrop","globalize","require","appSettings"],function(userSettings,events,pluginManager,backdrop,globalize,require,appSettings){"use strict";function getCurrentSkin(){return currentSkin}function getRequirePromise(deps){return new Promise(function(resolve,reject){require(deps,resolve)})}function loadSkin(id){var newSkin=pluginManager.plugins().filter(function(p){return p.id===id})[0];newSkin||(newSkin=pluginManager.plugins().filter(function(p){return"defaultskin"===p.id})[0]);var unloadPromise;if(currentSkin){if(currentSkin.id===newSkin.id)return Promise.resolve(currentSkin);unloadPromise=unloadSkin(currentSkin)}else unloadPromise=Promise.resolve();return unloadPromise.then(function(){var deps=newSkin.getDependencies();return console.log("Loading skin dependencies"),getRequirePromise(deps).then(function(){console.log("Skin dependencies loaded");var strings=newSkin.getTranslations?newSkin.getTranslations():[];return globalize.loadStrings({name:newSkin.id,strings:strings}).then(function(){return globalize.defaultModule(newSkin.id),loadSkinHeader(newSkin)})})})}function unloadSkin(skin){return unloadTheme(),backdrop.clear(),console.log("Unloading skin: "+skin.name),skin.unload().then(function(){document.dispatchEvent(new CustomEvent("skinunload",{detail:{name:skin.name}}))})}function loadSkinHeader(skin){return getSkinHeader(skin).then(function(headerHtml){return document.querySelector(".skinHeader").innerHTML=headerHtml,currentSkin=skin,skin.load(),skin})}function getSkinHeader(skin){return new Promise(function(resolve,reject){if(!skin.getHeaderTemplate)return void resolve("");var xhr=new XMLHttpRequest,url=skin.getHeaderTemplate();url+=url.indexOf("?")===-1?"?":"&",url+="v="+cacheParam,xhr.open("GET",url,!0),xhr.onload=function(e){resolve(this.status<400?this.response:"")},xhr.send()})}function loadUserSkin(){var skin=userSettings.get("skin",!1)||"defaultskin";loadSkin(skin).then(function(skin){Emby.Page.goHome()})}function unloadTheme(){var elem=themeStyleElement;elem&&(elem.parentNode.removeChild(elem),themeStyleElement=null,currentThemeId=null)}function getThemes(){return currentSkin.getThemes?currentSkin.getThemes():[]}function onRegistrationSuccess(){appSettings.set("appthemesregistered","true")}function onRegistrationFailure(){appSettings.set("appthemesregistered","false")}function isRegistered(){return getRequirePromise(["registrationServices"]).then(function(registrationServices){registrationServices.validateFeature("themes",{showDialog:!1}).then(onRegistrationSuccess,onRegistrationFailure)}),"false"!==appSettings.get("appthemesregistered")}function getThemeStylesheetInfo(id,isDefaultProperty){for(var defaultTheme,selectedTheme,themes=skinManager.getThemes(),i=0,length=themes.length;i<length;i++){var theme=themes[i];theme[isDefaultProperty]&&(defaultTheme=theme),id===theme.id&&(selectedTheme=theme)}selectedTheme=selectedTheme||defaultTheme,selectedTheme===defaultTheme.id||isRegistered()||(selectedTheme=defaultTheme);var embyWebComponentsBowerPath="bower_components/emby-webcomponents";return{stylesheetPath:require.toUrl(embyWebComponentsBowerPath+"/themes/"+selectedTheme.id+"/theme.css"),themeId:selectedTheme.id}}var currentSkin,cacheParam=(new Date).getTime();events.on(userSettings,"change",function(e,name){"skin"!==name&&"language"!==name||loadUserSkin()});var themeStyleElement,currentThemeId,skinManager={getCurrentSkin:getCurrentSkin,loadSkin:loadSkin,loadUserSkin:loadUserSkin,getThemes:getThemes};return skinManager.setTheme=function(id,context){return new Promise(function(resolve,reject){if(currentThemeId===id)return void resolve();var isDefaultProperty="serverdashboard"===context?"isDefaultServerDashboard":"isDefault",info=getThemeStylesheetInfo(id,isDefaultProperty);if(currentThemeId===info.themeId)return void resolve();var linkUrl=info.stylesheetPath;unloadTheme();var link=document.createElement("link");link.setAttribute("rel","stylesheet"),link.setAttribute("type","text/css"),link.onload=resolve,link.setAttribute("href",linkUrl),document.head.appendChild(link),themeStyleElement=link,currentThemeId=info.themeId})},skinManager});

View file

@ -1 +1 @@
define(["connectionManager","serverNotifications","events","globalize","emby-button"],function(connectionManager,serverNotifications,events,globalize,EmbyButtonPrototype){"use strict";function onClick(e){var button=this,id=button.getAttribute("data-id"),serverId=button.getAttribute("data-serverid"),apiClient=connectionManager.getApiClient(serverId);button.classList.contains("downloadbutton-on")?require(["confirm"],function(confirm){confirm({text:globalize.translate("sharedcomponents#ConfirmRemoveDownload"),confirmText:globalize.translate("sharedcomponents#RemoveDownload"),cancelText:globalize.translate("sharedcomponents#KeepDownload"),primary:"cancel"}).then(function(){apiClient.cancelSyncItems([id]),button.dispatchEvent(new CustomEvent("download-cancel",{cancelable:!1}))})}):require(["syncDialog"],function(syncDialog){syncDialog.showMenu({items:[id],isLocalSync:!0,serverId:serverId}).then(function(){button.dispatchEvent(new CustomEvent("download",{cancelable:!1}))})})}function updateSyncStatus(button,syncPercent){null!=syncPercent?button.classList.add("downloadbutton-on"):button.classList.remove("downloadbutton-on"),(syncPercent||0)>=100?button.classList.add("downloadbutton-complete"):button.classList.remove("downloadbutton-complete");var text;text=(syncPercent||0)>=100?globalize.translate("sharedcomponents#Downloaded"):null!=syncPercent?globalize.translate("sharedcomponents#Downloading"):globalize.translate("sharedcomponents#Download");var textElement=button.querySelector(".emby-downloadbutton-downloadtext");textElement&&(textElement.innerHTML=text),button.title=text}function clearEvents(button){button.removeEventListener("click",onClick)}function bindEvents(button){clearEvents(button),button.addEventListener("click",onClick)}var EmbyDownloadButtonPrototype=Object.create(EmbyButtonPrototype);EmbyDownloadButtonPrototype.createdCallback=function(){EmbyButtonPrototype.createdCallback&&EmbyButtonPrototype.createdCallback.call(this)},EmbyDownloadButtonPrototype.attachedCallback=function(){EmbyButtonPrototype.attachedCallback&&EmbyButtonPrototype.attachedCallback.call(this);var itemId=this.getAttribute("data-id"),serverId=this.getAttribute("data-serverid");itemId&&serverId&&bindEvents(this)},EmbyDownloadButtonPrototype.detachedCallback=function(){EmbyButtonPrototype.detachedCallback&&EmbyButtonPrototype.detachedCallback.call(this),clearEvents(this)},EmbyDownloadButtonPrototype.setItem=function(item){item?(this.setAttribute("data-id",item.Id),this.setAttribute("data-serverid",item.ServerId),updateSyncStatus(this,item.SyncPercent),bindEvents(this)):(this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),clearEvents(this))},document.registerElement("emby-downloadbutton",{prototype:EmbyDownloadButtonPrototype,extends:"button"})});
define(["connectionManager","serverNotifications","events","globalize","emby-button"],function(connectionManager,serverNotifications,events,globalize,EmbyButtonPrototype){"use strict";function onClick(e){var button=this,id=button.getAttribute("data-id"),serverId=button.getAttribute("data-serverid"),apiClient=connectionManager.getApiClient(serverId);button.classList.contains("downloadbutton-on")?require(["confirm"],function(confirm){confirm({text:globalize.translate("sharedcomponents#ConfirmRemoveDownload"),confirmText:globalize.translate("sharedcomponents#RemoveDownload"),cancelText:globalize.translate("sharedcomponents#KeepDownload"),primary:"cancel"}).then(function(){apiClient.cancelSyncItems([id]),button.dispatchEvent(new CustomEvent("download-cancel",{cancelable:!1}))})}):require(["syncDialog"],function(syncDialog){syncDialog.showMenu({items:[id],isLocalSync:!0,serverId:serverId}).then(function(){button.dispatchEvent(new CustomEvent("download",{cancelable:!1}))})})}function updateSyncStatus(button,syncPercent){var icon=button.iconElement;icon||(button.iconElement=button.querySelector("i"),icon=button.iconElement),null!=syncPercent?(button.classList.add("downloadbutton-on"),icon&&icon.classList.add("downloadbutton-icon-on")):(button.classList.remove("downloadbutton-on"),icon&&icon.classList.remove("downloadbutton-icon-on")),(syncPercent||0)>=100?(button.classList.add("downloadbutton-complete"),icon&&icon.classList.add("downloadbutton-icon-complete")):(button.classList.remove("downloadbutton-complete"),icon&&icon.classList.remove("downloadbutton-icon-complete"));var text;text=(syncPercent||0)>=100?globalize.translate("sharedcomponents#Downloaded"):null!=syncPercent?globalize.translate("sharedcomponents#Downloading"):globalize.translate("sharedcomponents#Download");var textElement=button.querySelector(".emby-downloadbutton-downloadtext");textElement&&(textElement.innerHTML=text),button.title=text}function clearEvents(button){button.removeEventListener("click",onClick)}function bindEvents(button){clearEvents(button),button.addEventListener("click",onClick)}var EmbyDownloadButtonPrototype=Object.create(EmbyButtonPrototype);EmbyDownloadButtonPrototype.createdCallback=function(){EmbyButtonPrototype.createdCallback&&EmbyButtonPrototype.createdCallback.call(this)},EmbyDownloadButtonPrototype.attachedCallback=function(){EmbyButtonPrototype.attachedCallback&&EmbyButtonPrototype.attachedCallback.call(this);var itemId=this.getAttribute("data-id"),serverId=this.getAttribute("data-serverid");itemId&&serverId&&bindEvents(this)},EmbyDownloadButtonPrototype.detachedCallback=function(){EmbyButtonPrototype.detachedCallback&&EmbyButtonPrototype.detachedCallback.call(this),clearEvents(this),this.iconElement=null},EmbyDownloadButtonPrototype.setItem=function(item){item?(this.setAttribute("data-id",item.Id),this.setAttribute("data-serverid",item.ServerId),updateSyncStatus(this,item.SyncPercent),bindEvents(this)):(this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),clearEvents(this))},document.registerElement("emby-downloadbutton",{prototype:EmbyDownloadButtonPrototype,extends:"button"})});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
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}function removeNotificationEvent(instance,name){var handler=instance[name];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))}function onUserDataChanged(e,apiClient,userData){var button=this;userData.ItemId===button.getAttribute("data-id")&&setState(button,userData.Played)}function setState(button,played,updateAttribute){played?button.classList.add("playstatebutton-played"):button.classList.remove("playstatebutton-played"),updateAttribute!==!1&&button.setAttribute("data-played",played)}function setTitle(button,itemType){"AudioBook"!==itemType&&"AudioPodcast"!==itemType?button.title=globalize.translate("sharedcomponents#MarkWatched"):button.title=globalize.translate("sharedcomponents#MarkPlayed")}function clearEvents(button){button.removeEventListener("click",onClick),removeNotificationEvent(button,"UserDataChanged")}function bindEvents(button){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)},EmbyPlaystateButtonPrototype.setItem=function(item){if(item){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"})});
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}function removeNotificationEvent(instance,name){var handler=instance[name];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))}function onUserDataChanged(e,apiClient,userData){var button=this;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")):(button.classList.remove("playstatebutton-played"),icon&&icon.classList.remove("playstatebutton-icon-played")),updateAttribute!==!1&&button.setAttribute("data-played",played)}function setTitle(button,itemType){"AudioBook"!==itemType&&"AudioPodcast"!==itemType?button.title=globalize.translate("sharedcomponents#MarkWatched"):button.title=globalize.translate("sharedcomponents#MarkPlayed")}function clearEvents(button){button.removeEventListener("click",onClick),removeNotificationEvent(button,"UserDataChanged")}function bindEvents(button){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){if(item){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"})});

View file

@ -1 +1 @@
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}function removeNotificationEvent(instance,name){var handler=instance[name];handler&&(events.off(serverNotifications,name,handler),instance[name]=null)}function showPicker(button,apiClient,itemId,likes,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)})}function onUserDataChanged(e,apiClient,userData){var button=this;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="&#xE87D;"),button.classList.add("ratingbutton-withrating")):likes?(icon&&(icon.innerHTML="&#xE87D;"),button.classList.remove("ratingbutton-withrating")):likes===!1?(icon&&(icon.innerHTML="&#xE87D;"),button.classList.remove("ratingbutton-withrating")):(icon&&(icon.innerHTML="&#xE87D;"),button.classList.remove("ratingbutton-withrating")),updateAttribute!==!1&&(button.setAttribute("data-isfavorite",isFavorite),button.setAttribute("data-likes",null===likes?"":likes))}function setTitle(button){button.title=globalize.translate("sharedcomponents#Favorite")}function clearEvents(button){button.removeEventListener("click",onClick),removeNotificationEvent(button,"UserDataChanged")}function bindEvents(button){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)}setTitle(this)},EmbyRatingButtonPrototype.detachedCallback=function(){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);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",{prototype:EmbyRatingButtonPrototype,extends:"button"})});
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}function removeNotificationEvent(instance,name){var handler=instance[name];handler&&(events.off(serverNotifications,name,handler),instance[name]=null)}function showPicker(button,apiClient,itemId,likes,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)})}function onUserDataChanged(e,apiClient,userData){var button=this;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="&#xE87D;",icon.classList.add("ratingbutton-icon-withrating")),button.classList.add("ratingbutton-withrating")):likes?(icon&&(icon.innerHTML="&#xE87D;",icon.classList.remove("ratingbutton-icon-withrating")),button.classList.remove("ratingbutton-withrating")):likes===!1?(icon&&(icon.innerHTML="&#xE87D;",icon.classList.remove("ratingbutton-icon-withrating")),button.classList.remove("ratingbutton-withrating")):(icon&&(icon.innerHTML="&#xE87D;",icon.classList.remove("ratingbutton-icon-withrating")),button.classList.remove("ratingbutton-withrating")),updateAttribute!==!1&&(button.setAttribute("data-isfavorite",isFavorite),button.setAttribute("data-likes",null===likes?"":likes))}function setTitle(button){button.title=globalize.translate("sharedcomponents#Favorite")}function clearEvents(button){button.removeEventListener("click",onClick),removeNotificationEvent(button,"UserDataChanged")}function bindEvents(button){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)}setTitle(this)},EmbyRatingButtonPrototype.detachedCallback=function(){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);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",{prototype:EmbyRatingButtonPrototype,extends:"button"})});