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

update components

This commit is contained in:
Luke Pulverenti 2016-08-11 23:23:12 -04:00
parent 1ad3cfbf43
commit 106870b066
11 changed files with 99 additions and 65 deletions

View file

@ -14,12 +14,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.4.166", "version": "1.4.167",
"_release": "1.4.166", "_release": "1.4.167",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.4.166", "tag": "1.4.167",
"commit": "869fe388b2e0bd01bee868001f9e1d456a2c7ca1" "commit": "03c12f1c7360d863dc0ec55491a292a3f64fb400"
}, },
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.1", "_target": "^1.2.1",

View file

@ -34,8 +34,9 @@
function getPosition(options, dlg) { function getPosition(options, dlg) {
var windowHeight = window.innerHeight; var windowSize = dom.getWindowSize();
var windowWidth = window.innerWidth; var windowHeight = windowSize.innerHeight;
var windowWidth = windowSize.innerWidth;
if (windowHeight < 540) { if (windowHeight < 540) {
return null; return null;
@ -125,7 +126,7 @@
// Admittedly a hack but right now the scrollbar is being factored into the width which is causing truncation // Admittedly a hack but right now the scrollbar is being factored into the width which is causing truncation
if (options.items.length > 20) { if (options.items.length > 20) {
var minWidth = window.innerWidth >= 300 ? 240 : 200; var minWidth = dom.getWindowSize().innerWidth >= 300 ? 240 : 200;
style += "min-width:" + minWidth + "px;"; style += "min-width:" + minWidth + "px;";
} }

View file

@ -1,4 +1,4 @@
define(['browser', 'connectionManager', 'playbackManager', 'css!./style'], function (browser, connectionManager, playbackManager) { define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style'], function (browser, connectionManager, playbackManager, dom) {
function enableAnimation(elem) { function enableAnimation(elem) {
@ -178,14 +178,6 @@
currentLoadingBackdrop = instance; currentLoadingBackdrop = instance;
} }
var windowWidth;
function resetWindowSize() {
windowWidth = screen.availWidth || window.innerWidth;
}
window.addEventListener("orientationchange", resetWindowSize);
window.addEventListener('resize', resetWindowSize);
resetWindowSize();
function getItemImageUrls(item) { function getItemImageUrls(item) {
var apiClient = connectionManager.getApiClient(item.ServerId); var apiClient = connectionManager.getApiClient(item.ServerId);
@ -197,7 +189,7 @@
return apiClient.getScaledImageUrl(item.Id, { return apiClient.getScaledImageUrl(item.Id, {
type: "Backdrop", type: "Backdrop",
tag: imgTag, tag: imgTag,
maxWidth: Math.min(windowWidth, 1920), maxWidth: Math.min(dom.getWindowSize().innerWidth, 1920),
index: index index: index
}); });
}); });
@ -210,7 +202,7 @@
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, { return apiClient.getScaledImageUrl(item.ParentBackdropItemId, {
type: "Backdrop", type: "Backdrop",
tag: imgTag, tag: imgTag,
maxWidth: Math.min(windowWidth, 1920), maxWidth: Math.min(dom.getWindowSize().innerWidth, 1920),
index: index index: index
}); });
}); });

View file

