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

adjust dependency loading

This commit is contained in:
Luke Pulverenti 2015-12-04 14:58:30 -05:00
parent 2eb2a5011d
commit d7fb9038a4
117 changed files with 639 additions and 29680 deletions

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-checkbox', 'paper-dialog'], function () {
function onSubmit() {
Dashboard.showLoadingMsg();
@ -192,39 +192,36 @@
items = items || [];
require(['components/paperdialoghelper'], function () {
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = items.length ? Globalize.translate('HeaderAddToCollection') : Globalize.translate('HeaderNewCollection');
var title = items.length ? Globalize.translate('HeaderAddToCollection') : Globalize.translate('HeaderNewCollection');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'collectioneditor');
PaperDialogHelper.openWithHash(dlg, 'collectioneditor');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
PaperDialogHelper.close(dlg);
});
};
}

View file

@ -0,0 +1,55 @@
define(['fade-in-animation', 'fade-out-animation', 'paper-dialog'], function () {
return function (options) {
var title = options.title;
var message = options.message;
var buttons = options.buttons;
var callback = options.callback;
var id = 'paperdlg' + new Date().getTime();
var html = '<paper-dialog id="' + id + '" role="alertdialog" entry-animation="fade-in-animation" exit-animation="fade-out-animation" with-backdrop>';
html += '<h2>' + title + '</h2>';
html += '<div>' + message + '</div>';
html += '<div class="buttons">';
var index = 0;
html += buttons.map(function (b) {
var dataIndex = ' data-index="' + index + '"';
index++;
return '<paper-button class="dialogButton"' + dataIndex + ' dialog-dismiss>' + b + '</paper-button>';
}).join('');
html += '</div>';
html += '</paper-dialog>';
$(document.body).append(html);
// This timeout is obviously messy but it's unclear how to determine when the webcomponent is ready for use
// element onload never fires
setTimeout(function () {
var dlg = document.getElementById(id);
$('.dialogButton', dlg).on('click', function () {
if (callback) {
callback(parseInt(this.getAttribute('data-index')));
}
});
// Has to be assigned a z-index after the call to .open()
dlg.addEventListener('iron-overlay-closed', function (e) {
dlg.parentNode.removeChild(dlg);
});
dlg.open();
}, 300);
};
});

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-item'], function () {
var systemInfo;
function getSystemInfo() {
@ -213,55 +213,52 @@
getSystemInfo().then(function (systemInfo) {
require(['components/paperdialoghelper'], function () {
var dlg = PaperDialogHelper.createDialog({
theme: 'a',
size: 'medium'
});
dlg.classList.add('directoryPicker');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + (options.header || Globalize.translate('HeaderSelectPath')) + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml(options, systemInfo);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options, fileOptions);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-opened', function () {
this.querySelector('#txtDirectoryPickerPath input').focus();
});
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'directorybrowser');
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
currentDialog = dlg;
var txtCurrentPath = $('#txtDirectoryPickerPath', editorContent);
if (options.path) {
txtCurrentPath.val(options.path);
}
refreshDirectoryBrowser(editorContent, txtCurrentPath.val());
var dlg = PaperDialogHelper.createDialog({
theme: 'a',
size: 'medium'
});
dlg.classList.add('directoryPicker');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + (options.header || Globalize.translate('HeaderSelectPath')) + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml(options, systemInfo);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options, fileOptions);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-opened', function () {
this.querySelector('#txtDirectoryPickerPath input').focus();
});
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'directorybrowser');
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
currentDialog = dlg;
var txtCurrentPath = $('#txtDirectoryPickerPath', editorContent);
if (options.path) {
txtCurrentPath.val(options.path);
}
refreshDirectoryBrowser(editorContent, txtCurrentPath.val());
});
};

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper', 'paper-checkbox', 'paper-dialog'], function () {
var currentItemId;
var currentItemType;
@ -312,7 +312,7 @@
currentDeferred.resolveWith(null, [hasChanges]);
}
window.ImageDownloader = {
return {
show: function (itemId, itemType, imageType) {
var deferred = DeferredBuilder.Deferred();
@ -323,12 +323,8 @@
browsableImageType = imageType || 'Primary';
selectedProvider = null;
require(['components/paperdialoghelper'], function () {
showEditor(itemId, itemType);
});
showEditor(itemId, itemType);
return deferred.promise();
}
};
})(jQuery, window, document);
});

View file

@ -1,4 +1,4 @@
(function ($, document, window, FileReader, escape) {
define(['components/paperdialoghelper', 'css!css/metadataeditor.css'], function () {
var currentItem;
var currentDeferred;
@ -190,7 +190,7 @@
}
function showImageDownloader(page, imageType) {
require(['components/imagedownloader/imagedownloader'], function () {
require(['components/imagedownloader/imagedownloader'], function (ImageDownloader) {
ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).then(function (hasChanged) {
@ -209,7 +209,7 @@
require(['components/imageuploader/imageuploader'], function () {
ImageUploader.show(currentItem.Id, {
theme: options.theme
}).then(function (hasChanged) {
@ -285,7 +285,7 @@
currentDeferred.resolveWith(null, [hasChanges]);
}
window.ImageEditor = {
return {
show: function (itemId, options) {
var deferred = DeferredBuilder.Deferred();
@ -293,13 +293,8 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
Dashboard.importCss('css/metadataeditor.css');
showEditor(itemId, options);
});
showEditor(itemId, options);
return deferred.promise();
}
};
})(jQuery, document, window, window.FileReader, escape);
});

View file

@ -182,7 +182,7 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
require(['components/paperdialoghelper', 'paper-dialog'], function () {
showEditor(itemId, options);
});

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-dialog'], function () {
var currentDeferred;
var hasChanges;
@ -186,57 +186,53 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibrarycreator/medialibrarycreator.template.html', true);
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibrarycreator/medialibrarycreator.template.html', true);
xhr.onload = function (e) {
xhr.onload = function (e) {
var template = this.response;
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
var template = this.response;
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = Globalize.translate('ButtonAddMediaLibrary');
var title = Globalize.translate('ButtonAddMediaLibrary');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options.collectionTypeOptions);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options.collectionTypeOptions);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'medialibrarycreator');
PaperDialogHelper.openWithHash(dlg, 'medialibrarycreator');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
PaperDialogHelper.close(dlg);
});
paths = [];
renderPaths(editorContent);
}
paths = [];
renderPaths(editorContent);
}
xhr.send();
});
xhr.send();
return deferred.promise();
};

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper'], function () {
var currentDeferred;
var hasChanges;
@ -140,54 +140,50 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibraryeditor/medialibraryeditor.template.html', true);
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibraryeditor/medialibraryeditor.template.html', true);
xhr.onload = function (e) {
xhr.onload = function (e) {
var template = this.response;
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
var template = this.response;
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + options.library.Name + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + options.library.Name + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'medialibraryeditor');
PaperDialogHelper.openWithHash(dlg, 'medialibraryeditor');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
PaperDialogHelper.close(dlg);
});
refreshLibraryFromServer(editorContent);
}
refreshLibraryFromServer(editorContent);
}
xhr.send();
});
xhr.send();
return deferred.promise();
};

View file

@ -1,112 +1 @@
(function ($, document, window, FileReader, escape) {
var currentItem;
function getBaseRemoteOptions() {
var options = {};
options.itemId = currentItem.Id;
return options;
}
function reload(page, item) {
Dashboard.showLoadingMsg();
if (item) {
reloadItem(page, item);
}
else {
ApiClient.getItem(Dashboard.getCurrentUserId(), currentItem.Id).then(function (item) {
reloadItem(page, item);
});
}
}
function reloadItem(page, item) {
currentItem = item;
}
function initEditor(page) {
}
function showEditor(itemId) {
Dashboard.showLoadingMsg();
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/metadataeditor/metadataeditor.template.html', true);
xhr.onload = function (e) {
var template = this.response;
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
var dlg = document.createElement('paper-dialog');
dlg.setAttribute('with-backdrop', 'with-backdrop');
dlg.setAttribute('role', 'alertdialog');
// without this safari will scroll the background instead of the dialog contents
dlg.setAttribute('modal', 'modal');
// seeing max call stack size exceeded in the debugger with this
dlg.setAttribute('noAutoFocus', 'noAutoFocus');
dlg.entryAnimation = 'scale-up-animation';
dlg.exitAnimation = 'fade-out-animation';
dlg.classList.add('smoothScrollY');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + Globalize.translate('ButtonEdit') + '</div>';
html += '</h2>';
html += '<div class="editorContent">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
initEditor(dlg);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'metadataeditor');
var editorContent = dlg.querySelector('.editorContent');
reload(editorContent, item);
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
});
}
xhr.send();
}
function onDialogClosed() {
$(this).remove();
Dashboard.hideLoadingMsg();
}
window.MetadataEditor = {
show: function (itemId) {
require(['components/paperdialoghelper'], function () {
Dashboard.importCss('css/metadataeditor.css');
showEditor(itemId);
});
}
};
})(jQuery, document, window, window.FileReader, escape);


