jellyfin-web/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.js

71 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-08-12 23:33:31 -07:00
define(['globalize', 'emby-checkbox'], function (globalize) {
2016-08-13 13:54:29 -07:00
function embed(parent, contentType, libraryOptions) {
2016-08-12 23:33:31 -07:00
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/libraryoptionseditor/libraryoptionseditor.template.html', true);
xhr.onload = function (e) {
var template = this.response;
parent.innerHTML = globalize.translateDocument(template);
setContentType(parent, contentType);
2016-08-13 13:54:29 -07:00
if (libraryOptions) {
setLibraryOptions(parent, libraryOptions);
}
2016-08-12 23:33:31 -07:00
resolve();
}
xhr.send();
});
}
function setContentType(parent, contentType) {
if (contentType == 'music' || contentType == 'tvshows' || contentType == 'movies' || contentType == 'homevideos' || contentType == 'musicvideos' || contentType == 'mixed') {
parent.querySelector('.chkArhiveAsMediaContainer').classList.remove('hide');
} else {
parent.querySelector('.chkArhiveAsMediaContainer').classList.add('hide');
}
2016-08-14 21:36:17 -07:00
if (contentType == 'homevideos') {
parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
} else {
parent.querySelector('.chkEnablePhotosContainer').classList.add('hide');
}
2016-08-12 23:33:31 -07:00
if (contentType == 'music' || contentType == 'tvshows' || contentType == 'movies' || contentType == 'homevideos' || contentType == 'musicvideos' || contentType == 'mixed') {
parent.classList.remove('hide');
} else {
parent.classList.add('hide');
}
}
function getLibraryOptions(parent) {
var options = {
2016-08-14 21:36:17 -07:00
EnableArchiveMediaFiles: parent.querySelector('.chkArhiveAsMedia').checked,
EnablePhotos: parent.querySelector('.chkEnablePhotos').checked
2016-08-12 23:33:31 -07:00
};
return options;
}
2016-08-13 13:54:29 -07:00
function setLibraryOptions(parent, options) {
2016-08-14 21:36:17 -07:00
parent.querySelector('.chkArhiveAsMedia').checked = options.EnableArchiveMediaFiles;
parent.querySelector('.chkEnablePhotos').checked = options.EnablePhotos;
2016-08-13 13:54:29 -07:00
}
2016-08-12 23:33:31 -07:00
return {
embed: embed,
setContentType: setContentType,
2016-08-13 13:54:29 -07:00
getLibraryOptions: getLibraryOptions,
setLibraryOptions: setLibraryOptions
2016-08-12 23:33:31 -07:00
};
});