@ -1,5 +1,5 @@
define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'mediaInfo', 'focusManager', 'indicators', 'globalize', 'layoutManager', 'apphost', 'emby-button', 'css!./card', 'paper-icon-button-light', 'clearButtonStyle'], define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'mediaInfo', 'focusManager', 'indicators', 'globalize', 'layoutManager', 'apphost', 'dom', 'emby-button', 'css!./card', 'paper-icon-button-light', 'clearButtonStyle'],
function (datetime, imageLoader, connectionManager, itemHelper, mediaInfo, focusManager, indicators, globalize, layoutManager, appHost) { function (datetime, imageLoader, connectionManager, itemHelper, mediaInfo, focusManager, indicators, globalize, layoutManager, appHost, dom) {
// Regular Expressions for parsing tags and attributes // Regular Expressions for parsing tags and attributes
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
@ -118,7 +118,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'mediaInfo
function getImageWidth(shape) { function getImageWidth(shape) {
var screenWidth = window.innerWidth; var screenWidth = dom.getWindowSize().innerWidth;
if (isResizable(screenWidth)) { if (isResizable(screenWidth)) {
var roundScreenTo = 100; var roundScreenTo = 100;

View file

@ -1,5 +1,8 @@
.cardBox-round { .cardBox-round {
border: .7em solid transparent; border: .7em solid transparent !important;
transition: transform 180ms ease-out !important;
-webkit-transform-origin: center center;
transform-origin: center center;
} }
.cardImageContainer-round { .cardImageContainer-round {
@ -10,12 +13,6 @@
border-color: #fff; border-color: #fff;
} }
.cardBox-round {
transition: transform 180ms ease-out !important;
-webkit-transform-origin: center center;
transform-origin: center center;
}
.layout-tv .card-round:focus .cardBox { .layout-tv .card-round:focus .cardBox {
transform: scale(1.34, 1.34); transform: scale(1.34, 1.34);
} }
@ -26,4 +23,4 @@
.cardImageContainer-round, .card-round .cardImage { .cardImageContainer-round, .card-round .cardImage {
border-radius: 1000px; border-radius: 1000px;
} }

View file

@ -284,6 +284,8 @@
if (!dlg.classList.contains('hide')) { if (!dlg.classList.contains('hide')) {
var onAnimationFinish = function () { var onAnimationFinish = function () {
focusManager.popScope(dlg);
dlg.classList.add('hide'); dlg.classList.add('hide');
if (dlg.close) { if (dlg.close) {
dlg.close(); dlg.close();
@ -319,6 +321,7 @@
function animateDialogOpen(dlg) { function animateDialogOpen(dlg) {
var onAnimationFinish = function () { var onAnimationFinish = function () {
focusManager.pushScope(dlg);
if (dlg.getAttribute('data-autofocus') == 'true') { if (dlg.getAttribute('data-autofocus') == 'true') {
autoFocus(dlg); autoFocus(dlg);
} }

View file

@ -70,11 +70,30 @@ define([], function () {
target.removeEventListener(type, handler, optionsOrCapture); target.removeEventListener(type, handler, optionsOrCapture);
} }
var windowSize;
function resetWindowSize() {
windowSize = {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
};
}
function getWindowSize() {
if (!windowSize) {
resetWindowSize();
addEventListenerWithOptions(window, "orientationchange", resetWindowSize, { passive: true });
addEventListenerWithOptions(window, 'resize', resetWindowSize, { passive: true });
}
return windowSize;
}
return { return {
parentWithAttribute: parentWithAttribute, parentWithAttribute: parentWithAttribute,
parentWithClass: parentWithClass, parentWithClass: parentWithClass,
parentWithTag: parentWithTag, parentWithTag: parentWithTag,
addEventListener: addEventListenerWithOptions, addEventListener: addEventListenerWithOptions,
removeEventListener: removeEventListenerWithOptions removeEventListener: removeEventListenerWithOptions,
getWindowSize: getWindowSize
}; };
}); });

View file

@ -1,5 +1,17 @@
define(['dom'], function (dom) { define(['dom'], function (dom) {
var scopes = [];
function pushScope(elem) {
scopes.push(elem);
}
function popScope(elem) {
if (scopes.length) {
scopes.length -= 1;
}
}
function autoFocus(view, defaultToFirst, findAutoFocusElement) { function autoFocus(view, defaultToFirst, findAutoFocusElement) {
var element; var element;
@ -34,7 +46,14 @@ define(['dom'], function (dom) {
var focusableTagNames = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'A']; var focusableTagNames = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'A'];
var focusableContainerTagNames = ['BODY', 'DIALOG']; var focusableContainerTagNames = ['BODY', 'DIALOG'];
var focusableQuery = focusableTagNames.join(',') + ',.focusable'; var focusableQuery = focusableTagNames.map(function (t) {
if (t == 'INPUT') {
t += ':not([type="range"])';
}
return t + ':not([tabindex="-1"]):not(:disabled)';
}).join(',') + ',.focusable';
function isFocusable(elem) { function isFocusable(elem) {
@ -62,6 +81,17 @@ define(['dom'], function (dom) {
return elem; return elem;
} }
// Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusableInternal(elem) {
// http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
if (elem.offsetParent === null) {
return false;
}
return true;
}
// Determines if a focusable element can be focused at a given point in time // Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusable(elem) { function isCurrentlyFocusable(elem) {
@ -73,11 +103,6 @@ define(['dom'], function (dom) {
return false; return false;
} }
// http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
if (elem.offsetParent === null) {
return false;
}
if (elem.tagName == 'INPUT') { if (elem.tagName == 'INPUT') {
var type = elem.type; var type = elem.type;
if (type == 'range') { if (type == 'range') {
@ -85,18 +110,22 @@ define(['dom'], function (dom) {
} }
} }
return true; return isCurrentlyFocusableInternal(elem);
}
function getDefaultScope() {
return scopes[0] || document.body;
} }
function getFocusableElements(parent) { function getFocusableElements(parent) {
var elems = (parent || document.body).querySelectorAll(focusableQuery); var elems = (parent || getDefaultScope()).querySelectorAll(focusableQuery);
var focusableElements = []; var focusableElements = [];
for (var i = 0, length = elems.length; i < length; i++) { for (var i = 0, length = elems.length; i < length; i++) {
var elem = elems[i]; var elem = elems[i];
if (isCurrentlyFocusable(elem)) { if (isCurrentlyFocusableInternal(elem)) {
focusableElements.push(elem); focusableElements.push(elem);
} }
} }
@ -132,7 +161,7 @@ define(['dom'], function (dom) {
elem = elem.parentNode; elem = elem.parentNode;
if (!elem) { if (!elem) {
return document.body; return getDefaultScope();
} }
} }
@ -192,7 +221,7 @@ define(['dom'], function (dom) {
activeElement = focusableParent(activeElement); activeElement = focusableParent(activeElement);
} }
var container = activeElement ? getFocusContainer(activeElement, direction) : document.body; var container = activeElement ? getFocusContainer(activeElement, direction) : getDefaultScope();
if (!activeElement) { if (!activeElement) {
autoFocus(container, true, false); autoFocus(container, true, false);
@ -218,9 +247,9 @@ define(['dom'], function (dom) {
continue; continue;
} }
if (!isCurrentlyFocusable(curr)) { //if (!isCurrentlyFocusableInternal(curr)) {
continue; // continue;
} //}
var elementRect = getViewportBoundingClientRect(curr, windowData); var elementRect = getViewportBoundingClientRect(curr, windowData);
@ -415,6 +444,8 @@ define(['dom'], function (dom) {
nav(sourceElement, 3); nav(sourceElement, 3);
}, },
sendText: sendText, sendText: sendText,
isCurrentlyFocusable: isCurrentlyFocusable isCurrentlyFocusable: isCurrentlyFocusable,
pushScope: pushScope,
popScope: popScope
}; };
}); });

View file

@ -2,7 +2,6 @@ define(['visibleinviewport', 'imageFetcher', 'layoutManager', 'events', 'browser
var thresholdX; var thresholdX;
var thresholdY; var thresholdY;
var windowSize;
var supportsIntersectionObserver = function () { var supportsIntersectionObserver = function () {
@ -20,37 +19,28 @@ define(['visibleinviewport', 'imageFetcher', 'layoutManager', 'events', 'browser
return false; return false;
}(); }();
function resetWindowSize() {
windowSize = {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
};
}
function resetThresholds() { function resetThresholds() {
var x = screen.availWidth; var x = screen.availWidth;
var y = screen.availHeight; var y = screen.availHeight;
if (layoutManager.mobile) { if (browser.touch) {
x *= 2; x *= 2;
y *= 2; y *= 2;
} }
thresholdX = x; thresholdX = x;
thresholdY = y; thresholdY = y;
resetWindowSize();
} }
if (!supportsIntersectionObserver) { if (!supportsIntersectionObserver) {
window.addEventListener("orientationchange", resetThresholds); dom.addEventListener(window, "orientationchange", resetThresholds, { passive: true });
window.addEventListener('resize', resetThresholds); dom.addEventListener(window, 'resize', resetThresholds, { passive: true });
events.on(layoutManager, 'modechange', resetThresholds);
resetThresholds(); resetThresholds();
} }
function isVisible(elem) { function isVisible(elem) {
return visibleinviewport(elem, true, thresholdX, thresholdY, windowSize); return visibleinviewport(elem, true, thresholdX, thresholdY);
} }
var wheelEvent = (document.implementation.hasFeature('Event.wheel', '3.0') ? 'wheel' : 'mousewheel'); var wheelEvent = (document.implementation.hasFeature('Event.wheel', '3.0') ? 'wheel' : 'mousewheel');

View file

@ -1,4 +1,4 @@
define([], function () { define(['dom'], function (dom) {
/** /**
* Copyright 2012, Digital Fusion * Copyright 2012, Digital Fusion
@ -19,10 +19,7 @@
return true; return true;
} }
windowSize = windowSize || { windowSize = windowSize || dom.getWindowSize();
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
};
var vpWidth = windowSize.innerWidth, var vpWidth = windowSize.innerWidth,
vpHeight = windowSize.innerHeight; vpHeight = windowSize.innerHeight;

View file

@ -2865,7 +2865,11 @@ var AppInfo = {};
if (!browserInfo.tv && !AppInfo.isNativeApp) { if (!browserInfo.tv && !AppInfo.isNativeApp) {
if (navigator.serviceWorker) { if (navigator.serviceWorker) {
navigator.serviceWorker.register('serviceworker.js'); try {
navigator.serviceWorker.register('serviceworker.js');
} catch (err) {
console.log('Error registering serviceWorker: ' + err);
}
} }
if (window.Notification) { if (window.Notification) {