Unminify using 1.5.323
Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
parent
4678528d00
commit
de6ac33ec1
289 changed files with 78483 additions and 54701 deletions
|
@ -1,233 +1,543 @@
|
|||
define(["require", "apphost", "layoutManager", "focusManager", "globalize", "loading", "connectionManager", "homeSections", "dom", "events", "listViewStyle", "emby-select", "emby-checkbox"], function(require, appHost, layoutManager, focusManager, globalize, loading, connectionManager, homeSections, dom, events) {
|
||||
define(['require', 'apphost', 'layoutManager', 'focusManager', 'globalize', 'loading', 'connectionManager', 'homeSections', 'dom', 'events', 'listViewStyle', 'emby-select', 'emby-checkbox'], function (require, appHost, layoutManager, focusManager, globalize, loading, connectionManager, homeSections, dom, events) {
|
||||
"use strict";
|
||||
|
||||
var numConfigurableSections = 7;
|
||||
|
||||
function renderViews(page, user, result) {
|
||||
var folderHtml = "";
|
||||
folderHtml += '<div class="checkboxList">', folderHtml += result.map(function(i) {
|
||||
var currentHtml = "",
|
||||
id = "chkGroupFolder" + i.Id,
|
||||
isChecked = -1 !== user.Configuration.GroupedFolders.indexOf(i.Id),
|
||||
checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
return currentHtml += "<label>", currentHtml += '<input type="checkbox" is="emby-checkbox" class="chkGroupFolder" data-folderid="' + i.Id + '" id="' + id + '"' + checkedHtml + "/>", currentHtml += "<span>" + i.Name + "</span>", currentHtml += "</label>"
|
||||
}).join(""), folderHtml += "</div>", page.querySelector(".folderGroupList").innerHTML = folderHtml
|
||||
|
||||
var folderHtml = '';
|
||||
|
||||
folderHtml += '<div class="checkboxList">';
|
||||
folderHtml += result.map(function (i) {
|
||||
|
||||
var currentHtml = '';
|
||||
|
||||
var id = 'chkGroupFolder' + i.Id;
|
||||
|
||||
var isChecked = user.Configuration.GroupedFolders.indexOf(i.Id) !== -1;
|
||||
|
||||
var checkedHtml = isChecked ? ' checked="checked"' : '';
|
||||
|
||||
currentHtml += '<label>';
|
||||
currentHtml += '<input type="checkbox" is="emby-checkbox" class="chkGroupFolder" data-folderid="' + i.Id + '" id="' + id + '"' + checkedHtml + '/>';
|
||||
currentHtml += '<span>' + i.Name + '</span>';
|
||||
currentHtml += '</label>';
|
||||
|
||||
return currentHtml;
|
||||
|
||||
}).join('');
|
||||
|
||||
folderHtml += '</div>';
|
||||
|
||||
page.querySelector('.folderGroupList').innerHTML = folderHtml;
|
||||
}
|
||||
|
||||
function getLandingScreenOptions(type) {
|
||||
|
||||
var list = [];
|
||||
return "movies" === type ? (list.push({
|
||||
name: globalize.translate("sharedcomponents#Movies"),
|
||||
value: "movies",
|
||||
isDefault: !0
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Suggestions"),
|
||||
value: "suggestions"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Favorites"),
|
||||
value: "favorites"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Collections"),
|
||||
value: "collections"
|
||||
})) : "tvshows" === type ? (list.push({
|
||||
name: globalize.translate("sharedcomponents#Shows"),
|
||||
value: "shows",
|
||||
isDefault: !0
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Suggestions"),
|
||||
value: "suggestions"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Latest"),
|
||||
value: "latest"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Favorites"),
|
||||
value: "favorites"
|
||||
})) : "music" === type ? (list.push({
|
||||
name: globalize.translate("sharedcomponents#Suggestions"),
|
||||
value: "suggestions",
|
||||
isDefault: !0
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Albums"),
|
||||
value: "albums"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#HeaderAlbumArtists"),
|
||||
value: "albumartists"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Artists"),
|
||||
value: "artists"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Playlists"),
|
||||
value: "playlists"
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Genres"),
|
||||
value: "genres"
|
||||
})) : "livetv" === type && (list.push({
|
||||
name: globalize.translate("sharedcomponents#Suggestions"),
|
||||
value: "suggestions",
|
||||
isDefault: !0
|
||||
}), list.push({
|
||||
name: globalize.translate("sharedcomponents#Guide"),
|
||||
value: "guide"
|
||||
})), list
|
||||
|
||||
if (type === 'movies') {
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Movies'),
|
||||
value: 'movies',
|
||||
isDefault: true
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Suggestions'),
|
||||
value: 'suggestions'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Favorites'),
|
||||
value: 'favorites'
|
||||
});
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Collections'),
|
||||
value: 'collections'
|
||||
});
|
||||
}
|
||||
else if (type === 'tvshows') {
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Shows'),
|
||||
value: 'shows',
|
||||
isDefault: true
|
||||
});
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Suggestions'),
|
||||
value: 'suggestions'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Latest'),
|
||||
value: 'latest'
|
||||
});
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Favorites'),
|
||||
value: 'favorites'
|
||||
});
|
||||
}
|
||||
else if (type === 'music') {
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Suggestions'),
|
||||
value: 'suggestions',
|
||||
isDefault: true
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Albums'),
|
||||
value: 'albums'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#HeaderAlbumArtists'),
|
||||
value: 'albumartists'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Artists'),
|
||||
value: 'artists'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Playlists'),
|
||||
value: 'playlists'
|
||||
});
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Genres'),
|
||||
value: 'genres'
|
||||
});
|
||||
}
|
||||
else if (type === 'livetv') {
|
||||
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Suggestions'),
|
||||
value: 'suggestions',
|
||||
isDefault: true
|
||||
});
|
||||
list.push({
|
||||
name: globalize.translate('sharedcomponents#Guide'),
|
||||
value: 'guide'
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function getLandingScreenOptionsHtml(type, userValue) {
|
||||
return getLandingScreenOptions(type).map(function(o) {
|
||||
var selected = userValue === o.value || o.isDefault && !userValue,
|
||||
selectedHtml = selected ? " selected" : "";
|
||||
return '<option value="' + (o.isDefault ? "" : o.value) + '"' + selectedHtml + ">" + o.name + "</option>"
|
||||
}).join("")
|
||||
|
||||
return getLandingScreenOptions(type).map(function (o) {
|
||||
|
||||
var selected = userValue === o.value || (o.isDefault && !userValue);
|
||||
var selectedHtml = selected ? ' selected' : '';
|
||||
var optionValue = o.isDefault ? '' : o.value;
|
||||
|
||||
return '<option value="' + optionValue + '"' + selectedHtml + '>' + o.name + '</option>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function renderViewOrder(context, user, result) {
|
||||
var html = "",
|
||||
index = 0;
|
||||
html += result.Items.map(function(view) {
|
||||
var currentHtml = "";
|
||||
return currentHtml += '<div class="listItem viewItem" data-viewid="' + view.Id + '">', currentHtml += '<i class="md-icon listItemIcon"></i>', currentHtml += '<div class="listItemBody">', currentHtml += "<div>", currentHtml += view.Name, currentHtml += "</div>", currentHtml += "</div>", currentHtml += '<button type="button" is="paper-icon-button-light" class="btnViewItemUp btnViewItemMove autoSize" title="' + globalize.translate("sharedcomponents#Up") + '"><i class="md-icon"></i></button>', currentHtml += '<button type="button" is="paper-icon-button-light" class="btnViewItemDown btnViewItemMove autoSize" title="' + globalize.translate("sharedcomponents#Down") + '"><i class="md-icon"></i></button>', currentHtml += "</div>", index++, currentHtml
|
||||
}).join(""), context.querySelector(".viewOrderList").innerHTML = html
|
||||
|
||||
var html = '';
|
||||
|
||||
var index = 0;
|
||||
|
||||
html += result.Items.map(function (view) {
|
||||
|
||||
var currentHtml = '';
|
||||
|
||||
currentHtml += '<div class="listItem viewItem" data-viewid="' + view.Id + '">';
|
||||
|
||||
currentHtml += '<i class="md-icon listItemIcon"></i>';
|
||||
|
||||
currentHtml += '<div class="listItemBody">';
|
||||
|
||||
currentHtml += '<div>';
|
||||
currentHtml += view.Name;
|
||||
currentHtml += '</div>';
|
||||
|
||||
currentHtml += '</div>';
|
||||
|
||||
currentHtml += '<button type="button" is="paper-icon-button-light" class="btnViewItemUp btnViewItemMove autoSize" title="' + globalize.translate('sharedcomponents#Up') + '"><i class="md-icon"></i></button>';
|
||||
currentHtml += '<button type="button" is="paper-icon-button-light" class="btnViewItemDown btnViewItemMove autoSize" title="' + globalize.translate('sharedcomponents#Down') + '"><i class="md-icon"></i></button>';
|
||||
|
||||
currentHtml += '</div>';
|
||||
|
||||
index++;
|
||||
return currentHtml;
|
||||
|
||||
}).join('');
|
||||
|
||||
context.querySelector('.viewOrderList').innerHTML = html;
|
||||
}
|
||||
|
||||
function updateHomeSectionValues(context, userSettings) {
|
||||
|
||||
for (var i = 1; i <= 7; i++) {
|
||||
var select = context.querySelector("#selectHomeSection" + i),
|
||||
defaultValue = homeSections.getDefaultSection(i - 1),
|
||||
option = select.querySelector("option[value=" + defaultValue + "]") || select.querySelector('option[value=""]'),
|
||||
userValue = userSettings.get("homesection" + (i - 1));
|
||||
option.value = "", select.value = userValue !== defaultValue && userValue ? userValue : ""
|
||||
|
||||
var select = context.querySelector('#selectHomeSection' + i);
|
||||
var defaultValue = homeSections.getDefaultSection(i - 1);
|
||||
|
||||
var option = select.querySelector('option[value=' + defaultValue + ']') || select.querySelector('option[value=""]');
|
||||
|
||||
var userValue = userSettings.get('homesection' + (i - 1));
|
||||
|
||||
option.value = '';
|
||||
|
||||
if (userValue === defaultValue || !userValue) {
|
||||
select.value = '';
|
||||
} else {
|
||||
select.value = userValue;
|
||||
}
|
||||
}
|
||||
context.querySelector(".selectTVHomeScreen").value = userSettings.get("tvhome") || ""
|
||||
|
||||
context.querySelector('.selectTVHomeScreen').value = userSettings.get('tvhome') || '';
|
||||
}
|
||||
|
||||
function getPerLibrarySettingsHtml(item, user, userSettings, apiClient) {
|
||||
var isChecked, html = "";
|
||||
if ("Channel" !== item.Type && "boxsets" !== item.CollectionType && "playlists" !== item.CollectionType || (isChecked = -1 === (user.Configuration.MyMediaExcludes || []).indexOf(item.Id), html += "<div>", html += "<label>", html += '<input type="checkbox" is="emby-checkbox" class="chkIncludeInMyMedia" data-folderid="' + item.Id + '"' + (isChecked ? ' checked="checked"' : "") + "/>", html += "<span>" + globalize.translate("sharedcomponents#DisplayInMyMedia") + "</span>", html += "</label>", html += "</div>"), -1 === ["playlists", "livetv", "boxsets", "channels"].indexOf(item.CollectionType || "") && (isChecked = -1 === user.Configuration.LatestItemsExcludes.indexOf(item.Id), html += '<label class="fldIncludeInLatest">', html += '<input type="checkbox" is="emby-checkbox" class="chkIncludeInLatest" data-folderid="' + item.Id + '"' + (isChecked ? ' checked="checked"' : "") + "/>", html += "<span>" + globalize.translate("sharedcomponents#DisplayInOtherHomeScreenSections") + "</span>", html += "</label>"), html && (html = '<div class="checkboxListContainer">' + html + "</div>"), "movies" === item.CollectionType || "tvshows" === item.CollectionType || "music" === item.CollectionType || "livetv" === item.CollectionType) {
|
||||
var idForLanding = "livetv" === item.CollectionType ? item.CollectionType : item.Id;
|
||||
html += '<div class="selectContainer">', html += '<select is="emby-select" class="selectLanding" data-folderid="' + idForLanding + '" label="' + globalize.translate("sharedcomponents#LabelDefaultScreen") + '">';
|
||||
var userValue = userSettings.get("landing-" + idForLanding);
|
||||
html += getLandingScreenOptionsHtml(item.CollectionType, userValue), html += "</select>", html += "</div>"
|
||||
|
||||
var html = '';
|
||||
|
||||
var isChecked;
|
||||
|
||||
if (item.Type === 'Channel' || item.CollectionType === 'boxsets' || item.CollectionType === 'playlists') {
|
||||
isChecked = (user.Configuration.MyMediaExcludes || []).indexOf(item.Id) === -1;
|
||||
html += '<div>';
|
||||
html += '<label>';
|
||||
html += '<input type="checkbox" is="emby-checkbox" class="chkIncludeInMyMedia" data-folderid="' + item.Id + '"' + (isChecked ? ' checked="checked"' : '') + '/>';
|
||||
html += '<span>' + globalize.translate('sharedcomponents#DisplayInMyMedia') + '</span>';
|
||||
html += '</label>';
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
var excludeFromLatest = ['playlists', 'livetv', 'boxsets', 'channels'];
|
||||
if (excludeFromLatest.indexOf(item.CollectionType || '') === -1) {
|
||||
|
||||
isChecked = user.Configuration.LatestItemsExcludes.indexOf(item.Id) === -1;
|
||||
html += '<label class="fldIncludeInLatest">';
|
||||
html += '<input type="checkbox" is="emby-checkbox" class="chkIncludeInLatest" data-folderid="' + item.Id + '"' + (isChecked ? ' checked="checked"' : '') + '/>';
|
||||
html += '<span>' + globalize.translate('sharedcomponents#DisplayInOtherHomeScreenSections') + '</span>';
|
||||
html += '</label>';
|
||||
}
|
||||
|
||||
if (html) {
|
||||
var prefix = "";
|
||||
prefix += '<div class="verticalSection">', prefix += '<h2 class="sectionTitle">', prefix += item.Name, prefix += "</h2>", html = prefix + html, html += "</div>"
|
||||
|
||||
html = '<div class="checkboxListContainer">' + html + '</div>';
|
||||
}
|
||||
return html
|
||||
|
||||
if (item.CollectionType === 'movies' || item.CollectionType === 'tvshows' || item.CollectionType === 'music' || item.CollectionType === 'livetv') {
|
||||
|
||||
var idForLanding = item.CollectionType === 'livetv' ? item.CollectionType : item.Id;
|
||||
html += '<div class="selectContainer">';
|
||||
html += '<select is="emby-select" class="selectLanding" data-folderid="' + idForLanding + '" label="' + globalize.translate('sharedcomponents#LabelDefaultScreen') + '">';
|
||||
|
||||
var userValue = userSettings.get('landing-' + idForLanding);
|
||||
|
||||
html += getLandingScreenOptionsHtml(item.CollectionType, userValue);
|
||||
|
||||
html += '</select>';
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
if (html) {
|
||||
|
||||
var prefix = '';
|
||||
prefix += '<div class="verticalSection">';
|
||||
|
||||
prefix += '<h2 class="sectionTitle">';
|
||||
prefix += item.Name;
|
||||
prefix += '</h2>';
|
||||
|
||||
html = prefix + html;
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function renderPerLibrarySettings(context, user, userViews, userSettings, apiClient) {
|
||||
for (var elem = context.querySelector(".perLibrarySettings"), html = "", i = 0, length = userViews.length; i < length; i++) html += getPerLibrarySettingsHtml(userViews[i], user, userSettings, apiClient);
|
||||
elem.innerHTML = html
|
||||
|
||||
var elem = context.querySelector('.perLibrarySettings');
|
||||
var html = '';
|
||||
|
||||
for (var i = 0, length = userViews.length; i < length; i++) {
|
||||
|
||||
html += getPerLibrarySettingsHtml(userViews[i], user, userSettings, apiClient);
|
||||
}
|
||||
|
||||
elem.innerHTML = html;
|
||||
}
|
||||
|
||||
function loadForm(context, user, userSettings, apiClient) {
|
||||
context.querySelector(".chkHidePlayedFromLatest").checked = user.Configuration.HidePlayedInLatest || !1, updateHomeSectionValues(context, userSettings);
|
||||
var promise1 = apiClient.getUserViews({
|
||||
IncludeHidden: !0
|
||||
}, user.Id),
|
||||
promise2 = apiClient.getJSON(apiClient.getUrl("Users/" + user.Id + "/GroupingOptions"));
|
||||
Promise.all([promise1, promise2]).then(function(responses) {
|
||||
renderViewOrder(context, user, responses[0]), renderPerLibrarySettings(context, user, responses[0].Items, userSettings, apiClient), renderViews(context, user, responses[1]), loading.hide()
|
||||
})
|
||||
|
||||
context.querySelector('.chkHidePlayedFromLatest').checked = user.Configuration.HidePlayedInLatest || false;
|
||||
|
||||
updateHomeSectionValues(context, userSettings);
|
||||
|
||||
var promise1 = apiClient.getUserViews({ IncludeHidden: true }, user.Id);
|
||||
var promise2 = apiClient.getJSON(apiClient.getUrl("Users/" + user.Id + "/GroupingOptions"));
|
||||
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
|
||||
renderViewOrder(context, user, responses[0]);
|
||||
|
||||
renderPerLibrarySettings(context, user, responses[0].Items, userSettings, apiClient);
|
||||
|
||||
renderViews(context, user, responses[1]);
|
||||
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function getSibling(elem, type, className) {
|
||||
|
||||
var sibling = elem[type];
|
||||
|
||||
while (sibling != null) {
|
||||
if (sibling.classList.contains(className)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sibling != null) {
|
||||
if (!sibling.classList.contains(className)) {
|
||||
sibling = null;
|
||||
}
|
||||
}
|
||||
|
||||
return sibling;
|
||||
}
|
||||
|
||||
function onSectionOrderListClick(e) {
|
||||
var target = dom.parentWithClass(e.target, "btnViewItemMove");
|
||||
|
||||
var target = dom.parentWithClass(e.target, 'btnViewItemMove');
|
||||
|
||||
if (target) {
|
||||
var viewItem = dom.parentWithClass(target, "viewItem");
|
||||
var viewItem = dom.parentWithClass(target, 'viewItem');
|
||||
|
||||
if (viewItem) {
|
||||
dom.parentWithClass(viewItem, "paperList");
|
||||
if (target.classList.contains("btnViewItemDown")) {
|
||||
var ul = dom.parentWithClass(viewItem, 'paperList');
|
||||
|
||||
if (target.classList.contains('btnViewItemDown')) {
|
||||
|
||||
var next = viewItem.nextSibling;
|
||||
next && (viewItem.parentNode.removeChild(viewItem), next.parentNode.insertBefore(viewItem, next.nextSibling))
|
||||
|
||||
if (next) {
|
||||
viewItem.parentNode.removeChild(viewItem);
|
||||
next.parentNode.insertBefore(viewItem, next.nextSibling);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
var prev = viewItem.previousSibling;
|
||||
prev && (viewItem.parentNode.removeChild(viewItem), prev.parentNode.insertBefore(viewItem, prev))
|
||||
|
||||
if (prev) {
|
||||
viewItem.parentNode.removeChild(viewItem);
|
||||
prev.parentNode.insertBefore(viewItem, prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCheckboxItems(selector, context, isChecked) {
|
||||
for (var inputs = context.querySelectorAll(selector), list = [], i = 0, length = inputs.length; i < length; i++) inputs[i].checked === isChecked && list.push(inputs[i]);
|
||||
return list
|
||||
|
||||
var inputs = context.querySelectorAll(selector);
|
||||
var list = [];
|
||||
|
||||
for (var i = 0, length = inputs.length; i < length; i++) {
|
||||
|
||||
if (inputs[i].checked === isChecked) {
|
||||
list.push(inputs[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function saveUser(context, user, userSettingsInstance, apiClient) {
|
||||
user.Configuration.HidePlayedInLatest = context.querySelector(".chkHidePlayedFromLatest").checked, user.Configuration.LatestItemsExcludes = getCheckboxItems(".chkIncludeInLatest", context, !1).map(function(i) {
|
||||
return i.getAttribute("data-folderid")
|
||||
}), user.Configuration.MyMediaExcludes = getCheckboxItems(".chkIncludeInMyMedia", context, !1).map(function(i) {
|
||||
return i.getAttribute("data-folderid")
|
||||
}), user.Configuration.GroupedFolders = getCheckboxItems(".chkGroupFolder", context, !0).map(function(i) {
|
||||
return i.getAttribute("data-folderid")
|
||||
|
||||
user.Configuration.HidePlayedInLatest = context.querySelector('.chkHidePlayedFromLatest').checked;
|
||||
|
||||
user.Configuration.LatestItemsExcludes = getCheckboxItems(".chkIncludeInLatest", context, false).map(function (i) {
|
||||
|
||||
return i.getAttribute('data-folderid');
|
||||
});
|
||||
var i, length, viewItems = context.querySelectorAll(".viewItem"),
|
||||
orderedViews = [];
|
||||
for (i = 0, length = viewItems.length; i < length; i++) orderedViews.push(viewItems[i].getAttribute("data-viewid"));
|
||||
user.Configuration.OrderedViews = orderedViews, userSettingsInstance.set("tvhome", context.querySelector(".selectTVHomeScreen").value), userSettingsInstance.set("homesection0", context.querySelector("#selectHomeSection1").value), userSettingsInstance.set("homesection1", context.querySelector("#selectHomeSection2").value), userSettingsInstance.set("homesection2", context.querySelector("#selectHomeSection3").value), userSettingsInstance.set("homesection3", context.querySelector("#selectHomeSection4").value), userSettingsInstance.set("homesection4", context.querySelector("#selectHomeSection5").value), userSettingsInstance.set("homesection5", context.querySelector("#selectHomeSection6").value), userSettingsInstance.set("homesection6", context.querySelector("#selectHomeSection7").value);
|
||||
var selectLandings = context.querySelectorAll(".selectLanding");
|
||||
|
||||
user.Configuration.MyMediaExcludes = getCheckboxItems(".chkIncludeInMyMedia", context, false).map(function (i) {
|
||||
|
||||
return i.getAttribute('data-folderid');
|
||||
});
|
||||
|
||||
user.Configuration.GroupedFolders = getCheckboxItems(".chkGroupFolder", context, true).map(function (i) {
|
||||
|
||||
return i.getAttribute('data-folderid');
|
||||
});
|
||||
|
||||
var viewItems = context.querySelectorAll('.viewItem');
|
||||
var orderedViews = [];
|
||||
var i, length;
|
||||
for (i = 0, length = viewItems.length; i < length; i++) {
|
||||
orderedViews.push(viewItems[i].getAttribute('data-viewid'));
|
||||
}
|
||||
|
||||
user.Configuration.OrderedViews = orderedViews;
|
||||
|
||||
userSettingsInstance.set('tvhome', context.querySelector('.selectTVHomeScreen').value);
|
||||
|
||||
userSettingsInstance.set('homesection0', context.querySelector('#selectHomeSection1').value);
|
||||
userSettingsInstance.set('homesection1', context.querySelector('#selectHomeSection2').value);
|
||||
userSettingsInstance.set('homesection2', context.querySelector('#selectHomeSection3').value);
|
||||
userSettingsInstance.set('homesection3', context.querySelector('#selectHomeSection4').value);
|
||||
userSettingsInstance.set('homesection4', context.querySelector('#selectHomeSection5').value);
|
||||
userSettingsInstance.set('homesection5', context.querySelector('#selectHomeSection6').value);
|
||||
userSettingsInstance.set('homesection6', context.querySelector('#selectHomeSection7').value);
|
||||
|
||||
var selectLandings = context.querySelectorAll('.selectLanding');
|
||||
for (i = 0, length = selectLandings.length; i < length; i++) {
|
||||
var selectLanding = selectLandings[i];
|
||||
userSettingsInstance.set("landing-" + selectLanding.getAttribute("data-folderid"), selectLanding.value)
|
||||
userSettingsInstance.set('landing-' + selectLanding.getAttribute('data-folderid'), selectLanding.value);
|
||||
}
|
||||
return apiClient.updateUserConfiguration(user.Id, user.Configuration)
|
||||
|
||||
return apiClient.updateUserConfiguration(user.Id, user.Configuration);
|
||||
}
|
||||
|
||||
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
|
||||
loading.show(), apiClient.getUser(userId).then(function(user) {
|
||||
saveUser(context, user, userSettings, apiClient).then(function() {
|
||||
loading.hide(), enableSaveConfirmation && require(["toast"], function(toast) {
|
||||
toast(globalize.translate("sharedcomponents#SettingsSaved"))
|
||||
}), events.trigger(instance, "saved")
|
||||
}, function() {
|
||||
loading.hide()
|
||||
})
|
||||
})
|
||||
|
||||
loading.show();
|
||||
|
||||
apiClient.getUser(userId).then(function (user) {
|
||||
|
||||
saveUser(context, user, userSettings, apiClient).then(function () {
|
||||
|
||||
loading.hide();
|
||||
if (enableSaveConfirmation) {
|
||||
require(['toast'], function (toast) {
|
||||
toast(globalize.translate('sharedcomponents#SettingsSaved'));
|
||||
});
|
||||
}
|
||||
|
||||
events.trigger(instance, 'saved');
|
||||
|
||||
}, function () {
|
||||
loading.hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
var self = this,
|
||||
apiClient = connectionManager.getApiClient(self.options.serverId),
|
||||
userId = self.options.userId,
|
||||
userSettings = self.options.userSettings;
|
||||
return userSettings.setUserInfo(userId, apiClient).then(function() {
|
||||
|
||||
var self = this;
|
||||
var apiClient = connectionManager.getApiClient(self.options.serverId);
|
||||
var userId = self.options.userId;
|
||||
var userSettings = self.options.userSettings;
|
||||
|
||||
userSettings.setUserInfo(userId, apiClient).then(function () {
|
||||
|
||||
var enableSaveConfirmation = self.options.enableSaveConfirmation;
|
||||
save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation)
|
||||
}), e && e.preventDefault(), !1
|
||||
save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation);
|
||||
});
|
||||
|
||||
// Disable default form submission
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onChange(e) {
|
||||
var chkIncludeInMyMedia = dom.parentWithClass(e.target, "chkIncludeInMyMedia");
|
||||
if (chkIncludeInMyMedia) {
|
||||
var section = dom.parentWithClass(chkIncludeInMyMedia, "verticalSection"),
|
||||
fldIncludeInLatest = section.querySelector(".fldIncludeInLatest");
|
||||
fldIncludeInLatest && (chkIncludeInMyMedia.checked ? fldIncludeInLatest.classList.remove("hide") : fldIncludeInLatest.classList.add("hide"))
|
||||
|
||||
var chkIncludeInMyMedia = dom.parentWithClass(e.target, 'chkIncludeInMyMedia');
|
||||
if (!chkIncludeInMyMedia) {
|
||||
return;
|
||||
}
|
||||
|
||||
var section = dom.parentWithClass(chkIncludeInMyMedia, 'verticalSection');
|
||||
var fldIncludeInLatest = section.querySelector('.fldIncludeInLatest');
|
||||
if (fldIncludeInLatest) {
|
||||
if (chkIncludeInMyMedia.checked) {
|
||||
fldIncludeInLatest.classList.remove('hide');
|
||||
} else {
|
||||
fldIncludeInLatest.classList.add('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function embed(options, self) {
|
||||
require(["text!./homescreensettings.template.html"], function(template) {
|
||||
for (var i = 1; i <= numConfigurableSections; i++) template = template.replace("{section" + i + "label}", globalize.translate("sharedcomponents#LabelHomeScreenSectionValue", i));
|
||||
options.element.innerHTML = globalize.translateDocument(template, "sharedcomponents"), options.element.querySelector(".viewOrderList").addEventListener("click", onSectionOrderListClick), options.element.querySelector("form").addEventListener("submit", onSubmit.bind(self)), options.element.addEventListener("change", onChange), options.enableSaveButton && options.element.querySelector(".btnSave").classList.remove("hide"), layoutManager.tv ? options.element.querySelector(".selectTVHomeScreenContainer").classList.remove("hide") : options.element.querySelector(".selectTVHomeScreenContainer").classList.add("hide"), self.loadData(options.autoFocus)
|
||||
})
|
||||
|
||||
require(['text!./homescreensettings.template.html'], function (template) {
|
||||
|
||||
for (var i = 1; i <= numConfigurableSections; i++) {
|
||||
template = template.replace('{section' + i + 'label}', globalize.translate('sharedcomponents#LabelHomeScreenSectionValue', i));
|
||||
}
|
||||
|
||||
options.element.innerHTML = globalize.translateDocument(template, 'sharedcomponents');
|
||||
|
||||
options.element.querySelector('.viewOrderList').addEventListener('click', onSectionOrderListClick);
|
||||
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
|
||||
options.element.addEventListener('change', onChange);
|
||||
|
||||
if (options.enableSaveButton) {
|
||||
options.element.querySelector('.btnSave').classList.remove('hide');
|
||||
}
|
||||
|
||||
if (layoutManager.tv) {
|
||||
options.element.querySelector('.selectTVHomeScreenContainer').classList.remove('hide');
|
||||
} else {
|
||||
options.element.querySelector('.selectTVHomeScreenContainer').classList.add('hide');
|
||||
}
|
||||
|
||||
self.loadData(options.autoFocus);
|
||||
});
|
||||
}
|
||||
|
||||
function HomeScreenSettings(options) {
|
||||
this.options = options, embed(options, this)
|
||||
|
||||
this.options = options;
|
||||
|
||||
embed(options, this);
|
||||
}
|
||||
var numConfigurableSections = 7;
|
||||
return HomeScreenSettings.prototype.loadData = function(autoFocus) {
|
||||
var self = this,
|
||||
context = self.options.element;
|
||||
|
||||
HomeScreenSettings.prototype.loadData = function (autoFocus) {
|
||||
|
||||
var self = this;
|
||||
var context = self.options.element;
|
||||
|
||||
loading.show();
|
||||
var userId = self.options.userId,
|
||||
apiClient = connectionManager.getApiClient(self.options.serverId),
|
||||
userSettings = self.options.userSettings;
|
||||
apiClient.getUser(userId).then(function(user) {
|
||||
userSettings.setUserInfo(userId, apiClient).then(function() {
|
||||
self.dataLoaded = !0, loadForm(context, user, userSettings, apiClient), autoFocus && focusManager.autoFocus(context)
|
||||
})
|
||||
})
|
||||
}, HomeScreenSettings.prototype.submit = function() {
|
||||
onSubmit.call(this)
|
||||
}, HomeScreenSettings.prototype.destroy = function() {
|
||||
this.options = null
|
||||
}, HomeScreenSettings
|
||||
|
||||
var userId = self.options.userId;
|
||||
var apiClient = connectionManager.getApiClient(self.options.serverId);
|
||||
var userSettings = self.options.userSettings;
|
||||
|
||||
apiClient.getUser(userId).then(function (user) {
|
||||
|
||||
userSettings.setUserInfo(userId, apiClient).then(function () {
|
||||
|
||||
self.dataLoaded = true;
|
||||
|
||||
loadForm(context, user, userSettings, apiClient);
|
||||
|
||||
if (autoFocus) {
|
||||
focusManager.autoFocus(context);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
HomeScreenSettings.prototype.submit = function () {
|
||||
onSubmit.call(this);
|
||||
};
|
||||
|
||||
HomeScreenSettings.prototype.destroy = function () {
|
||||
|
||||
this.options = null;
|
||||
};
|
||||
|
||||
return HomeScreenSettings;
|
||||
});
|
|
@ -1,47 +1,88 @@
|
|||
define(["dialogHelper", "layoutManager", "globalize", "require", "events", "homescreenSettings", "paper-icon-button-light", "css!./../formdialog"], function(dialogHelper, layoutManager, globalize, require, events, HomescreenSettings) {
|
||||
"use strict";
|
||||
define(['dialogHelper', 'layoutManager', 'globalize', 'require', 'events', 'homescreenSettings', 'paper-icon-button-light', 'css!./../formdialog'], function (dialogHelper, layoutManager, globalize, require, events, HomescreenSettings) {
|
||||
'use strict';
|
||||
|
||||
function centerFocus(elem, horiz, on) {
|
||||
require(["scrollHelper"], function(scrollHelper) {
|
||||
var fn = on ? "on" : "off";
|
||||
scrollHelper.centerFocus[fn](elem, horiz)
|
||||
})
|
||||
require(['scrollHelper'], function (scrollHelper) {
|
||||
var fn = on ? 'on' : 'off';
|
||||
scrollHelper.centerFocus[fn](elem, horiz);
|
||||
});
|
||||
}
|
||||
|
||||
function show(options) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["text!./homescreensettingsdialog.template.html"], function(template) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['text!./homescreensettingsdialog.template.html'], function (template) {
|
||||
|
||||
var dialogOptions = {
|
||||
removeOnClose: !0,
|
||||
scrollY: !1
|
||||
removeOnClose: true,
|
||||
scrollY: false
|
||||
};
|
||||
layoutManager.tv ? dialogOptions.size = "fullscreen" : dialogOptions.size = "medium-tall";
|
||||
|
||||
if (layoutManager.tv) {
|
||||
dialogOptions.size = 'fullscreen';
|
||||
} else {
|
||||
dialogOptions.size = 'medium-tall';
|
||||
}
|
||||
|
||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||
dlg.classList.add("formDialog");
|
||||
var html = "",
|
||||
submitted = !1;
|
||||
html += globalize.translateDocument(template, "sharedcomponents"), dlg.innerHTML = html, layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !0);
|
||||
|
||||
dlg.classList.add('formDialog');
|
||||
|
||||
var html = '';
|
||||
var submitted = false;
|
||||
|
||||
html += globalize.translateDocument(template, 'sharedcomponents');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
if (layoutManager.tv) {
|
||||
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
|
||||
}
|
||||
|
||||
var homescreenSettingsInstance = new HomescreenSettings({
|
||||
serverId: options.serverId,
|
||||
userId: options.userId,
|
||||
element: dlg.querySelector(".settingsContent"),
|
||||
element: dlg.querySelector('.settingsContent'),
|
||||
userSettings: options.userSettings,
|
||||
enableSaveButton: !1,
|
||||
enableSaveConfirmation: !1
|
||||
enableSaveButton: false,
|
||||
enableSaveConfirmation: false
|
||||
});
|
||||
dialogHelper.open(dlg), dlg.addEventListener("close", function() {
|
||||
layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !1), submitted ? resolve() : reject()
|
||||
}), dlg.querySelector(".btnCancel").addEventListener("click", function(e) {
|
||||
dialogHelper.close(dlg)
|
||||
}), dlg.querySelector(".btnSave").addEventListener("click", function(e) {
|
||||
submitted = !0, homescreenSettingsInstance.submit()
|
||||
}), events.on(homescreenSettingsInstance, "saved", function() {
|
||||
submitted = !0, dialogHelper.close(dlg)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
dialogHelper.open(dlg);
|
||||
|
||||
dlg.addEventListener('close', function () {
|
||||
|
||||
if (layoutManager.tv) {
|
||||
centerFocus(dlg.querySelector('.formDialogContent'), false, false);
|
||||
}
|
||||
|
||||
if (submitted) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
|
||||
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
||||
|
||||
dialogHelper.close(dlg);
|
||||
});
|
||||
|
||||
dlg.querySelector('.btnSave').addEventListener('click', function (e) {
|
||||
|
||||
submitted = true;
|
||||
homescreenSettingsInstance.submit();
|
||||
});
|
||||
|
||||
events.on(homescreenSettingsInstance, 'saved', function () {
|
||||
submitted = true;
|
||||
dialogHelper.close(dlg);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
show: show
|
||||
}
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue