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

merge from dev

This commit is contained in:
Luke Pulverenti 2015-12-14 10:43:03 -05:00
parent 1c8f02ce0f
commit 33b01d778c
911 changed files with 34157 additions and 57125 deletions

View file

@ -1,19 +1,22 @@
(function (globalScope) {
define(['paper-dialog', 'scale-up-animation', 'fade-out-animation', 'fade-in-animation'], function () {
function paperDialogHashHandler(dlg, hash, lockDocumentScroll) {
function paperDialogHashHandler(dlg, hash, resolve, lockDocumentScroll) {
function onHashChange(e, data) {
var self = this;
self.originalUrl = window.location.href;
var activeElement = document.activeElement;
data = data.state;
var isActive = data.hash == '#' + hash;
function onHashChange(e) {
if (data.direction == 'back') {
if (dlg) {
if (!isActive) {
dlg.close();
dlg = null;
}
}
var isBack = self.originalUrl == window.location.href;
if (isBack || !dlg.opened) {
window.removeEventListener('popstate', onHashChange);
}
if (isBack) {
self.closedByBack = true;
dlg.close();
}
}
@ -23,62 +26,69 @@
Dashboard.onPopupClose();
}
dlg = null;
if (enableHashChange()) {
$(window).off('navigate', onHashChange);
window.removeEventListener('popstate', onHashChange);
if (window.location.hash == '#' + hash) {
if (!self.closedByBack) {
var state = history.state || {};
if (state.dialogId == hash) {
history.back();
}
}
activeElement.focus();
if (dlg.getAttribute('data-removeonclose') == 'true') {
dlg.parentNode.removeChild(dlg);
}
//resolve();
// if we just called history.back(), then use a timeout to allow the history events to fire first
setTimeout(function () {
resolve({
element: dlg,
closedByBack: self.closedByBack
});
}, 1);
}
var self = this;
$(dlg).on('iron-overlay-closed', onDialogClosed);
dlg.addEventListener('iron-overlay-closed', onDialogClosed);
dlg.open();
if (lockDocumentScroll !== false) {
Dashboard.onPopupOpen();
}
if (enableHashChange()) {
var state = {
dialogId: hash,
navigate: false
};
history.pushState(state, "Dialog", hash);
window.location.hash = hash;
jQuery.onStatePushed(state);
$(window).on('navigate', onHashChange);
}
window.addEventListener('popstate', onHashChange);
}
function enableHashChange() {
// It's not firing popstate in response to hashbang changes
if ($.browser.msie) {
return false;
}
if ($.browser.edge) {
return false;
}
return true;
}
function open(dlg) {
function openWithHash(dlg, hash, lockDocumentScroll) {
return new Promise(function (resolve, reject) {
new paperDialogHashHandler(dlg, hash, lockDocumentScroll);
new paperDialogHashHandler(dlg, 'dlg' + new Date().getTime(), resolve);
});
}
function close(dlg) {
if (enableHashChange()) {
if (dlg.opened) {
history.back();
}
} else {
dlg.close();
if (dlg.opened) {
history.back();
}
}
function onDialogOpened(e) {
//Emby.FocusManager.autoFocus(e.target, true);
}
function createDialog(options) {
options = options || {};
@ -92,26 +102,46 @@
// but not needed here since this is already on top of an existing dialog
// but skip it in IE because it's causing the entire browser to hang
// Also have to disable for firefox because it's causing select elements to not be clickable
if (!$.browser.msie && !$.browser.mozilla) {
if (!browserInfo.msie && !browserInfo.mozilla) {
if (options.modal !== false) {
dlg.setAttribute('modal', 'modal');
}
}
//// seeing max call stack size exceeded in the debugger with this
// seeing max call stack size exceeded in the debugger with this
dlg.setAttribute('noAutoFocus', 'noAutoFocus');
dlg.entryAnimation = 'scale-up-animation';
// These don't seem to perform well on mobile
var defaultEntryAnimation = browserInfo.mobile ? 'fade-in-animation' : 'scale-up-animation';
dlg.entryAnimation = options.entryAnimation || defaultEntryAnimation;
dlg.exitAnimation = 'fade-out-animation';
dlg.classList.add('popupEditor');
dlg.animationConfig = {
// scale up
'entry': {
name: options.entryAnimation || defaultEntryAnimation,
node: dlg,
timing: { duration: options.entryAnimationDuration || 300, easing: 'ease-out' }
},
// fade out
'exit': {
name: 'fade-out-animation',
node: dlg,
timing: { duration: options.exitAnimationDuration || 400, easing: 'ease-in' }
}
};
if (options.size == 'small') {
dlg.classList.add('small-paper-dialog');
}
else if (options.size == 'medium') {
dlg.classList.add('medium-paper-dialog');
} else {
dlg.classList.add('fullscreen-paper-dialog');
if (options.size != 'auto') {
dlg.classList.add('popupEditor');
if (options.size == 'small') {
dlg.classList.add('small-paper-dialog');
}
else if (options.size == 'medium') {
dlg.classList.add('medium-paper-dialog');
} else {
dlg.classList.add('fullscreen-paper-dialog');
}
}
var theme = options.theme || 'b';
@ -120,6 +150,10 @@
dlg.classList.add('background-theme-' + theme);
dlg.classList.add('smoothScrollY');
if (options.removeOnClose) {
dlg.setAttribute('data-removeonclose', 'true');
}
return dlg;
}
@ -162,11 +196,12 @@
}
}
globalScope.PaperDialogHelper = {
openWithHash: openWithHash,
window.PaperDialogHelper = {
open: open,
close: close,
createDialog: createDialog,
positionTo: positionTo
};
})(this);
return PaperDialogHelper;
});