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

@ -2,6 +2,13 @@
function show(options) {
require(['paper-menu', 'paper-dialog', 'paper-dialog-scrollable', 'scale-up-animation', 'fade-out-animation'], function () {
showInternal(options);
});
}
function showInternal(options) {
// items
// positionTo
// showCancel

View file

@ -318,14 +318,16 @@
if (endpointInfo) {
var deferred = $.Deferred();
deferred.resolveWith(null, [endpointInfo]);
return deferred.promise();
return new Promise(function (resolve, reject) {
resolve(endpointInfo);
});
}
return ApiClient.getJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) {
endpointInfo = info;
return info;
});
}

View file

@ -153,6 +153,11 @@
},
enableFullPaperTabs: function () {
if (browserInfo.animate && !browserInfo.mobile) {
return true;
}
return AppInfo.isNativeApp;
},
@ -162,11 +167,15 @@
return false;
}
if (browserInfo.safari) {
if (!browserInfo.animate) {
return false;
}
return false;
if (browserInfo.mobile) {
return false;
}
return true;
},
allowSwipe: function (target) {
@ -195,12 +204,45 @@
return true;
},
getTabsAnimationConfig: function (elem, reverse) {
if (browserInfo.mobile) {
}
return {
// scale up
'entry': {
name: 'fade-in-animation',
node: elem,
timing: { duration: 160, easing: 'ease-out' }
},
// fade out
'exit': {
name: 'fade-out-animation',
node: elem,
timing: { duration: 200, easing: 'ease-out' }
}
};
},
configureSwipeTabs: function (ownerpage, tabs, pages) {
if (LibraryBrowser.animatePaperTabs()) {
// Safari doesn't handle the horizontal swiping very well
pages.entryAnimation = 'slide-from-right-animation';
pages.exitAnimation = 'slide-left-animation';
if (browserInfo.mobile) {
require(['slide-left-animation', 'slide-from-right-animation'], function () {
pages.entryAnimation = 'slide-from-right-animation';
pages.exitAnimation = 'slide-left-animation';
});
} else {
require(['fade-in-animation', 'fade-out-animation'], function () {
pages.entryAnimation = 'fade-in-animation';
pages.exitAnimation = 'fade-out-animation';
});
}
}
var pageCount = pages.querySelectorAll('neon-animatable').length;
@ -282,7 +324,7 @@
// When transition animations are used, add a content loading delay to allow the animations to finish
// Otherwise with both operations happening at the same time, it can cause the animation to not run at full speed.
var pgs = this;
var delay = LibraryBrowser.animatePaperTabs() || !tabs.noSlide ? 500 : 0;
var delay = LibraryBrowser.animatePaperTabs() || !tabs.noSlide ? 300 : 0;
setTimeout(function () {
pgs.dispatchEvent(new CustomEvent("tabchange", {}));
@ -811,7 +853,7 @@
editImages: function (itemId) {
require(['components/imageeditor/imageeditor'], function () {
require(['components/imageeditor/imageeditor'], function (ImageEditor) {
ImageEditor.show(itemId);
});
@ -819,7 +861,7 @@
editSubtitles: function (itemId) {
require(['components/subtitleeditor/subtitleeditor'], function () {
require(['components/subtitleeditor/subtitleeditor'], function (SubtitleEditor) {
SubtitleEditor.show(itemId);
});
@ -2785,82 +2827,82 @@
showSortMenu: function (options) {
var dlg = document.createElement('paper-dialog');
require(['paper-dialog', 'components/paperdialoghelper', 'paper-radio-button', 'paper-radio-group', 'scale-up-animation', 'fade-in-animation', 'fade-out-animation'], function () {
dlg.setAttribute('with-backdrop', 'with-backdrop');
dlg.setAttribute('role', 'alertdialog');
var dlg = document.createElement('paper-dialog');
dlg.entryAnimation = 'fade-in-animation';
dlg.exitAnimation = 'fade-out-animation';
dlg.setAttribute('with-backdrop', 'with-backdrop');
dlg.setAttribute('role', 'alertdialog');
// The animations flicker in IE and Firefox (probably wherever the polyfill is used)
if (browserInfo.animate) {
dlg.animationConfig = {
// scale up
'entry': {
name: 'scale-up-animation',
node: dlg,
timing: { duration: 160, easing: 'ease-out' }
},
// fade out
'exit': {
name: 'fade-out-animation',
node: dlg,
timing: { duration: 200, easing: 'ease-in' }
}
};
}
dlg.entryAnimation = 'fade-in-animation';
dlg.exitAnimation = 'fade-out-animation';
var html = '';
// The animations flicker in IE and Firefox (probably wherever the polyfill is used)
if (browserInfo.animate) {
dlg.animationConfig = {
// scale up
'entry': {
name: 'scale-up-animation',
node: dlg,
timing: { duration: 160, easing: 'ease-out' }
},
// fade out
'exit': {
name: 'fade-out-animation',
node: dlg,
timing: { duration: 200, easing: 'ease-in' }
}
};
}
// There seems to be a bug with this in safari causing it to immediately roll up to 0 height
// Have to disable this right now because it's causing the radio buttons to not function properly in other browsers besides chrome
var isScrollable = false;
if (browserInfo.android) {
isScrollable = true;
}
var html = '';
html += '<h2>';
html += Globalize.translate('HeaderSortBy');
html += '</h2>';
// There seems to be a bug with this in safari causing it to immediately roll up to 0 height
// Have to disable this right now because it's causing the radio buttons to not function properly in other browsers besides chrome
var isScrollable = false;
if (browserInfo.android) {
isScrollable = true;
}
if (isScrollable) {
html += '<paper-dialog-scrollable>';
}
html += '<h2>';
html += Globalize.translate('HeaderSortBy');
html += '</h2>';
html += '<paper-radio-group class="groupSortBy" selected="' + (options.query.SortBy || '').replace(',', '_') + '">';
for (var i = 0, length = options.items.length; i < length; i++) {
if (isScrollable) {
html += '<paper-dialog-scrollable>';
}
var option = options.items[i];
html += '<paper-radio-group class="groupSortBy" selected="' + (options.query.SortBy || '').replace(',', '_') + '">';
for (var i = 0, length = options.items.length; i < length; i++) {
html += '<paper-radio-button class="menuSortBy block" data-id="' + option.id + '" name="' + option.id.replace(',', '_') + '">' + option.name + '</paper-radio-button>';
}
html += '</paper-radio-group>';
var option = options.items[i];
html += '<p>';
html += Globalize.translate('HeaderSortOrder');
html += '</p>';
html += '<paper-radio-group class="groupSortOrder" selected="' + (options.query.SortOrder || 'Ascending') + '">';
html += '<paper-radio-button name="Ascending" class="menuSortOrder block">' + Globalize.translate('OptionAscending') + '</paper-radio-button>';
html += '<paper-radio-button name="Descending" class="menuSortOrder block">' + Globalize.translate('OptionDescending') + '</paper-radio-button>';
html += '</paper-radio-group>';
html += '<paper-radio-button class="menuSortBy block" data-id="' + option.id + '" name="' + option.id.replace(',', '_') + '">' + option.name + '</paper-radio-button>';
}
html += '</paper-radio-group>';
if (isScrollable) {
html += '</paper-dialog-scrollable>';
}
html += '<p>';
html += Globalize.translate('HeaderSortOrder');
html += '</p>';
html += '<paper-radio-group class="groupSortOrder" selected="' + (options.query.SortOrder || 'Ascending') + '">';
html += '<paper-radio-button name="Ascending" class="menuSortOrder block">' + Globalize.translate('OptionAscending') + '</paper-radio-button>';
html += '<paper-radio-button name="Descending" class="menuSortOrder block">' + Globalize.translate('OptionDescending') + '</paper-radio-button>';
html += '</paper-radio-group>';
html += '<div class="buttons">';
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonClose') + '</paper-button>';
html += '</div>';
if (isScrollable) {
html += '</paper-dialog-scrollable>';
}
dlg.innerHTML = html;
document.body.appendChild(dlg);
html += '<div class="buttons">';
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonClose') + '</paper-button>';
html += '</div>';
dlg.addEventListener('iron-overlay-closed', function () {
dlg.parentNode.removeChild(dlg);
});
dlg.innerHTML = html;
document.body.appendChild(dlg);
require(['components/paperdialoghelper'], function () {
dlg.addEventListener('iron-overlay-closed', function () {
dlg.parentNode.removeChild(dlg);
});
PaperDialogHelper.openWithHash(dlg, 'sortmenu');

View file

@ -913,17 +913,19 @@
if (!itemSelectionPanel) {
itemSelectionPanel = document.createElement('div');
itemSelectionPanel.classList.add('itemSelectionPanel');
require(['paper-checkbox'], function() {
itemSelectionPanel = document.createElement('div');
itemSelectionPanel.classList.add('itemSelectionPanel');
item.querySelector('.cardContent').appendChild(itemSelectionPanel);
item.querySelector('.cardContent').appendChild(itemSelectionPanel);
var chkItemSelect = document.createElement('paper-checkbox');
chkItemSelect.classList.add('chkItemSelect');
var chkItemSelect = document.createElement('paper-checkbox');
chkItemSelect.classList.add('chkItemSelect');
$(chkItemSelect).on('change', onSelectionChange);
$(chkItemSelect).on('change', onSelectionChange);
itemSelectionPanel.appendChild(chkItemSelect);
itemSelectionPanel.appendChild(chkItemSelect);
});
}
}

View file

@ -244,7 +244,7 @@
function showOverlay(elem, item) {
require(['components/paperdialoghelper'], function () {
require(['components/paperdialoghelper', 'scale-up-animation', 'fade-out-animation'], function () {
var dlg = document.createElement('paper-dialog');

View file

@ -118,6 +118,13 @@
function showActivePlayerMenu(playerInfo) {
require(['paper-checkbox', 'fade-in-animation', 'fade-out-animation', 'paper-dialog'], function () {
showActivePlayerMenuInternal(playerInfo);
});
}
function showActivePlayerMenuInternal(playerInfo) {
var id = 'dlg' + new Date().getTime();
var html = '';
@ -401,7 +408,9 @@
buttons: [Globalize.translate('ButtonYes'), Globalize.translate('ButtonNo'), Globalize.translate('ButtonCancel')]
};
Dashboard.dialog(options);
require(['dialog'], function (dialog) {
dialog(options);
});
} else {

View file

@ -207,7 +207,7 @@
return;
}
require(['components/imageeditor/imageeditor'], function () {
require(['components/imageeditor/imageeditor'], function (ImageEditor) {
ImageEditor.show(virtualFolder.ItemId, {
theme: 'a'

View file

@ -940,7 +940,7 @@
self.playVideo = function (item, mediaSource, startPosition, callback) {
// TODO: remove dependency on nowplayingbar
requirejs(['videorenderer', 'css!css/nowplayingbar.css', 'css!css/mediaplayer-video.css'], function () {
requirejs(['videorenderer', 'css!css/nowplayingbar.css', 'css!css/mediaplayer-video.css', 'paper-slider'], function () {
initVideoElements();

View file

@ -88,11 +88,11 @@
return;
}
var onfinish = function() {
var onfinish = function () {
elem.classList.add('hide');
};
if (!browserInfo.animate) {
if (!browserInfo.animate || browserInfo.mobile) {
onfinish();
return;
}
@ -114,7 +114,7 @@
elem.classList.remove('hide');
if (!browserInfo.animate) {
if (!browserInfo.animate || browserInfo.mobile) {
return;
}
@ -260,7 +260,7 @@
return;
}
require(['css!css/nowplayingbar.css'], function () {
require(['css!css/nowplayingbar.css', 'paper-slider'], function () {
nowPlayingBarElement = document.querySelector('.nowPlayingBar');

View file

@ -25,7 +25,7 @@
Dashboard.showLoadingMsg();
require(['sharingwidget'], function () {
require(['sharingwidget'], function (SharingWidget) {
ApiClient.ajax({
type: 'POST',

View file

@ -1,83 +0,0 @@
(function () {
function showMenu(options, successCallback, cancelCallback) {
require(['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'], function () {
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);
});
}
window.SharingWidget = {
showMenu: showMenu
};
})();

View file

@ -450,6 +450,7 @@ var Dashboard = {
showLoadingMsg: function () {
Dashboard.loadingVisible = true;
var elem = document.querySelector('.docspinner');
if (elem) {
@ -464,13 +465,15 @@ var Dashboard = {
elem.classList.add('docspinner');
document.body.appendChild(elem);
elem.active = true;
elem.active = Dashboard.loadingVisible == true;
});
}
},
hideLoadingMsg: function () {
Dashboard.loadingVisible = false;
var elem = document.querySelector('.docspinner');
if (elem) {
@ -523,27 +526,30 @@ var Dashboard = {
if (typeof options == "string") {
var message = options;
require(['paper-toast'], function () {
var message = options;
Dashboard.toastId = Dashboard.toastId || 0;
Dashboard.toastId = Dashboard.toastId || 0;
var id = 'toast' + (Dashboard.toastId++);
var id = 'toast' + (Dashboard.toastId++);
var elem = document.createElement("paper-toast");
elem.setAttribute('text', message);
elem.id = id;
var elem = document.createElement("paper-toast");
elem.setAttribute('text', message);
elem.id = id;
document.body.appendChild(elem);
document.body.appendChild(elem);
// 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 () {
elem.show();
// 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 () {
elem.show();
}, 300);
setTimeout(function () {
elem.parentNode.removeChild(elem);
}, 5000);
}, 300);
}, 5300);
});
return;
}
@ -558,75 +564,6 @@ var Dashboard = {
}
},
dialog: function (options) {
var title = options.title;
var message = options.message;
var buttons = options.buttons;
var callback = options.callback;
// Cordova
if (navigator.notification && navigator.notification.confirm && message.indexOf('<') == -1) {
navigator.notification.confirm(message, function (index) {
callback(index);
}, title, buttons.join(','));
} else {
Dashboard.dialogInternal(message, title, buttons, callback);
}
},
dialogInternal: function (message, title, buttons, 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);
},
confirm: function (message, title, callback) {
// Cordova
@ -641,7 +578,10 @@ var Dashboard = {
}, title || Globalize.translate('HeaderConfirm'), buttonLabels.join(','));
} else {
Dashboard.confirmInternal(message, title, true, callback);
require(['paper-dialog', 'fade-in-animation', 'fade-out-animation'], function () {
Dashboard.confirmInternal(message, title, true, callback);
});
}
},
@ -1836,9 +1776,13 @@ var AppInfo = {};
};
if (Dashboard.isRunningInCordova()) {
paths.dialog = "cordova/dialog";
paths.prompt = "cordova/prompt";
paths.sharingwidget = "cordova/sharingwidget";
} else {
paths.dialog = "components/dialog";
paths.prompt = "components/prompt";
paths.sharingwidget = "components/sharingwidget";
}
requirejs.config({
@ -1856,7 +1800,39 @@ var AppInfo = {};
define("cryptojs-sha1", ["apiclient/sha1"]);
define("cryptojs-md5", ["apiclient/md5"]);
define("paper-spinner", []);
// Done
define("paper-spinner", ["html!bower_components/paper-spinner/paper-spinner.html"]);
define("paper-toast", ["html!bower_components/paper-toast/paper-toast.html"]);
define("paper-slider", ["html!bower_components/paper-slider/paper-slider.html"]);
define("paper-tabs", ["html!bower_components/paper-tabs/paper-tabs.html"]);
define("paper-menu", ["html!bower_components/paper-menu/paper-menu.html"]);
define("paper-dialog-scrollable", ["html!bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html"]);
define("paper-button", ["html!bower_components/paper-button/paper-button.html"]);
define("paper-icon-button", ["html!bower_components/paper-icon-button/paper-icon-button.html"]);
define("paper-drawer-panel", ["html!bower_components/paper-drawer-panel/paper-drawer-panel.html"]);
define("paper-radio-group", ["html!bower_components/paper-radio-group/paper-radio-group.html"]);
define("paper-radio-button", ["html!bower_components/paper-radio-button/paper-radio-button.html"]);
define("neon-animated-pages", ["html!bower_components/neon-animation/neon-animated-pages.html"]);
define("slide-right-animation", ["html!bower_components/neon-animation/animations/slide-right-animation.html"]);
define("slide-left-animation", ["html!bower_components/neon-animation/animations/slide-left-animation.html"]);
define("slide-from-right-animation", ["html!bower_components/neon-animation/animations/slide-from-right-animation.html"]);
define("slide-from-left-animation", ["html!bower_components/neon-animation/animations/slide-from-left-animation.html"]);
define("paper-textarea", ["html!bower_components/paper-input/paper-textarea.html"]);
define("paper-item", ["html!bower_components/paper-item/paper-item.html"]);
define("paper-checkbox", ["html!bower_components/paper-checkbox/paper-checkbox.html"]);
define("fade-in-animation", ["html!bower_components/neon-animation/animations/fade-in-animation.html"]);
define("fade-out-animation", ["html!bower_components/neon-animation/animations/fade-out-animation.html"]);
define("scale-up-animation", ["html!bower_components/neon-animation/animations/scale-up-animation.html"]);
define("paper-dialog", ["html!bower_components/paper-dialog/paper-dialog.html"]);
// Not done
define("paper-fab", ["html!bower_components/paper-fab/paper-fab.html"]);
define("paper-input", ["html!bower_components/paper-input/paper-input.html"]);
define("paper-icon-item", ["html!bower_components/paper-item/paper-icon-item.html"]);
define("paper-item-body", ["html!bower_components/paper-item/paper-item-body.html"]);
}
function init(promiseResolve, hostingAppInfo) {
@ -1926,12 +1902,6 @@ var AppInfo = {};
define("sharingmanager", ["scripts/sharingmanager"]);
if (Dashboard.isRunningInCordova()) {
define("sharingwidget", ["cordova/sharingwidget"]);
} else {
define("sharingwidget", ["scripts/sharingwidget"]);
}
if (Dashboard.isRunningInCordova() && browserInfo.safari) {
define("searchmenu", ["cordova/searchmenu"]);
} else {
@ -1989,6 +1959,8 @@ var AppInfo = {};
deps.push('jQuery');
deps.push('paper-drawer-panel');
require(deps, function () {
for (var i in hostingAppInfo) {
@ -2033,6 +2005,15 @@ var AppInfo = {};
deps.push('thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js');
deps.push('paper-button');
deps.push('paper-icon-button');
// TODO: These need to be removed
deps.push('paper-fab');
deps.push('paper-input');
deps.push('paper-icon-item');
deps.push('paper-item-body');
require(deps, function () {
// TODO: This needs to be deprecated, but it's used heavily
@ -2072,9 +2053,11 @@ var AppInfo = {};
capabilities.DeviceProfile = MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
var connectionManagerPromise = createConnectionManager(capabilities);
deps = [];
deps.push(Globalize.ensure());
deps.push(createConnectionManager(capabilities));
Promise.all([Globalize.ensure(), connectionManagerPromise]).then(function () {
Promise.all(deps).then(function () {
document.title = Globalize.translateDocument(document.title, 'html');
@ -2126,6 +2109,10 @@ var AppInfo = {};
var deps = [];
if (!(AppInfo.isNativeApp && browserInfo.android)) {
document.documentElement.classList.add('minimumSizeTabs');
}
// Do these now to prevent a flash of content
if (AppInfo.isNativeApp && browserInfo.android) {
deps.push('css!devices/android/android.css');
@ -2219,6 +2206,8 @@ var AppInfo = {};
postInitDependencies.push('scripts/nowplayingbar');
}
//postInitDependencies.push('components/testermessage');
require(postInitDependencies);
});
}
@ -2406,7 +2395,11 @@ var AppInfo = {};
function onWebComponentsReady() {
require(['html!vulcanize-out.html'], function () {
var polymerDependencies = [];
polymerDependencies.push('html!thirdparty/emby-icons.html');
require(polymerDependencies, function () {
getHostingAppInfo().then(function (hostingAppInfo) {
init(resolve, hostingAppInfo);
});

View file

@ -76,6 +76,13 @@
function renderForm(options) {
require(['paper-checkbox'], function () {
renderFormInternal(options);
});
}
function renderFormInternal(options) {
var elem = options.elem;
var dialogOptions = options.dialogOptions;