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

update paper button and button

This commit is contained in:
Cameron 2020-07-17 17:02:49 +01:00
parent 9e2d289265
commit 93fcca6965
2 changed files with 62 additions and 70 deletions

View file

@ -7,12 +7,10 @@ import appHost from 'apphost';
import 'css!./emby-button'; import 'css!./emby-button';
import 'registerElement'; import 'registerElement';
/* eslint-disable indent */ const EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
const EmbyLinkButtonPrototype = Object.create(HTMLAnchorElement.prototype);
const EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype); function onAnchorClick(e) {
const EmbyLinkButtonPrototype = Object.create(HTMLAnchorElement.prototype);
function onAnchorClick(e) {
const href = this.getAttribute('href') || ''; const href = this.getAttribute('href') || '';
if (href !== '#') { if (href !== '#') {
if (this.getAttribute('target')) { if (this.getAttribute('target')) {
@ -26,9 +24,9 @@ import 'registerElement';
} else { } else {
e.preventDefault(); e.preventDefault();
} }
} }
EmbyButtonPrototype.createdCallback = function () { EmbyButtonPrototype.createdCallback = function () {
if (this.classList.contains('emby-button')) { if (this.classList.contains('emby-button')) {
return; return;
} }
@ -40,9 +38,9 @@ import 'registerElement';
// this method utilizes class chaining // this method utilizes class chaining
this.classList.add('show-focus'); this.classList.add('show-focus');
} }
}; };
EmbyButtonPrototype.attachedCallback = function () { EmbyButtonPrototype.attachedCallback = function () {
if (this.tagName === 'A') { if (this.tagName === 'A') {
dom.removeEventListener(this, 'click', onAnchorClick, {}); dom.removeEventListener(this, 'click', onAnchorClick, {});
dom.addEventListener(this, 'click', onAnchorClick, {}); dom.addEventListener(this, 'click', onAnchorClick, {});
@ -55,25 +53,23 @@ import 'registerElement';
} }
} }
} }
}; };
EmbyButtonPrototype.detachedCallback = function () { EmbyButtonPrototype.detachedCallback = function () {
dom.removeEventListener(this, 'click', onAnchorClick, {}); dom.removeEventListener(this, 'click', onAnchorClick, {});
}; };
EmbyLinkButtonPrototype.createdCallback = EmbyButtonPrototype.createdCallback; EmbyLinkButtonPrototype.createdCallback = EmbyButtonPrototype.createdCallback;
EmbyLinkButtonPrototype.attachedCallback = EmbyButtonPrototype.attachedCallback; EmbyLinkButtonPrototype.attachedCallback = EmbyButtonPrototype.attachedCallback;
document.registerElement('emby-button', { document.registerElement('emby-button', {
prototype: EmbyButtonPrototype, prototype: EmbyButtonPrototype,
extends: 'button' extends: 'button'
}); });
document.registerElement('emby-linkbutton', { document.registerElement('emby-linkbutton', {
prototype: EmbyLinkButtonPrototype, prototype: EmbyLinkButtonPrototype,
extends: 'a' extends: 'a'
}); });
export default EmbyButtonPrototype; export default EmbyButtonPrototype;
/* eslint-enable indent */

View file

@ -2,21 +2,17 @@ import layoutManager from 'layoutManager';
import 'css!./emby-button'; import 'css!./emby-button';
import 'registerElement'; import 'registerElement';
/* eslint-disable indent */ const EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
const EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype); EmbyButtonPrototype.createdCallback = function () {
EmbyButtonPrototype.createdCallback = function () {
this.classList.add('paper-icon-button-light'); this.classList.add('paper-icon-button-light');
if (layoutManager.tv) { if (layoutManager.tv) {
this.classList.add('show-focus'); this.classList.add('show-focus');
} }
}; };
document.registerElement('paper-icon-button-light', { document.registerElement('paper-icon-button-light', {
prototype: EmbyButtonPrototype, prototype: EmbyButtonPrototype,
extends: 'button' extends: 'button'
}); });
/* eslint-enable indent */