mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
minify
This commit is contained in:
parent
82bcca376f
commit
8a6884abef
494 changed files with 256 additions and 120180 deletions
|
@ -1,106 +1 @@
|
|||
define(['browser', 'dom', 'layoutManager', 'css!./emby-button', 'registerElement'], function (browser, dom, layoutManager) {
|
||||
'use strict';
|
||||
|
||||
var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
|
||||
|
||||
function animateButtonInternal(e, btn) {
|
||||
|
||||
var div = document.createElement('div');
|
||||
|
||||
for (var i = 0, length = btn.classList.length; i < length; i++) {
|
||||
div.classList.add(btn.classList[i] + '-ripple-effect');
|
||||
}
|
||||
|
||||
var offsetX = e.offsetX || 0;
|
||||
var offsetY = e.offsetY || 0;
|
||||
|
||||
if (offsetX > 0 && offsetY > 0) {
|
||||
div.style.left = offsetX + 'px';
|
||||
div.style.top = offsetY + 'px';
|
||||
}
|
||||
|
||||
var firstChild = btn.firstChild;
|
||||
if (firstChild) {
|
||||
btn.insertBefore(div, btn.firstChild);
|
||||
} else {
|
||||
btn.appendChild(div);
|
||||
}
|
||||
|
||||
div.addEventListener(dom.whichAnimationEvent(), function () {
|
||||
div.parentNode.removeChild(div);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function animateButton(e, btn) {
|
||||
|
||||
requestAnimationFrame(function () {
|
||||
animateButtonInternal(e, btn);
|
||||
});
|
||||
}
|
||||
|
||||
function onKeyDown(e) {
|
||||
|
||||
if (e.keyCode === 13) {
|
||||
animateButton(e, this);
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseDown(e) {
|
||||
|
||||
if (e.button === 0) {
|
||||
animateButton(e, this);
|
||||
}
|
||||
}
|
||||
|
||||
function onClick(e) {
|
||||
|
||||
animateButton(e, this);
|
||||
}
|
||||
|
||||
function enableAnimation() {
|
||||
if (browser.tv) {
|
||||
// too slow
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
EmbyButtonPrototype.createdCallback = function () {
|
||||
|
||||
if (this.classList.contains('emby-button')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.classList.add('emby-button');
|
||||
|
||||
// Even though they support flex, it doesn't quite work with button elements
|
||||
if (browser.firefox || browser.safari) {
|
||||
this.classList.add('emby-button-noflex');
|
||||
}
|
||||
|
||||
if (layoutManager.tv) {
|
||||
this.classList.add('emby-button-focusscale');
|
||||
}
|
||||
|
||||
if (enableAnimation()) {
|
||||
dom.addEventListener(this, 'keydown', onKeyDown, {
|
||||
passive: true
|
||||
});
|
||||
if (browser.safari) {
|
||||
dom.addEventListener(this, 'click', onClick, {
|
||||
passive: true
|
||||
});
|
||||
} else {
|
||||
dom.addEventListener(this, 'mousedown', onMouseDown, {
|
||||
passive: true
|
||||
});
|
||||
//this.addEventListener('touchstart', animateButton);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
document.registerElement('emby-button', {
|
||||
prototype: EmbyButtonPrototype,
|
||||
extends: 'button'
|
||||
});
|
||||
});
|
||||
define(["browser","dom","layoutManager","css!./emby-button","registerElement"],function(browser,dom,layoutManager){"use strict";function animateButtonInternal(e,btn){for(var div=document.createElement("div"),i=0,length=btn.classList.length;i<length;i++)div.classList.add(btn.classList[i]+"-ripple-effect");var offsetX=e.offsetX||0,offsetY=e.offsetY||0;offsetX>0&&offsetY>0&&(div.style.left=offsetX+"px",div.style.top=offsetY+"px");var firstChild=btn.firstChild;firstChild?btn.insertBefore(div,btn.firstChild):btn.appendChild(div),div.addEventListener(dom.whichAnimationEvent(),function(){div.parentNode.removeChild(div)},!1)}function animateButton(e,btn){requestAnimationFrame(function(){animateButtonInternal(e,btn)})}function onKeyDown(e){13===e.keyCode&&animateButton(e,this)}function onMouseDown(e){0===e.button&&animateButton(e,this)}function onClick(e){animateButton(e,this)}function enableAnimation(){return!browser.tv}var EmbyButtonPrototype=Object.create(HTMLButtonElement.prototype);EmbyButtonPrototype.createdCallback=function(){this.classList.contains("emby-button")||(this.classList.add("emby-button"),(browser.firefox||browser.safari)&&this.classList.add("emby-button-noflex"),layoutManager.tv&&this.classList.add("emby-button-focusscale"),enableAnimation()&&(dom.addEventListener(this,"keydown",onKeyDown,{passive:!0}),browser.safari?dom.addEventListener(this,"click",onClick,{passive:!0}):dom.addEventListener(this,"mousedown",onMouseDown,{passive:!0})))},document.registerElement("emby-button",{prototype:EmbyButtonPrototype,extends:"button"})});
|
Loading…
Add table
Add a link
Reference in a new issue