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

add object assign polyfill

This commit is contained in:
Luke Pulverenti 2016-03-16 16:38:01 -04:00
parent 74505accb3
commit bd8391a61c
13 changed files with 145 additions and 103 deletions

View file

@ -1,4 +1,4 @@
<div id="indexPage" style="outline: none;" data-role="page" data-dom-cache="true" class="page homePage libraryPage allLibraryPage backdropPage pageWithAbsoluteTabs" data-title="${ButtonHome}" data-backdroptype="movie,series,game,book" data-require="scripts/indexpage,paper-tabs,neon-animated-pages"> <div id="indexPage" style="outline: none;" data-role="page" data-dom-cache="true" class="page homePage libraryPage allLibraryPage backdropPage pageWithAbsoluteTabs" data-title="${ButtonHome}" data-backdroptype="movie,series,game,book">
<div class="libraryViewNav libraryViewNavWithMinHeight hide"> <div class="libraryViewNav libraryViewNavWithMinHeight hide">
<paper-tabs hidescrollbuttons noink> <paper-tabs hidescrollbuttons noink>

View file

@ -0,0 +1,23 @@
if (typeof Object.assign != 'function') {
(function () {
Object.assign = function (target) {
'use strict';
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== undefined && source !== null) {
for (var nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}
return output;
};
})();
}

View file

@ -343,7 +343,7 @@
receiverName = castPlayer.session.receiver.friendlyName; receiverName = castPlayer.session.receiver.friendlyName;
} }
message = $.extend(message, { message = Object.assign(message, {
userId: Dashboard.getCurrentUserId(), userId: Dashboard.getCurrentUserId(),
deviceId: ApiClient.deviceId(), deviceId: ApiClient.deviceId(),
accessToken: ApiClient.accessToken(), accessToken: ApiClient.accessToken(),

View file

@ -272,47 +272,10 @@
}); });
} }
pageIdOn('pageinit', "indexPage", function () {
var page = this;
var tabs = page.querySelector('paper-tabs');
var pages = page.querySelector('neon-animated-pages');
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages, 'home.html');
pages.addEventListener('tabchange', function (e) {
loadTab(page, parseInt(e.target.selected));
});
page.querySelector('.btnTakeTour').addEventListener('click', function () {
takeTour(page, Dashboard.getCurrentUserId());
});
if (AppInfo.enableHomeTabs) {
page.classList.remove('noSecondaryNavPage');
page.querySelector('.libraryViewNav').classList.remove('hide');
} else {
page.classList.add('noSecondaryNavPage');
page.querySelector('.libraryViewNav').classList.add('hide');
}
});
pageIdOn('pageshow', "indexPage", function () {
var page = this;
Events.on(MediaController, 'playbackstop', onPlaybackStop);
});
pageIdOn('pagebeforehide', "indexPage", function () {
var page = this;
Events.off(MediaController, 'playbackstop', onPlaybackStop);
});
function onPlaybackStop(e, state) { function onPlaybackStop(e, state) {
if (state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') { if (state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
var page = $($.mobile.activePage)[0]; var page = $.mobile.activePage;
var pages = page.querySelector('neon-animated-pages'); var pages = page.querySelector('neon-animated-pages');
pages.dispatchEvent(new CustomEvent("tabchange", {})); pages.dispatchEvent(new CustomEvent("tabchange", {}));
@ -328,4 +291,36 @@
renderHomeTab: loadHomeTab renderHomeTab: loadHomeTab
}; };
return function (view, params) {
var self = this;
var pages = view.querySelector('neon-animated-pages');
LibraryBrowser.configurePaperLibraryTabs(view, view.querySelector('paper-tabs'), pages, 'home.html');
pages.addEventListener('tabchange', function (e) {
loadTab(view, parseInt(e.target.selected));
});
view.querySelector('.btnTakeTour').addEventListener('click', function () {
takeTour(view, Dashboard.getCurrentUserId());
});
if (AppInfo.enableHomeTabs) {
view.classList.remove('noSecondaryNavPage');
view.querySelector('.libraryViewNav').classList.remove('hide');
} else {
view.classList.add('noSecondaryNavPage');
view.querySelector('.libraryViewNav').classList.add('hide');
}
view.addEventListener('viewshow', function (e) {
Events.on(MediaController, 'playbackstop', onPlaybackStop);
});
view.addEventListener('viewbeforehide', function (e) {
Events.off(MediaController, 'playbackstop', onPlaybackStop);
});
}
}); });

