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

Unminify using 1.5.323

Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
Vasily 2019-01-10 15:39:37 +03:00
parent 4678528d00
commit de6ac33ec1
289 changed files with 78483 additions and 54701 deletions

View file

@ -1,71 +1,188 @@
define(["connectionManager", "serverNotifications", "events", "globalize", "emby-button"], function(connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
"use strict";
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],
mode: "download",
serverId: serverId
}).then(function() {
button.dispatchEvent(new CustomEvent("download", {
cancelable: !1
}))
})
})
var button = this;
var id = button.getAttribute('data-id');
var serverId = button.getAttribute('data-serverid');
var apiClient = connectionManager.getApiClient(serverId);
if (!button.classList.contains('downloadbutton-on')) {
require(['syncDialog'], function (syncDialog) {
syncDialog.showMenu({
items: [id],
mode: 'download',
serverId: serverId
}).then(function () {
button.dispatchEvent(new CustomEvent('download', {
cancelable: false
}));
});
});
} else {
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: false
}));
});
});
}
}
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"));
if (!icon) {
button.iconElement = button.querySelector('i');
icon = button.iconElement;
}
if (syncPercent != null) {
button.classList.add('downloadbutton-on');
if (icon) {
icon.classList.add('downloadbutton-icon-on');
}
} else {
button.classList.remove('downloadbutton-on');
if (icon) {
icon.classList.remove('downloadbutton-icon-on');
}
}
if ((syncPercent || 0) >= 100) {
button.classList.add('downloadbutton-complete');
if (icon) {
icon.classList.add('downloadbutton-icon-complete');
}
} else {
button.classList.remove('downloadbutton-complete');
if (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
if ((syncPercent || 0) >= 100) {
text = globalize.translate('sharedcomponents#Downloaded');
} else if (syncPercent != null) {
text = globalize.translate('sharedcomponents#Downloading');
} else {
text = globalize.translate('sharedcomponents#Download');
}
var textElement = button.querySelector('.emby-downloadbutton-downloadtext');
if (textElement) {
textElement.innerHTML = text;
}
button.title = text;
}
function clearEvents(button) {
button.removeEventListener("click", onClick)
button.removeEventListener('click', onClick);
}
function bindEvents(button) {
clearEvents(button), button.addEventListener("click", onClick)
clearEvents(button);
button.addEventListener('click', onClick);
}
function fetchAndUpdate(button, item) {
connectionManager.getApiClient(item.ServerId).getSyncStatus(item.Id).then(function(result) {
updateSyncStatus(button, result.Progress)
}, function() {})
}
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), fetchAndUpdate(this, item), bindEvents(this)) : (this.removeAttribute("data-id"), this.removeAttribute("data-serverid"), clearEvents(this))
}, document.registerElement("emby-downloadbutton", {
EmbyDownloadButtonPrototype.createdCallback = function () {
// base method
if (EmbyButtonPrototype.createdCallback) {
EmbyButtonPrototype.createdCallback.call(this);
}
};
EmbyDownloadButtonPrototype.attachedCallback = function () {
// base method
if (EmbyButtonPrototype.attachedCallback) {
EmbyButtonPrototype.attachedCallback.call(this);
}
var itemId = this.getAttribute('data-id');
var serverId = this.getAttribute('data-serverid');
if (itemId && serverId) {
bindEvents(this);
}
};
EmbyDownloadButtonPrototype.detachedCallback = function () {
// base method
if (EmbyButtonPrototype.detachedCallback) {
EmbyButtonPrototype.detachedCallback.call(this);
}
clearEvents(this);
this.iconElement = null;
};
function fetchAndUpdate(button, item) {
connectionManager.getApiClient(item.ServerId).getSyncStatus(item.Id).then(function (result) {
updateSyncStatus(button, result.Progress);
}, function () {
});
}
EmbyDownloadButtonPrototype.setItem = function (item) {
if (item) {
this.setAttribute('data-id', item.Id);
this.setAttribute('data-serverid', item.ServerId);
fetchAndUpdate(this, item);
bindEvents(this);
} else {
this.removeAttribute('data-id');
this.removeAttribute('data-serverid');
clearEvents(this);
}
};
document.registerElement('emby-downloadbutton', {
prototype: EmbyDownloadButtonPrototype,
extends: "button"
})
extends: 'button'
});
});