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,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-checkbox', 'paper-dialog', 'paper-input', 'paper-fab'], function (paperDialogHelper) {
function onSubmit() {
Dashboard.showLoadingMsg();
@ -33,13 +33,13 @@
url: url,
dataType: "json"
}).done(function (result) {
}).then(function (result) {
Dashboard.hideLoadingMsg();
var id = result.Id;
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
redirectToCollection(id);
});
@ -49,7 +49,7 @@
var context = getParameterByName('context');
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
ApiClient.getItem(Dashboard.getCurrentUserId(), id).then(function (item) {
Dashboard.navigate(LibraryBrowser.getHref(item, context));
@ -67,11 +67,11 @@
type: "POST",
url: url
}).done(function () {
}).then(function () {
Dashboard.hideLoadingMsg();
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
Dashboard.alert(Globalize.translate('MessageItemsAdded'));
});
@ -98,7 +98,7 @@
SortBy: "SortName"
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
ApiClient.getItems(Dashboard.getCurrentUserId(), options).then(function (result) {
var html = '';
@ -192,39 +192,36 @@
items = items || [];
require(['components/paperdialoghelper'], function () {
var dlg = paperDialogHelper.createDialog({
size: 'small'
});
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = items.length ? Globalize.translate('HeaderAddToCollection') : Globalize.translate('HeaderNewCollection');
var title = items.length ? Globalize.translate('HeaderAddToCollection') : Globalize.translate('HeaderNewCollection');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
paperDialogHelper.open(dlg);
PaperDialogHelper.openWithHash(dlg, 'collectioneditor');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
paperDialogHelper.close(dlg);
});
};
}

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-item', 'paper-input', 'paper-fab', 'paper-item-body'], function (paperDialogHelper) {
var systemInfo;
function getSystemInfo() {
@ -8,7 +8,7 @@
if (systemInfo) {
deferred.resolveWith(null, [systemInfo]);
} else {
ApiClient.getPublicSystemInfo().done(function (info) {
ApiClient.getPublicSystemInfo().then(function (info) {
systemInfo = info;
deferred.resolveWith(null, [systemInfo]);
});
@ -48,15 +48,15 @@
}
if (!parentPathPromise) {
parentPathPromise = $.Deferred();
parentPathPromise.resolveWith(null, []);
parentPathPromise = parentPathPromise.promise();
parentPathPromise = new Promise(function (resolve, reject) {
resolve();
});
}
$.when(promise, parentPathPromise).done(function (response1, response2) {
Promise.all([promise, parentPathPromise]).then(function (responses) {
var folders = response1[0];
var parentPath = response2 && response2.length ? response2[0] || '' : '';
var folders = responses[0];
var parentPath = responses[1] || '';
$('#txtDirectoryPickerPath', page).val(path || "");
@ -84,7 +84,7 @@
Dashboard.hideLoadingMsg();
}).fail(function () {
}, function () {
$('#txtDirectoryPickerPath', page).val("");
$('.results', page).html('');
@ -211,63 +211,60 @@
fileOptions.includeFiles = options.includeFiles;
}
getSystemInfo().done(function (systemInfo) {
getSystemInfo().then(function (systemInfo) {
require(['components/paperdialoghelper'], function () {
var dlg = PaperDialogHelper.createDialog({
theme: 'a',
size: 'medium'
});
dlg.classList.add('directoryPicker');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + (options.header || Globalize.translate('HeaderSelectPath')) + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml(options, systemInfo);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options, fileOptions);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-opened', function () {
this.querySelector('#txtDirectoryPickerPath input').focus();
});
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'directorybrowser');
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
currentDialog = dlg;
var txtCurrentPath = $('#txtDirectoryPickerPath', editorContent);
if (options.path) {
txtCurrentPath.val(options.path);
}
refreshDirectoryBrowser(editorContent, txtCurrentPath.val());
var dlg = paperDialogHelper.createDialog({
theme: 'a',
size: 'medium'
});
dlg.classList.add('directoryPicker');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + (options.header || Globalize.translate('HeaderSelectPath')) + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml(options, systemInfo);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options, fileOptions);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-opened', function () {
this.querySelector('#txtDirectoryPickerPath input').focus();
});
$(dlg).on('iron-overlay-closed', onDialogClosed);
paperDialogHelper.open(dlg);
$('.btnCloseDialog', dlg).on('click', function () {
paperDialogHelper.close(dlg);
});
currentDialog = dlg;
var txtCurrentPath = $('#txtDirectoryPickerPath', editorContent);
if (options.path) {
txtCurrentPath.val(options.path);
}
refreshDirectoryBrowser(editorContent, txtCurrentPath.val());
});
};
self.close = function () {
if (currentDialog) {
PaperDialogHelper.close(currentDialog);
paperDialogHelper.close(currentDialog);
}
};

View file

@ -0,0 +1,64 @@
define([], function () {
/*
* Javascript Humane Dates
* Copyright (c) 2008 Dean Landolt (deanlandolt.com)
* Re-write by Zach Leatherman (zachleat.com)
*
* Adopted from the John Resig's pretty.js
* at http://ejohn.org/blog/javascript-pretty-date
* and henrah's proposed modification
* at http://ejohn.org/blog/javascript-pretty-date/#comment-297458
*
* Licensed under the MIT license.
*/
function humane_date(date_str) {
var time_formats = [[90, 'a minute'], // 60*1.5
[3600, 'minutes', 60], // 60*60, 60
[5400, 'an hour'], // 60*60*1.5
[86400, 'hours', 3600], // 60*60*24, 60*60
[129600, 'a day'], // 60*60*24*1.5
[604800, 'days', 86400], // 60*60*24*7, 60*60*24
[907200, 'a week'], // 60*60*24*7*1.5
[2628000, 'weeks', 604800], // 60*60*24*(365/12), 60*60*24*7
[3942000, 'a month'], // 60*60*24*(365/12)*1.5
[31536000, 'months', 2628000], // 60*60*24*365, 60*60*24*(365/12)
[47304000, 'a year'], // 60*60*24*365*1.5
[3153600000, 'years', 31536000] // 60*60*24*365*100, 60*60*24*365
];
var dt = new Date;
var date = parseISO8601Date(date_str, { toLocal: true });
var seconds = ((dt - date) / 1000);
var token = ' ago';
var i = 0;
var format;
if (seconds < 0) {
seconds = Math.abs(seconds);
token = '';
}
while (format = time_formats[i++]) {
if (seconds < format[0]) {
if (format.length == 2) {
return format[1] + token;
} else {
return Math.round(seconds / format[2]) + ' ' + format[1] + token;
}
}
}
// overflow for centuries
if (seconds > 4730400000)
return Math.round(seconds / 4730400000) + ' centuries' + token;
return date_str;
}
window.humane_date = humane_date;
return humane_date;
});

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper', 'paper-checkbox', 'paper-dialog', 'paper-fab'], function (paperDialogHelper) {
var currentItemId;
var currentItemType;
@ -6,7 +6,7 @@
var hasChanges = false;
// These images can be large and we're seeing memory problems in safari
var browsableImagePageSize = $.browser.safari ? 6 : 10;
var browsableImagePageSize = browserInfo.safari ? 6 : 10;
var browsableImageStartIndex = 0;
var browsableImageType = 'Primary';
@ -38,7 +38,7 @@
options.ProviderName = provider;
}
ApiClient.getAvailableRemoteImages(options).done(function (result) {
ApiClient.getAvailableRemoteImages(options).then(function (result) {
renderRemoteImages(page, result, browsableImageType, options.startIndex, options.limit);
@ -65,7 +65,9 @@
html += getRemoteImageHtml(imagesResult.Images[i], imageType);
}
$('.availableImagesList', page).html(html).lazyChildren();
var availableImagesList = page.querySelector('.availableImagesList');
availableImagesList.innerHTML = html;
ImageLoader.lazyChildren(availableImagesList);
$('.btnNextPage', page).on('click', function () {
browsableImageStartIndex += browsableImagePageSize;
@ -125,11 +127,11 @@
Dashboard.showLoadingMsg();
ApiClient.downloadRemoteImage(options).done(function () {
ApiClient.downloadRemoteImage(options).then(function () {
hasChanges = true;
var dlg = $(page).parents('paper-dialog')[0];
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
});
}
@ -260,17 +262,16 @@
Dashboard.showLoadingMsg();
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/imagedownloader/imagedownloader.template.html', true);
type: 'GET',
url: 'components/imagedownloader/imagedownloader.template.html'
}).done(function (template) {
xhr.onload = function (e) {
var template = this.response;
currentItemId = itemId;
currentItemType = itemType;
var dlg = PaperDialogHelper.createDialog();
var dlg = paperDialogHelper.createDialog();
var html = '';
html += '<h2 class="dialogHeader">';
@ -288,18 +289,20 @@
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'imagedownloader');
paperDialogHelper.open(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent);
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
});
reloadBrowsableImages(editorContent);
});
}
xhr.send();
}
function onDialogClosed() {
@ -309,7 +312,7 @@
currentDeferred.resolveWith(null, [hasChanges]);
}
window.ImageDownloader = {
return {
show: function (itemId, itemType, imageType) {
var deferred = DeferredBuilder.Deferred();
@ -320,12 +323,8 @@
browsableImageType = imageType || 'Primary';
selectedProvider = null;
require(['components/paperdialoghelper'], function () {
showEditor(itemId, itemType);
});
showEditor(itemId, itemType);
return deferred.promise();
}
};
})(jQuery, window, document);
});