View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-dialog'], function () {
var lastPlaylistId = '';
@ -197,39 +197,36 @@
items = items || [];
require(['components/paperdialoghelper'], function () {
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = Globalize.translate('HeaderAddToPlaylist');
var title = Globalize.translate('HeaderAddToPlaylist');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'playlisteditor');
PaperDialogHelper.openWithHash(dlg, 'playlisteditor');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
PaperDialogHelper.close(dlg);
});
};
}

View file

@ -0,0 +1,78 @@
define(['thirdparty/social-share-kit-1.0.4/dist/js/social-share-kit.min', 'css!thirdparty/social-share-kit-1.0.4/dist/css/social-share-kit.css', 'fade-in-animation', 'fade-out-animation', 'paper-dialog'], function () {
function showMenu(options, successCallback, cancelCallback) {
var id = 'dlg' + new Date().getTime();
var html = '';
html += '<paper-dialog id="' + id + '" entry-animation="fade-in-animation" exit-animation="fade-out-animation" with-backdrop>';
html += '<h2>' + Globalize.translate('HeaderShare') + '</h2>';
html += '<div>';
html += '<div class="ssk-group ssk-round ssk-lg">';
// We can only do facebook if we can guarantee that the current page is available over the internet, since FB will try to probe it.
if (Dashboard.isConnectMode()) {
html += '<a href="" class="ssk ssk-facebook"></a>';
}
html += '<a href="" class="ssk ssk-twitter"></a><a href="" class="ssk ssk-google-plus"></a><a href="" class="ssk ssk-pinterest"></a><a href="" class="ssk ssk-tumblr"></a></div>';
html += '</div>';
html += '<div style="max-width:240px;">';
html += Globalize.translate('ButtonShareHelp');
html += '</div>';
html += '<div class="buttons">';
html += '<paper-button class="btnCancel" dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
html += '</div>';
html += '</paper-dialog>';
$(document.body).append(html);
var isShared = false;
setTimeout(function () {
var dlg = document.getElementById(id);
dlg.open();
var shareInfo = options.share;
SocialShareKit.init({
selector: '#' + id + ' .ssk',
url: shareInfo.Url,
title: shareInfo.Name,
text: shareInfo.Overview,
image: shareInfo.ImageUrl,
via: 'Emby'
});
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', function () {
$(this).remove();
if (isShared) {
successCallback(options);
} else {
cancelCallback(options);
}
});
// Has to be assigned a z-index after the call to .open()
$('.ssk', dlg).on('click', function () {
isShared = true;
dlg.close();
});
}, 100);
}
return {
showMenu: showMenu
};
});

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper'], function () {
var currentItem;
@ -12,7 +12,7 @@
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
ApiClient.ajax({
type: 'GET',
url: url
@ -385,14 +385,7 @@
Dashboard.hideLoadingMsg();
}
window.SubtitleEditor = {
show: function (itemId) {
require(['components/paperdialoghelper'], function () {
showEditor(itemId);
});
}
return {
show: showEditor
};
})(jQuery, window, document);
});

View file

@ -0,0 +1,29 @@
(function () {
function onPageShow() {
var msg;
var settingsKey = "betatester";
var expectedValue = new Date().toDateString() + "3";
if (appStorage.getItem(settingsKey) == expectedValue) {
return;
}
msg = 'At your convenience, please take a moment to visit the Emby Community and leave testing feedback related to this beta build. Your feedback will help us improve the release before it goes public. Thank you for being a part of the Emby beta test team.';
msg += "<br/><br/>";
msg += '<a href="http://emby.media/community/index.php?/topic/28144-android-mobile-25" target="_blank">Visit Emby community</a>';
Dashboard.alert({
message: msg,
title: 'Hello Emby Beta Tester!'
});
appStorage.setItem(settingsKey, expectedValue);
}
pageClassOn('pageshow', "homePage", onPageShow);
})();

View file

@ -1,4 +1,4 @@
define([], function () {
define(['paper-checkbox'], function () {
return function (page, providerId, options) {