dashboard-ui/modules/emby-elements/emby-button/emby-button.js
2023-08-31 15:30:17 +02:00

1 line
5.3 KiB
JavaScript

define(["exports","./../../emby-apiclient/connectionmanager.js","./../../common/globalize.js","./../../dom.js","./../../layoutmanager.js","./../../common/servicelocator.js","./../../approuter.js"],function(_exports,_connectionmanager,_globalize,_dom,_layoutmanager,_servicelocator,_approuter){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/emby-elements/emby-button/emby-button.css"]);var EnableFocusTransfrom=_dom.default.allowFocusScaling();function openPremiumInfo(){require(["registrationServices"],function(registrationServices){registrationServices.showPremiereInfo()})}function showPremiereInfoToPremiereUser(){_connectionmanager.default.currentApiClient().getCurrentUser().then(function(user){user.Policy.IsAdministrator&&_approuter.default.getRouteInfo("/embypremiere")?_approuter.default.show("embypremiere"):openPremiumInfo()})}function onAnchorClick(e){var url,href=this.getAttribute("href")||"";"#"===href?(e.preventDefault(),"premiereinfo"===this.getAttribute("data-preset")&&require(["registrationServices"],function(registrationServices){registrationServices.validateFeature("themes",{viewOnly:!0,showDialog:!0}).then(showPremiereInfoToPremiereUser)})):this.getAttribute("target")?-1===href.indexOf("emby.media/premiere")||_servicelocator.appHost.supports("externalpremium")?_servicelocator.appHost.supports("targetblank")||(e.preventDefault(),url=href,require(["shell"],function(shell){shell.openUrl(url)})):(e.preventDefault(),openPremiumInfo()):_approuter.default.handleAnchorClick(e)}function onInit(){var classList;this.hasInit||(this.hasInit=!0,(classList=this.classList).add("emby-button"),_dom.default.allowBackdropFilter()&&!classList.contains("nobackdropfilter")&&(classList.add("emby-button-backdropfilter"),classList.contains("raised")?classList.add("raised-backdropfilter"):classList.contains("fab")&&classList.add("fab-backdropfilter")),_layoutmanager.default.tv&&(EnableFocusTransfrom&&"false"!==this.getAttribute("data-focusscale")?classList.add("emby-button-focusscale"):classList.contains("emby-tab-button"),classList.add("emby-button-tv")))}var EmbyButton=function(_HTMLButtonElement){babelHelpers.inherits(EmbyButton,_HTMLButtonElement);var _super=_createSuper(EmbyButton);function EmbyButton(){babelHelpers.classCallCheck(this,EmbyButton);var _this,self=_this=_super.call(this);return onInit.call(self),babelHelpers.possibleConstructorReturn(_this,self)}return babelHelpers.createClass(EmbyButton,[{key:"connectedCallback",value:function(){onInit.call(this)}},{key:"disconnectedCallback",value:function(){}}]),EmbyButton}(babelHelpers.wrapNativeSuper(HTMLButtonElement)),EmbyAnchor=(customElements.define("emby-button",EmbyButton,{extends:"button"}),function(_HTMLAnchorElement){babelHelpers.inherits(EmbyAnchor,_HTMLAnchorElement);var _super2=_createSuper2(EmbyAnchor);function EmbyAnchor(){babelHelpers.classCallCheck(this,EmbyAnchor);var _this2,self=_this2=_super2.call(this);return onInit.call(self),babelHelpers.possibleConstructorReturn(_this2,self)}return babelHelpers.createClass(EmbyAnchor,[{key:"connectedCallback",value:function(){onInit.call(this),_dom.default.removeEventListener(this,"click",onAnchorClick,{}),_dom.default.addEventListener(this,"click",onAnchorClick,{}),"true"===this.getAttribute("data-autohide")&&(_servicelocator.appHost.supports("externallinks")&&(_servicelocator.appHost.supports("externalappinfo")||"true"!==this.getAttribute("data-externalappinfo"))?this.classList.remove("hide"):this.classList.add("hide"))}},{key:"disconnectedCallback",value:function(){_dom.default.removeEventListener(this,"click",onAnchorClick,{})}}]),EmbyAnchor}(babelHelpers.wrapNativeSuper(HTMLAnchorElement))),EmbySectionTitle=(customElements.define("emby-linkbutton",EmbyAnchor,{extends:"a"}),function(){babelHelpers.inherits(EmbySectionTitle,EmbyAnchor);var _super3=_createSuper3(EmbySectionTitle);function EmbySectionTitle(){var _this3;babelHelpers.classCallCheck(this,EmbySectionTitle),_this3=_super3.call(this);return babelHelpers.possibleConstructorReturn(_this3,_this3)}return babelHelpers.createClass(EmbySectionTitle,[{key:"href",get:function(){return babelHelpers.get(babelHelpers.getPrototypeOf(EmbySectionTitle.prototype),"href",this)},set:function(value){babelHelpers.set(babelHelpers.getPrototypeOf(EmbySectionTitle.prototype),"href",value,this,!0);var seeAllButton=this.seeAllButton;seeAllButton&&(seeAllButton.href=value)}},{key:"addSeeAllButton",value:function(){var parent,targetAttribute;this.seeAllButton||!_layoutmanager.default.tv&&(targetAttribute="_blank"===this.target?' target="_blank"':"",targetAttribute='<a href="'+(this.href||"#")+'"'+targetAttribute+' is="emby-linkbutton" class="secondaryText sectionSeeAllButton noautofocus button-link">'+_globalize.default.translate("HeaderSeeAll")+"</a>",(parent=this.parentNode).insertAdjacentHTML("beforeend",targetAttribute),this.seeAllButton=parent.querySelector(".sectionSeeAllButton"),targetAttribute=this.closest(".sectionTitleContainer"))&&targetAttribute.classList.add("sectionTitleContainer-withseeall")}},{key:"connectedCallback",value:function(){EmbyAnchor.prototype.connectedCallback.call(this),this.addSeeAllButton()}},{key:"disconnectedCallback",value:function(){EmbyAnchor.prototype.disconnectedCallback.call(this)}}]),EmbySectionTitle}());customElements.define("emby-sectiontitle",EmbySectionTitle,{extends:"a"}),_exports.default=EmbyButton});