View file

@ -1,4 +1,4 @@
(function ($, document, window, FileReader, escape) {
define(['components/paperdialoghelper', 'css!css/metadataeditor.css', 'paper-fab'], function (paperDialogHelper) {
var currentItem;
var currentDeferred;
@ -21,7 +21,7 @@
reloadItem(page, item);
}
else {
ApiClient.getItem(Dashboard.getCurrentUserId(), currentItem.Id).done(function (item) {
ApiClient.getItem(Dashboard.getCurrentUserId(), currentItem.Id).then(function (item) {
reloadItem(page, item);
});
}
@ -31,7 +31,7 @@
currentItem = item;
ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).done(function (providers) {
ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
if (providers.length) {
$('.btnBrowseAllImages', page).removeClass('hide');
@ -39,7 +39,7 @@
$('.btnBrowseAllImages', page).addClass('hide');
}
ApiClient.getItemImageInfos(currentItem.Id).done(function (imageInfos) {
ApiClient.getItemImageInfos(currentItem.Id).then(function (imageInfos) {
renderStandardImages(page, item, imageInfos, providers);
renderBackdrops(page, item, imageInfos, providers);
@ -122,7 +122,7 @@
Dashboard.confirm(Globalize.translate('DeleteImageConfirmation'), Globalize.translate('HeaderDeleteImage'), function (result) {
if (result) {
ApiClient.deleteItemImage(currentItem.Id, type, index).done(function () {
ApiClient.deleteItemImage(currentItem.Id, type, index).then(function () {
hasChanges = true;
reload(page);
@ -137,7 +137,7 @@
var type = this.getAttribute('data-imagetype');
var index = parseInt(this.getAttribute('data-index'));
var newIndex = parseInt(this.getAttribute('data-newindex'));
ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).done(function () {
ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).then(function () {
hasChanges = true;
reload(page);
@ -190,9 +190,9 @@
}
function showImageDownloader(page, imageType) {
require(['components/imagedownloader/imagedownloader'], function () {
require(['components/imagedownloader/imagedownloader'], function (ImageDownloader) {
ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).done(function (hasChanged) {
ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).then(function (hasChanged) {
if (hasChanged) {
hasChanges = true;
@ -206,13 +206,13 @@
$('.btnOpenUploadMenu', page).on('click', function () {
require(['components/imageuploader/imageuploader'], function () {
require(['components/imageuploader/imageuploader'], function (imageUploader) {
imageUploader.show(currentItem.Id, {
ImageUploader.show(currentItem.Id, {
theme: options.theme
}).done(function (hasChanged) {
}).then(function (hasChanged) {
if (hasChanged) {
hasChanges = true;
@ -233,16 +233,15 @@
Dashboard.showLoadingMsg();
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/imageeditor/imageeditor.template.html', true);
type: 'GET',
url: 'components/imageeditor/imageeditor.template.html'
xhr.onload = function (e) {
}).done(function (template) {
var template = this.response;
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(function (item) {
var dlg = PaperDialogHelper.createDialog({
var dlg = paperDialogHelper.createDialog({
theme: options.theme
});
@ -264,17 +263,19 @@
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'imageeditor');
paperDialogHelper.open(dlg);
var editorContent = dlg.querySelector('.editorContent');
reload(editorContent, item);
$('.btnCloseDialog', dlg).on('click', function() {
PaperDialogHelper.close(dlg);
$('.btnCloseDialog', dlg).on('click', function () {
paperDialogHelper.close(dlg);
});
});
});
}
xhr.send();
}
function onDialogClosed() {
@ -284,7 +285,7 @@
currentDeferred.resolveWith(null, [hasChanges]);
}
window.ImageEditor = {
return {
show: function (itemId, options) {
var deferred = DeferredBuilder.Deferred();
@ -292,13 +293,8 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
Dashboard.importCss('css/metadataeditor.css');
showEditor(itemId, options);
});
showEditor(itemId, options);
return deferred.promise();
}
};
})(jQuery, document, window, window.FileReader, escape);
});

View file

@ -0,0 +1,185 @@
(function () {
function setImageIntoElement(elem, url) {
if (elem.tagName !== "IMG") {
elem.style.backgroundImage = "url('" + url + "')";
} else {
elem.setAttribute("src", url);
}
if (browserInfo.chrome && !browserInfo.mobile) {
if (!elem.classList.contains('noFade')) {
fadeIn(elem, 1);
}
}
}
function fadeIn(elem, iterations) {
var keyframes = [
{ opacity: '0', offset: 0 },
{ opacity: '1', offset: 1 }];
var timing = { duration: 200, iterations: iterations };
return elem.animate(keyframes, timing);
}
// Request Quota (only for File System API)
var requestedBytes = 1024 * 1024 * 600; // MB
var imageCacheDirectoryEntry;
var imageCacheFolder = 'images';
function createDir(rootDirEntry, folders, callback, errorCallback) {
// Throw out './' or '/' and move on to prevent something like '/foo/.//bar'.
if (folders[0] == '.' || folders[0] == '') {
folders = folders.slice(1);
}
rootDirEntry.getDirectory(folders[0], { create: true }, function (dirEntry) {
// Recursively add the new subfolder (if we still have another to create).
if (folders.length > 1) {
createDir(dirEntry, folders.slice(1), callback, errorCallback);
} else {
callback(dirEntry);
}
}, errorCallback);
}
navigator.webkitPersistentStorage.requestQuota(requestedBytes, function (grantedBytes) {
var requestMethod = window.webkitRequestFileSystem || window.requestFileSystem;
requestMethod(PERSISTENT, grantedBytes, function (fs) {
fileSystem = fs;
createDir(fileSystem.root, imageCacheFolder.split('/'), function (dirEntry) {
imageCacheDirectoryEntry = dirEntry;
});
});
});
var fileSystem;
function imageFileStore() {
var self = this;
function getCacheKey(url) {
// Try to strip off the domain to share the cache between local and remote connections
var index = url.indexOf('://');
if (index != -1) {
url = url.substring(index + 3);
index = url.indexOf('/');
if (index != -1) {
url = url.substring(index + 1);
}
}
return CryptoJS.MD5(url).toString();
}
function downloadToFile(url, dir, filename, callback, errorCallback) {
Logger.log('Downloading ' + url);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = "arraybuffer";
xhr.onload = function (e) {
if (this.status == 200) {
writeData(dir, filename, this.getResponseHeader('Content-Type'), this.response, callback, errorCallback);
} else {
errorCallback('');
}
}
xhr.send();
}
function writeData(dir, filename, fileType, data, callback, errorCallback) {
dir.getFile(filename, { create: true }, function (fileEntry) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function (e) {
callback(fileEntry);
};
fileWriter.onerror = errorCallback;
// Create a new Blob and write it to log.txt.
var blob = new Blob([data], { type: fileType });
fileWriter.write(blob);
}, errorCallback);
}, errorCallback);
}
self.getImageUrl = function (originalUrl) {
return new Promise(function (resolve, reject) {
if (originalUrl.indexOf('tag=') != -1) {
originalUrl += "&accept=webp";
}
var key = getCacheKey(originalUrl);
var fileEntryCallback = function (fileEntry) {
resolve(fileEntry.toURL());
};
var errorCallback = function (e) {
Logger.log('Imagestore error: ' + e.name);
reject();
};
if (!fileSystem || !imageCacheDirectoryEntry) {
errorCallback('');
return;
}
var path = '/' + imageCacheFolder + "/" + key;
fileSystem.root.getFile(path, { create: false }, fileEntryCallback, function () {
downloadToFile(originalUrl, imageCacheDirectoryEntry, key, fileEntryCallback, errorCallback);
});
});
};
self.setImageInto = function (elem, url) {
self.getImageUrl(url).then(function (localUrl) {
setImageIntoElement(elem, localUrl);
}, function () {
setImageIntoElement(elem, url);
});
};
window.ImageStore = self;
}
require(['cryptojs-md5'], function () {
new imageFileStore();
});
})();

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper', 'paper-dialog', 'paper-fab'], function (paperDialogHelper) {
var currentItemId;
var currentFile;
@ -11,12 +11,12 @@
switch (evt.target.error.code) {
case evt.target.error.NOT_FOUND_ERR:
Dashboard.showError(Globalize.translate('MessageFileNotFound'));
Dashboard.alert(Globalize.translate('MessageFileNotFound'));
break;
case evt.target.error.ABORT_ERR:
break; // noop
default:
Dashboard.showError(Globalize.translate('MessageFileReadError'));
Dashboard.alert(Globalize.translate('MessageFileReadError'));
break;
};
}
@ -85,7 +85,7 @@
var imageType = $('#selectImageType', page).val();
ApiClient.uploadItemImage(currentItemId, imageType, file).done(function () {
ApiClient.uploadItemImage(currentItemId, imageType, file).then(function () {
$('#uploadImage', page).val('').trigger('change');
Dashboard.hideLoadingMsg();
@ -125,16 +125,15 @@
options = options || {};
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/imageuploader/imageuploader.template.html', true);
type: 'GET',
url: 'components/imageuploader/imageuploader.template.html'
}).done(function (template) {
xhr.onload = function (e) {
var template = this.response;
currentItemId = itemId;
var dlg = PaperDialogHelper.createDialog({
var dlg = paperDialogHelper.createDialog({
theme: options.theme
});
@ -154,16 +153,18 @@
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'imageuploader');
paperDialogHelper.open(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent);
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
});
});
}
xhr.send();
}
function onDialogClosed() {
@ -173,7 +174,7 @@
currentDeferred.resolveWith(null, [hasChanges]);
}
window.ImageUploader = {
return {
show: function (itemId, options) {
var deferred = DeferredBuilder.Deferred();
@ -181,12 +182,8 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
showEditor(itemId, options);
});
showEditor(itemId, options);
return deferred.promise();
}
};
})(jQuery, window, document);
});

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper', 'paper-dialog', 'paper-fab', 'paper-input'], function (paperDialogHelper) {
var currentItem;
var currentDeferred;
@ -67,9 +67,10 @@
type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
data: JSON.stringify(lookupInfo),
contentType: "application/json"
contentType: "application/json",
dataType: 'json'
}).done(function (results) {
}).then(function (results) {
Dashboard.hideLoadingMsg();
showIdentificationSearchResults(page, results);
@ -88,7 +89,6 @@
for (var i = 0, length = results.length; i < length; i++) {
var result = results[i];
html += getSearchResultHtml(result, i);
}
@ -213,18 +213,18 @@
data: JSON.stringify(currentSearchResult),
contentType: "application/json"
}).done(function () {
}).then(function () {
hasChanges = true;
Dashboard.hideLoadingMsg();
PaperDialogHelper.close(document.querySelector('.identifyDialog'));
paperDialogHelper.close(document.querySelector('.identifyDialog'));
}).fail(function () {
}, function () {
Dashboard.hideLoadingMsg();
PaperDialogHelper.close(document.querySelector('.identifyDialog'));
paperDialogHelper.close(document.querySelector('.identifyDialog'));
});
}
@ -236,7 +236,7 @@
function showIdentificationForm(page, item) {
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) {
var html = '';
@ -281,18 +281,17 @@
Dashboard.showLoadingMsg();
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/itemidentifier/itemidentifier.template.html', true);
type: 'GET',
url: 'components/itemidentifier/itemidentifier.template.html'
xhr.onload = function (e) {
}).done(function (template) {
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(function (item) {
var template = this.response;
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
currentItem = item;
var dlg = PaperDialogHelper.createDialog();
var dlg = paperDialogHelper.createDialog();
var html = '';
html += '<h2 class="dialogHeader">';
@ -310,14 +309,14 @@
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'itemidentifier');
paperDialogHelper.open(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent);
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
});
dlg.classList.add('identifyDialog');
@ -325,7 +324,9 @@
showIdentificationForm(dlg, item);
Dashboard.hideLoadingMsg();
});
});
}
xhr.send();
}
function onDialogClosed() {
@ -343,12 +344,8 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
showEditor(itemId);
});
showEditor(itemId);
return deferred.promise();
}
};
})(jQuery, window, document);
});

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-dialog', 'paper-input', 'paper-fab', 'paper-item-body', 'paper-icon-item'], function (paperDialogHelper) {
var currentDeferred;
var hasChanges;
@ -24,14 +24,14 @@
type = null;
}
ApiClient.addVirtualFolder(name, type, currentOptions.refresh, paths).done(function () {
ApiClient.addVirtualFolder(name, type, currentOptions.refresh, paths).then(function () {
hasChanges = true;
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
}).fail(function () {
}, function () {
Dashboard.showError(Globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
Dashboard.alert(Globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
return false;
@ -186,56 +186,53 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibrarycreator/medialibrarycreator.template.html', true);
HttpClient.send({
xhr.onload = function (e) {
type: 'GET',
url: 'components/medialibrarycreator/medialibrarycreator.template.html'
var template = this.response;
var dlg = paperDialogHelper.createDialog({
size: 'small',
theme: 'a',
}).done(function (template) {
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = Globalize.translate('ButtonAddMediaLibrary');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options.collectionTypeOptions);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'medialibrarycreator');
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
paths = [];
renderPaths(editorContent);
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = Globalize.translate('ButtonAddMediaLibrary');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options.collectionTypeOptions);
$(dlg).on('iron-overlay-closed', onDialogClosed);
paperDialogHelper.open(dlg);
$('.btnCloseDialog', dlg).on('click', function () {
paperDialogHelper.close(dlg);
});
paths = [];
renderPaths(editorContent);
}
xhr.send();
return deferred.promise();
};

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-fab', 'paper-item-body', 'paper-icon-item'], function (paperDialogHelper) {
var currentDeferred;
var hasChanges;
@ -10,14 +10,14 @@
var refreshAfterChange = currentOptions.refresh;
ApiClient.addMediaPath(virtualFolder.Name, path, refreshAfterChange).done(function () {
ApiClient.addMediaPath(virtualFolder.Name, path, refreshAfterChange).then(function () {
hasChanges = true;
refreshLibraryFromServer(page);
}).fail(function () {
}, function () {
Dashboard.showError(Globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
Dashboard.alert(Globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
}
@ -36,14 +36,14 @@
var refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).done(function () {
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function () {
hasChanges = true;
refreshLibraryFromServer($(button).parents('.editorContent')[0]);
}).fail(function () {
}, function () {
Dashboard.showError(Globalize.translate('DefaultErrorMessage'));
Dashboard.alert(Globalize.translate('DefaultErrorMessage'));
});
}
});
@ -70,7 +70,7 @@
function refreshLibraryFromServer(page) {
ApiClient.getVirtualFolders().done(function (result) {
ApiClient.getVirtualFolders().then(function (result) {
var library = result.filter(function (f) {
@ -140,53 +140,50 @@
currentDeferred = deferred;
hasChanges = false;
require(['components/paperdialoghelper'], function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/medialibraryeditor/medialibraryeditor.template.html', true);
HttpClient.send({
xhr.onload = function (e) {
type: 'GET',
url: 'components/medialibraryeditor/medialibraryeditor.template.html'
var template = this.response;
var dlg = paperDialogHelper.createDialog({
size: 'small',
theme: 'a',
}).done(function (template) {
var dlg = PaperDialogHelper.createDialog({
size: 'small',
theme: 'a',
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + options.library.Name + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options);
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'medialibraryeditor');
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
refreshLibraryFromServer(editorContent);
// In (at least) chrome this is causing the text field to not be editable
modal: false
});
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + options.library.Name + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, options);
$(dlg).on('iron-overlay-closed', onDialogClosed);
paperDialogHelper.open(dlg);
$('.btnCloseDialog', dlg).on('click', function () {
paperDialogHelper.close(dlg);
});
refreshLibraryFromServer(editorContent);
}
xhr.send();
return deferred.promise();
};

View file

@ -1,111 +1 @@
(function ($, document, window, FileReader, escape) {
var currentItem;
function getBaseRemoteOptions() {
var options = {};
options.itemId = currentItem.Id;
return options;
}
function reload(page, item) {
Dashboard.showLoadingMsg();
if (item) {
reloadItem(page, item);
}
else {
ApiClient.getItem(Dashboard.getCurrentUserId(), currentItem.Id).done(function (item) {
reloadItem(page, item);
});
}
}
function reloadItem(page, item) {
currentItem = item;
}
function initEditor(page) {
}
function showEditor(itemId) {
Dashboard.showLoadingMsg();
HttpClient.send({
type: 'GET',
url: 'components/metadataeditor/metadataeditor.template.html'
}).done(function (template) {
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(function (item) {
var dlg = document.createElement('paper-dialog');
dlg.setAttribute('with-backdrop', 'with-backdrop');
dlg.setAttribute('role', 'alertdialog');
// without this safari will scroll the background instead of the dialog contents
dlg.setAttribute('modal', 'modal');
// seeing max call stack size exceeded in the debugger with this
dlg.setAttribute('noAutoFocus', 'noAutoFocus');
dlg.entryAnimation = 'scale-up-animation';
dlg.exitAnimation = 'fade-out-animation';
dlg.classList.add('smoothScrollY');
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + Globalize.translate('ButtonEdit') + '</div>';
html += '</h2>';
html += '<div class="editorContent">';
html += Globalize.translateDocument(template);
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
initEditor(dlg);
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'metadataeditor');
var editorContent = dlg.querySelector('.editorContent');
reload(editorContent, item);
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
});
});
}
function onDialogClosed() {
$(this).remove();
Dashboard.hideLoadingMsg();
}
window.MetadataEditor = {
show: function (itemId) {
require(['components/paperdialoghelper'], function () {
Dashboard.importCss('css/metadataeditor.css');
showEditor(itemId);
});
}
};
})(jQuery, document, window, window.FileReader, escape);


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;
});

View file

@ -1,4 +1,4 @@
define([], function () {
define(['components/paperdialoghelper', 'paper-dialog', 'paper-input', 'paper-fab'], function (paperDialogHelper) {
var lastPlaylistId = '';
@ -6,7 +6,7 @@
var context = getParameterByName('context');
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
ApiClient.getItem(Dashboard.getCurrentUserId(), id).then(function (item) {
Dashboard.navigate(LibraryBrowser.getHref(item, context));
@ -46,13 +46,13 @@
url: url,
dataType: "json"
}).done(function (result) {
}).then(function (result) {
Dashboard.hideLoadingMsg();
var id = result.Id;
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
redirectToPlaylist(id);
});
}
@ -69,11 +69,11 @@
type: "POST",
url: url
}).done(function () {
}).then(function () {
Dashboard.hideLoadingMsg();
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
Dashboard.alert(Globalize.translate('MessageAddedToPlaylistSuccess'));
});
@ -106,7 +106,7 @@
SortBy: 'SortName'
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
ApiClient.getItems(Dashboard.getCurrentUserId(), options).then(function (result) {
var html = '';
@ -197,39 +197,36 @@
items = items || [];
require(['components/paperdialoghelper'], function () {
var dlg = paperDialogHelper.createDialog({
size: 'small'
});
var dlg = PaperDialogHelper.createDialog({
size: 'small'
});
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var html = '';
html += '<h2 class="dialogHeader">';
html += '<paper-fab icon="arrow-back" mini class="btnCloseDialog"></paper-fab>';
var title = Globalize.translate('HeaderAddToPlaylist');
var title = Globalize.translate('HeaderAddToPlaylist');
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + title + '</div>';
html += '</h2>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
html += '<div class="editorContent" style="max-width:800px;margin:auto;">';
html += getEditorHtml();
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.innerHTML = html;
document.body.appendChild(dlg);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
var editorContent = dlg.querySelector('.editorContent');
initEditor(editorContent, items);
$(dlg).on('iron-overlay-closed', onDialogClosed);
$(dlg).on('iron-overlay-closed', onDialogClosed);
paperDialogHelper.open(dlg);
PaperDialogHelper.openWithHash(dlg, 'playlisteditor');
$('.btnCloseDialog', dlg).on('click', function () {
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
});
paperDialogHelper.close(dlg);
});
};
}

View file

@ -0,0 +1,80 @@
define(function () {
var requireCss = {};
requireCss.normalize = function (name, normalize) {
if (name.substr(name.length - 4, 4) == '.css')
name = name.substr(0, name.length - 4);
return normalize(name);
}
var importedCss = [];
function isLoaded(url) {
return importedCss.indexOf(url) != -1;
}
function removeFromLoadHistory(url) {
url = url.toLowerCase();
importedCss = importedCss.filter(function (c) {
return url.indexOf(c.toLowerCase()) == -1;
});
}
requireCss.load = function (cssId, req, load, config) {
// Somehow if the url starts with /css, require will get all screwed up since this extension is also called css
cssId = cssId.replace('components/requirecss', 'css');
var url = cssId + '.css';
var packageName = '';
// TODO: handle any value before the #
if (url.indexOf('theme#') != -1) {
url = url.replace('theme#', '');
packageName = 'theme';
}
if (url.indexOf('http') != 0 && url.indexOf('file:') != 0) {
url = config.baseUrl + url;
}
if (!isLoaded(url)) {
importedCss.push(url);
var link = document.createElement('link');
if (packageName) {
link.setAttribute('data-package', packageName);
}
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.onload = load;
link.setAttribute('href', url + "?" + config.urlArgs);
document.head.appendChild(link);
} else {
load();
}
}
window.requireCss = {
unloadPackage: function (packageName) {
// Todo: unload css here
var stylesheets = document.head.querySelectorAll("link[data-package='" + packageName + "']");
for (var i = 0, length = stylesheets.length; i < length; i++) {
var stylesheet = stylesheets[i];
Logger.log('Unloading stylesheet: ' + stylesheet.href);
stylesheet.parentNode.removeChild(stylesheet);
removeFromLoadHistory(stylesheet.href);
}
}
};
return requireCss;
});

View file

@ -0,0 +1,46 @@
define(function () {
var cssAPI = {};
cssAPI.normalize = function (name, normalize) {
if (name.substr(name.length - 5, 5) == '.html')
name = name.substr(0, name.length - 5);
return normalize(name);
}
var importedFiles = [];
cssAPI.load = function (cssId, req, load, config) {
// Somehow if the url starts with /css, require will get all screwed up since this extension is also called css
cssId = cssId.replace('js/requirehtml', 'html');
var url = cssId + '.html';
if (url.indexOf('http') != 0 && url.indexOf('file:') != 0) {
url = config.baseUrl + url;
}
if (importedFiles.indexOf(url) == -1) {
importedFiles.push(url);
var link = document.createElement('link');
link.rel = 'import';
if (url.toLowerCase().indexOf('bower_') == -1) {
url = url + "?" + config.urlArgs;
}
link.onload = load;
link.href = url;
document.head.appendChild(link);
return;
}
load();
}
return cssAPI;
});

View file

@ -0,0 +1,78 @@
define(['thirdparty/social-share-kit-1.0.4/dist/js/social-share-kit.min', 'css!thirdparty/social-share-kit-1.0.4/dist/css/social-share-kit.css', 'fade-in-animation', 'fade-out-animation', 'paper-dialog'], function () {
function showMenu(options, successCallback, cancelCallback) {
var id = 'dlg' + new Date().getTime();
var html = '';
html += '<paper-dialog id="' + id + '" entry-animation="fade-in-animation" exit-animation="fade-out-animation" with-backdrop>';
html += '<h2>' + Globalize.translate('HeaderShare') + '</h2>';
html += '<div>';
html += '<div class="ssk-group ssk-round ssk-lg">';
// We can only do facebook if we can guarantee that the current page is available over the internet, since FB will try to probe it.
if (Dashboard.isConnectMode()) {
html += '<a href="" class="ssk ssk-facebook"></a>';
}
html += '<a href="" class="ssk ssk-twitter"></a><a href="" class="ssk ssk-google-plus"></a><a href="" class="ssk ssk-pinterest"></a><a href="" class="ssk ssk-tumblr"></a></div>';
html += '</div>';
html += '<div style="max-width:240px;">';
html += Globalize.translate('ButtonShareHelp');
html += '</div>';
html += '<div class="buttons">';
html += '<paper-button class="btnCancel" dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
html += '</div>';
html += '</paper-dialog>';
$(document.body).append(html);
var isShared = false;
setTimeout(function () {
var dlg = document.getElementById(id);
dlg.open();
var shareInfo = options.share;
SocialShareKit.init({
selector: '#' + id + ' .ssk',
url: shareInfo.Url,
title: shareInfo.Name,
text: shareInfo.Overview,
image: shareInfo.ImageUrl,
via: 'Emby'
});
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', function () {
$(this).remove();
if (isShared) {
successCallback(options);
} else {
cancelCallback(options);
}
});
// Has to be assigned a z-index after the call to .open()
$('.ssk', dlg).on('click', function () {
isShared = true;
dlg.close();
});
}, 100);
}
return {
showMenu: showMenu
};
});

View file

@ -1,4 +1,4 @@
(function ($, window, document) {
define(['components/paperdialoghelper', 'paper-fab', 'paper-item-body', 'paper-icon-item'], function (paperDialogHelper) {
var currentItem;
@ -11,7 +11,12 @@
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
$.get(ApiClient.getUrl(url)).done(function (result) {
ApiClient.ajax({
type: 'GET',
url: url
}).then(function (result) {
$('.subtitleContent', page).html(result);
@ -30,7 +35,7 @@
var url = 'Providers/Subtitles/Subtitles/' + id;
ApiClient.get(ApiClient.getUrl(url)).done(function (result) {
ApiClient.get(ApiClient.getUrl(url)).then(function (result) {
$('.subtitleContent', page).html(result);
@ -49,7 +54,7 @@
type: "POST",
url: ApiClient.getUrl(url)
}).done(function () {
}).then(function () {
Dashboard.alert(Globalize.translate('MessageDownloadQueued'));
});
@ -73,7 +78,7 @@
type: "DELETE",
url: ApiClient.getUrl(url)
}).done(function () {
}).then(function () {
reload(page, itemId);
});
@ -184,7 +189,7 @@
}
else {
Dashboard.getCurrentUser().done(function (user) {
Dashboard.getCurrentUser().then(function (user) {
var lang = user.Configuration.SubtitleLanguagePreference;
@ -286,7 +291,7 @@
var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
ApiClient.getJSON(url).done(function (results) {
ApiClient.getJSON(url).then(function (results) {
renderSearchResults(page, results);
});
@ -305,7 +310,7 @@
}
if (typeof itemId == 'string') {
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(onGetItem);
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(onGetItem);
}
else {
onGetItem(itemId);
@ -326,16 +331,15 @@
Dashboard.showLoadingMsg();
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/subtitleeditor/subtitleeditor.template.html', true);
type: 'GET',
url: 'components/subtitleeditor/subtitleeditor.template.html'
xhr.onload = function (e) {
}).done(function (template) {
var template = this.response;
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(function (item) {
var dlg = PaperDialogHelper.createDialog();
var dlg = paperDialogHelper.createDialog();
var html = '';
html += '<h2 class="dialogHeader">';
@ -355,22 +359,24 @@
// Has to be assigned a z-index after the call to .open()
$(dlg).on('iron-overlay-closed', onDialogClosed);
PaperDialogHelper.openWithHash(dlg, 'subtitleeditor');
paperDialogHelper.open(dlg);
var editorContent = dlg.querySelector('.editorContent');
reload(editorContent, item);
ApiClient.getCultures().done(function (languages) {
ApiClient.getCultures().then(function (languages) {
fillLanguages(editorContent, languages);
});
$('.btnCloseDialog', dlg).on('click', function () {
PaperDialogHelper.close(dlg);
paperDialogHelper.close(dlg);
});
});
});
}
xhr.send();
}
function onDialogClosed() {
@ -379,14 +385,7 @@
Dashboard.hideLoadingMsg();
}
window.SubtitleEditor = {
show: function (itemId) {
require(['components/paperdialoghelper'], function () {
showEditor(itemId);
});
}
return {
show: showEditor
};
})(jQuery, window, document);
});

View file

@ -0,0 +1,35 @@
(function () {
function onPageShow() {
if (!browserInfo.android) {
return;
}
var msg;
var settingsKey = "betatester";
var expectedValue = new Date().toDateString() + "6";
if (appStorage.getItem(settingsKey) == expectedValue) {
return;
}
msg = 'At your convenience, please take a moment to visit the Emby Community and leave testing feedback related to this beta build. Your feedback will help us improve the release before it goes public. Thank you for being a part of the Emby beta test team.';
msg += "<br/><br/>";
msg += '<a href="http://emby.media/community/index.php?/topic/28144-android-mobile-25" target="_blank">Visit Emby community</a>';
Dashboard.alert({
message: msg,
title: 'Hello Emby Beta Tester!',
callback: function () {
appStorage.setItem(settingsKey, expectedValue);
}
});
}
pageClassOn('pageshow', "homePage", onPageShow);
})();

View file

@ -50,7 +50,7 @@
function reloadGuide(page) {
Dashboard.showModalLoadingMsg();
Dashboard.showLoadingMsg();
channelQuery.UserId = Dashboard.getCurrentUserId();
@ -67,7 +67,7 @@
var nextDay = new Date(date.getTime() + msPerDay - 2000);
Logger.log(nextDay);
channelsPromise.done(function (channelsResult) {
channelsPromise.then(function (channelsResult) {
ApiClient.getLiveTvPrograms({
UserId: Dashboard.getCurrentUserId(),
@ -80,11 +80,11 @@
EnableImages: false,
SortBy: "StartDate"
}).done(function (programsResult) {
}).then(function (programsResult) {
renderGuide(page, date, channelsResult.Items, programsResult.Items);
Dashboard.hideModalLoadingMsg();
Dashboard.hideLoadingMsg();
LibraryBrowser.setLastRefreshed(page);
@ -305,28 +305,28 @@
html += '<div class="channelHeaderCellContainer">';
html += '<div class="channelHeaderCell">';
html += '<a class="channelHeaderCellInner" href="itemdetails.html?id=' + channel.Id + '">';
html += '<a class="channelHeaderCell" href="itemdetails.html?id=' + channel.Id + '">';
var hasChannelImage = channel.ImageTags.Primary;
var cssClass = hasChannelImage ? 'guideChannelInfo guideChannelInfoWithImage' : 'guideChannelInfo';
html += '<div class="' + cssClass + '">' + channel.Name + '<br/>' + channel.Number + '</div>';
html += '<div class="' + cssClass + '">' + channel.Number + '</div>';
if (hasChannelImage) {
var url = ApiClient.getScaledImageUrl(channel.Id, {
maxHeight: 35,
maxWidth: 60,
maxHeight: 44,
maxWidth: 70,
tag: channel.ImageTags.Primary,
type: "Primary"
});
html += '<div class="guideChannelImage lazy" data-src="' + url + '"></div>';
} else {
html += '<div class="guideChannelName">' + channel.Name + '</div>';
}
html += '</a>';
html += '</div>';
html += '</div>';
}
@ -424,7 +424,7 @@
channelLimit = limit;
ApiClient.getLiveTvGuideInfo().done(function (guideInfo) {
ApiClient.getLiveTvGuideInfo().then(function (guideInfo) {
setDateRange(page, guideInfo);
});
@ -434,13 +434,13 @@
$('.guideRequiresUnlock', page).hide();
RegistrationServices.validateFeature('livetv').done(function () {
Dashboard.showModalLoadingMsg();
RegistrationServices.validateFeature('livetv').then(function () {
Dashboard.showLoadingMsg();
reloadPageAfterValidation(page, 1000);
}).fail(function () {
}, function () {
Dashboard.showModalLoadingMsg();
Dashboard.showLoadingMsg();
var limit = 5;
$('.guideRequiresUnlock', page).show();
@ -469,13 +469,12 @@
});
}
HttpClient.send({
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/tvguide/tvguide.template.html', true);
type: 'GET',
url: 'components/tvguide/tvguide.template.html'
}).done(function (template) {
xhr.onload = function (e) {
var template = this.response;
var tabContent = options.element;
tabContent.innerHTML = Globalize.translateDocument(template);
@ -484,20 +483,20 @@
onProgramGridScroll(tabContent, this);
});
if ($.browser.mobile) {
if (browserInfo.mobile) {
tabContent.querySelector('.tvGuide').classList.add('mobileGuide');
} else {
tabContent.querySelector('.tvGuide').classList.remove('mobileGuide');
Events.on(tabContent.querySelector('.timeslotHeaders'), 'scroll', function () {
tabContent.querySelector('.timeslotHeaders').addEventListener('scroll', function (e) {
onTimeslotHeadersScroll(tabContent, this);
onTimeslotHeadersScroll(tabContent, e.target);
});
}
if (AppInfo.enableHeadRoom && options.enableHeadRoom) {
requirejs(["thirdparty/headroom"], function () {
requirejs(["headroom"], function () {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(tabContent.querySelector('.tvGuideHeader'));
@ -517,6 +516,8 @@
});
self.refresh();
});
}
xhr.send();
};
});

View file

@ -1,4 +1,4 @@
define([], function () {
define(['paper-checkbox', 'paper-input'], function () {
return function (page, providerId, options) {
@ -10,7 +10,7 @@
Dashboard.showLoadingMsg();
ApiClient.getNamedConfiguration("livetv").done(function (config) {
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id == providerId;
@ -35,7 +35,7 @@
function setCountry(info) {
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
var countryList = [];
var i, length;
@ -72,7 +72,7 @@
$(page.querySelector('.txtZipCode')).trigger('change');
}).fail(function () {
}, function () {
Dashboard.alert({
message: Globalize.translate('ErrorGettingTvLineups')
@ -106,15 +106,16 @@
ValidateLogin: true
}),
data: JSON.stringify(info),
contentType: "application/json"
contentType: "application/json",
dataType: 'json'
}).done(function (result) {
}).then(function (result) {
Dashboard.processServerConfigurationUpdateResult();
providerId = result.Id;
reload();
}).fail(function () {
}, function () {
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
@ -137,7 +138,7 @@
var id = providerId;
ApiClient.getNamedConfiguration("livetv").done(function (config) {
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id == id;
@ -155,7 +156,7 @@
data: JSON.stringify(info),
contentType: "application/json"
}).done(function (result) {
}).then(function (result) {
Dashboard.hideLoadingMsg();
if (options.showConfirmation !== false) {
@ -163,7 +164,7 @@
}
$(self).trigger('submitted');
}).fail(function () {
}, function () {
Dashboard.hideLoadingMsg();
Dashboard.alert({
message: Globalize.translate('ErrorAddingListingsToSchedulesDirect')
@ -191,7 +192,7 @@
}),
dataType: 'json'
}).done(function (result) {
}).then(function (result) {
$('#selectListing', page).html(result.map(function (o) {
@ -205,7 +206,7 @@
Dashboard.hideModalLoadingMsg();
}).fail(function (result) {
}, function (result) {
Dashboard.alert({
message: Globalize.translate('ErrorGettingTvLineups')