EmbyCrackedClient/web/modules/emby-elements/emby-button/emby-button.js

1 line
3.6 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
import connectionManager from"./../../emby-apiclient/connectionmanager.js";import dom from"./../../dom.js";import layoutManager from"./../../layoutmanager.js";import{appHost}from"./../../common/servicelocator.js";import appRouter from"./../../approuter.js";require(["css!modules/emby-elements/emby-button/emby-button.css"]);let EnableFocusTransfrom=dom.allowFocusScaling();function openPremiumInfo(){Emby.importModule("./modules/registrationservices/registrationservices.js").then(function(registrationServices){registrationServices.showPremiereInfo()})}function showPremiereInfo(){Emby.importModule("./modules/registrationservices/registrationservices.js").then(function(registrationServices){registrationServices.validateFeature("themes",{viewOnly:!0,showDialog:!0}).then(showPremiereInfoToPremiereUser)})}function showPremiereInfoToPremiereUser(){connectionManager.currentApiClient().getCurrentUser().then(function(user){user.Policy.IsAdministrator&&appRouter.getRouteInfo("/embypremiere")?appRouter.show("embypremiere"):openPremiumInfo()})}function openUrlWithShell(url){require(["shell"],function(shell){shell.openUrl(url)})}function onAnchorClick(e){var href=this.getAttribute("href")||"";"#"===href?(e.preventDefault(),"premiereinfo"===this.getAttribute("data-preset")&&showPremiereInfo()):this.getAttribute("target")?-1===href.indexOf("emby.media/premiere")||appHost.supports("externalpremium")?appHost.supports("targetblank")&&!appHost.supports("shellopenurl")||(e.preventDefault(),openUrlWithShell(href)):(e.preventDefault(),openPremiumInfo()):appRouter.handleAnchorClick(e)}function onInit(){var classList;this.hasInit||(this.hasInit=!0,(classList=this.classList).add("emby-button"),dom.allowBackdropFilter()&&!classList.contains("nobackdropfilter")&&(classList.add("emby-button-backdropfilter"),classList.contains("raised")?classList.add("raised-backdropfilter"):classList.contains("fab")&&classList.add("fab-backdropfilter")),layoutManager.tv&&(EnableFocusTransfrom&&"false"!==this.getAttribute("data-focusscale")?classList.add("emby-button-focusscale"):classList.contains("emby-tab-button"),classList.add("emby-button-tv")))}class EmbyButton extends HTMLButtonElement{constructor(){var self=super();return onInit.call(self),self}connectedCallback(){onInit.call(this)}disconnectedCallback(){}}customElements.define("emby-button",EmbyButton,{extends:"button"});class EmbyAnchor extends HTMLAnchorElement{constructor(){var self=super();return onInit.call(self),self}connectedCallback(){onInit.call(this),dom.removeEventListener(this,"click",onAnchorClick,{}),dom.addEventListener(this,"click",onAnchorClick,{}),"true"===this.getAttribute("data-autohide")&&(appHost.supports("externallinks")&&(appHost.supports("externalappinfo")||"true"!==this.getAttribute("data-externalappinfo"))?this.classList.remove("hide"):this.classList.add("hide"))}disconnectedCallback(){dom.removeEventListener(this,"click",onAnchorClick,{})}}customElements.define("emby-linkbutton",EmbyAnchor,{extends:"a"});class EmbySectionTitle extends EmbyAnchor{constructor(){return super()}addSeeAllButton(){var elem;layoutManager.tv||this.querySelector(".sectionTitleMoreIcon")||((elem=document.createElement("i")).classList.add("md-icon","sectionTitleMoreIcon","secondaryText"),elem.innerHTML="",this.appendChild(elem),this.querySelector(".sectionTitle")?.classList.add("sectionTitleText-withseeall"))}connectedCallback(){EmbyAnchor.prototype.connectedCallback.call(this),this.addSeeAllButton()}disconnectedCallback(){EmbyAnchor.prototype.disconnectedCallback.call(this)}}customElements.define("emby-sectiontitle",EmbySectionTitle,{extends:"a"});export default EmbyButton;