View file

@ -1,4 +1,4 @@
define(['playlistManager', 'appSettings', 'appStorage'], function (playlistManager, appSettings, appStorage) { define(['playlistManager', 'appSettings', 'appStorage', 'jQuery'], function (playlistManager, appSettings, appStorage, $) {
var libraryBrowser = (function (window, document, screen) { var libraryBrowser = (function (window, document, screen) {

View file

@ -1,4 +1,4 @@
define(['appSettings', 'appStorage', 'libraryBrowser'], function (appSettings, appStorage, LibraryBrowser) { define(['appSettings', 'appStorage', 'libraryBrowser', 'jQuery'], function (appSettings, appStorage, LibraryBrowser, $) {
var showOverlayTimeout; var showOverlayTimeout;

View file

@ -244,7 +244,7 @@
document.body.classList.add('bodyWithPopupOpen'); document.body.classList.add('bodyWithPopupOpen');
} }
var pageElem = $($.mobile.activePage)[0]; var pageElem = $.mobile.activePage;
if (requiresDrawerRefresh || requiresDashboardDrawerRefresh) { if (requiresDrawerRefresh || requiresDashboardDrawerRefresh) {
@ -435,7 +435,7 @@
view.icon = 'live-tv'; view.icon = 'live-tv';
view.onclick = "LibraryBrowser.showTab('livetv.html', 0);"; view.onclick = "LibraryBrowser.showTab('livetv.html', 0);";
var guideView = $.extend({}, view); var guideView = Object.assign({}, view);
guideView.Name = Globalize.translate('ButtonGuide'); guideView.Name = Globalize.translate('ButtonGuide');
guideView.ImageTags = {}; guideView.ImageTags = {};
guideView.icon = 'dvr'; guideView.icon = 'dvr';
@ -443,7 +443,7 @@
guideView.onclick = "LibraryBrowser.showTab('livetv.html', 1);"; guideView.onclick = "LibraryBrowser.showTab('livetv.html', 1);";
list.push(guideView); list.push(guideView);
var recordedTvView = $.extend({}, view); var recordedTvView = Object.assign({}, view);
recordedTvView.Name = Globalize.translate('ButtonRecordedTv'); recordedTvView.Name = Globalize.translate('ButtonRecordedTv');
recordedTvView.ImageTags = {}; recordedTvView.ImageTags = {};
recordedTvView.icon = 'video-library'; recordedTvView.icon = 'video-library';
@ -457,13 +457,25 @@
}); });
} }
function showBySelector(selector, show) {
var elem = document.querySelector(selector);
if (elem) {
if (show) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
}
}
function updateLibraryMenu(user) { function updateLibraryMenu(user) {
if (!user) { if (!user) {
$('.adminMenuOptions').addClass('hide'); showBySelector('.adminMenuOptions', false);
$('.lnkMySync').addClass('hide'); showBySelector('.lnkMySync', false);
$('.userMenuOptions').addClass('hide'); showBySelector('.userMenuOptions', false);
return; return;
} }
@ -541,19 +553,23 @@
libraryMenuOptions.innerHTML = html; libraryMenuOptions.innerHTML = html;
var elem = libraryMenuOptions; var elem = libraryMenuOptions;
$('.sidebarLink', elem).off('click', onSidebarLinkClick).on('click', onSidebarLinkClick); var sidebarLinks = elem.querySelectorAll('.sidebarLink');
for (var i = 0, length = sidebarLinks.length; i < length; i++) {
sidebarLinks[i].removeEventListener('click', onSidebarLinkClick);
sidebarLinks[i].addEventListener('click', onSidebarLinkClick);
}
}); });
if (user.Policy.IsAdministrator) { if (user.Policy.IsAdministrator) {
$('.adminMenuOptions').removeClass('hide'); showBySelector('.adminMenuOptions', true);
} else { } else {
$('.adminMenuOptions').addClass('hide'); showBySelector('.adminMenuOptions', false);
} }
if (user.Policy.EnableSync) { if (user.Policy.EnableSync) {
$('.lnkMySync').removeClass('hide'); showBySelector('.lnkMySync', true);
} else { } else {
$('.lnkMySync').addClass('hide'); showBySelector('.lnkMySync', false);
} }
} }

View file

@ -38,7 +38,7 @@
NowPlayingItem: state.NowPlayingItem NowPlayingItem: state.NowPlayingItem
}; };
info = $.extend(info, state.PlayState); info = Object.assign(info, state.PlayState);
ApiClient.reportPlaybackStart(info); ApiClient.reportPlaybackStart(info);
@ -126,12 +126,11 @@
function showActivePlayerMenuInternal(playerInfo) { function showActivePlayerMenuInternal(playerInfo) {
var id = 'dlg' + new Date().getTime();
var html = ''; var html = '';
var style = ""; var dlg = document.createElement('paper-dialog');
dlg.setAttribute('with-backdrop', 'with-backdrop');
html += '<paper-dialog id="' + id + '" entry-animation="fade-in-animation" exit-animation="fade-out-animation" with-backdrop style="' + style + '">'; dlg.setAttribute('role', 'alertdialog');
html += '<h2>'; html += '<h2>';
html += (playerInfo.deviceName || playerInfo.name); html += (playerInfo.deviceName || playerInfo.name);
@ -160,21 +159,19 @@
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>'; html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
html += '</div>'; html += '</div>';
html += '</paper-dialog>'; dlg.innerHTML = html;
$(document.body).append(html); document.body.appendChild(dlg);
setTimeout(function () { setTimeout(function () {
var dlg = document.getElementById(id); dlg.querySelector('.chkMirror').addEventListener('change', onMirrorChange);
$('.chkMirror', dlg).on('change', onMirrorChange);
dlg.open(); dlg.open();
// Has to be assigned a z-index after the call to .open() // Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', function () { dlg.addEventListener('iron-overlay-closed', function () {
$(this).remove(); dlg.parentNode.removeChild(dlg);
}); });
}, 100); }, 100);
@ -1045,7 +1042,9 @@
document.addEventListener('headercreated', function () { document.addEventListener('headercreated', function () {
$('.btnCast').off('click', onCastButtonClicked).on('click', onCastButtonClicked); var btnCast = document.querySelector('.viewMenuBar .btnCast');
btnCast.removeEventListener('click', onCastButtonClicked);
btnCast.addEventListener('click', onCastButtonClicked);
}); });
pageClassOn('pagebeforeshow', "page", function () { pageClassOn('pagebeforeshow', "page", function () {

View file

@ -273,7 +273,7 @@
return; return;
} }
require(['css!css/nowplayingbar.css', 'paper-slider'], function () { require(['jQuery', 'css!css/nowplayingbar.css', 'paper-slider'], function ($) {
nowPlayingBarElement = document.querySelector('.nowPlayingBar'); nowPlayingBarElement = document.querySelector('.nowPlayingBar');

View file

@ -1,4 +1,4 @@
define(['appStorage'], function (appStorage) { define(['appStorage', 'jQuery'], function (appStorage, $) {
var supporterPlaybackKey = 'lastSupporterPlaybackMessage4'; var supporterPlaybackKey = 'lastSupporterPlaybackMessage4';

View file

@ -1,4 +1,4 @@
define(['jQuery', 'searchmenu'], function ($) { define(['libraryBrowser'], function (libraryBrowser) {
var searchHintTimeout; var searchHintTimeout;
@ -84,7 +84,7 @@
return i; return i;
}); });
var html = LibraryBrowser.getPosterViewHtml({ var html = libraryBrowser.getPosterViewHtml({
items: hints, items: hints,
shape: "auto", shape: "auto",
lazy: true, lazy: true,
@ -151,12 +151,13 @@
if (createIfNeeded && !elem) { if (createIfNeeded && !elem) {
var html = '<div class="searchResultsOverlay ui-body-b smoothScrollY background-theme-b">'; var div = document.createElement('div');
div.className = 'searchResultsOverlay ui-body-b smoothScrollY background-theme-b';
html += '<div class="searchResultsContainer"><div class="itemsContainer"></div></div></div>'; div.innerHTML = '<div class="searchResultsContainer"><div class="itemsContainer"></div></div></div>';
elem = $(html).appendTo(document.body)[0]; document.body.appendChild(div);
$(elem).createCardMenus(); libraryBrowser.createCardMenus(div);
} }
return elem; return elem;

View file

@ -1,4 +1,4 @@
define(['jQuery'], function ($) { define([], function () {
function fadeIn(elem, iterations) { function fadeIn(elem, iterations) {
@ -16,15 +16,25 @@
self.show = function () { self.show = function () {
require(['css!css/search.css'], function () { require(['css!css/search.css'], function () {
$('.headerSearchInput').val('');
$('.btnCloseSearch').hide(); document.querySelector('.headerSearchInput').value = '';
var elem = $('.viewMenuSearch').removeClass('hide')[0];
fadeIn(elem, 1).onfinish = function () { document.querySelector('.btnCloseSearch').classList.add('hide');
$('.headerSearchInput').focus(); var elem = document.querySelector('.viewMenuSearch');
$('.btnCloseSearch').show();
elem.classList.remove('hide');
var onFinish = function() {
document.querySelector('.headerSearchInput').focus();
document.querySelector('.btnCloseSearch').classList.remove('hide');
}; };
if (elem.animate) {
fadeIn(elem, 1).onfinish = onFinish;
} else {
onFinish();
}
}); });
}; };
@ -37,48 +47,40 @@
} }
if (!viewMenuSearch.classList.contains('hide')) { if (!viewMenuSearch.classList.contains('hide')) {
$('.btnCloseSearch').hide(); document.querySelector('.btnCloseSearch').classList.add('hide');
viewMenuSearch.classList.add('hide'); viewMenuSearch.classList.add('hide');
} }
}; };
$('.viewMenuSearchForm').on('submit', function () { document.querySelector('.viewMenuSearchForm').addEventListener('submit', function (e) {
e.preventDefault();
return false; return false;
}); });
$('.btnCloseSearch').on('click', function () { document.querySelector('.btnCloseSearch').addEventListener('click', function () {
self.hide(); self.hide();
Events.trigger(self, 'closed'); Events.trigger(self, 'closed');
}); });
$('.headerSearchInput').on("keyup", function (e) { document.querySelector('.headerSearchInput').addEventListener('keyup', function (e) {
// Down key // Down key
if (e.keyCode == 40) { if (e.keyCode == 40) {
//var first = $('.card', panel)[0]; e.preventDefault();
//if (first) {
// first.focus();
//}
return false; return false;
} else { } else {
Events.trigger(self, 'change', [this.value]); Events.trigger(self, 'change', [this.value]);
} }
}).on("search", function (e) {
if (!this.value) {
Events.trigger(self, 'change', ['']);
}
}); });
document.querySelector('.headerSearchInput').addEventListener('search', function (e) {
if (!this.value) {
Events.trigger(self, 'change', ['']);
}
});
} }
window.SearchMenu = new searchMenu(); window.SearchMenu = new searchMenu();

View file

@ -1854,6 +1854,7 @@ var AppInfo = {};
define("slideshow", [embyWebComponentsBowerPath + "/slideshow/slideshow"], returnFirstDependency); define("slideshow", [embyWebComponentsBowerPath + "/slideshow/slideshow"], returnFirstDependency);
define('fetch', [bowerPath + '/fetch/fetch']); define('fetch', [bowerPath + '/fetch/fetch']);
define('objectassign', ['legacy/objectassign']);
define('webcomponentsjs', [bowerPath + '/webcomponentsjs/webcomponents-lite.min.js']); define('webcomponentsjs', [bowerPath + '/webcomponentsjs/webcomponents-lite.min.js']);
define('native-promise-only', [bowerPath + '/native-promise-only/lib/npo.src']); define('native-promise-only', [bowerPath + '/native-promise-only/lib/npo.src']);
@ -2133,6 +2134,10 @@ var AppInfo = {};
deps.push('fetch'); deps.push('fetch');
} }
if (typeof Object.assign != 'function') {
deps.push('objectassign');
}
require(deps, function (connectionManagerExports, credentialProviderFactory) { require(deps, function (connectionManagerExports, credentialProviderFactory) {
window.MediaBrowser = window.MediaBrowser || {}; window.MediaBrowser = window.MediaBrowser || {};
@ -2403,13 +2408,14 @@ var AppInfo = {};
defineRoute({ defineRoute({
path: '/home.html', path: '/home.html',
dependencies: ['jQuery'], dependencies: ['paper-tabs', 'neon-animated-pages'],
autoFocus: false autoFocus: false,
controller: 'scripts/indexpage'
}); });
defineRoute({ defineRoute({
path: '/index.html', path: '/index.html',
dependencies: ['jQuery'], dependencies: [],
autoFocus: false, autoFocus: false,
isDefaultRoute: true isDefaultRoute: true
}); });