update components
This commit is contained in:
parent
a694661cc1
commit
9ff21cf7b8
9 changed files with 174 additions and 126 deletions
|
@ -1,116 +1,4 @@
|
|||
define(['layoutManager', 'globalize'], function (layoutManager, globalize) {
|
||||
|
||||
function showTvConfirm(options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['actionsheet'], function (actionSheet) {
|
||||
|
||||
var items = [];
|
||||
|
||||
items.push({
|
||||
name: globalize.translate('sharedcomponents#ButtonOk'),
|
||||
id: 'ok'
|
||||
});
|
||||
|
||||
items.push({
|
||||
name: globalize.translate('sharedcomponents#ButtonCancel'),
|
||||
id: 'cancel'
|
||||
});
|
||||
|
||||
actionSheet.show({
|
||||
|
||||
title: options.text,
|
||||
items: items
|
||||
|
||||
}).then(function (id) {
|
||||
|
||||
switch (id) {
|
||||
|
||||
case 'ok':
|
||||
resolve();
|
||||
break;
|
||||
default:
|
||||
reject();
|
||||
break;
|
||||
}
|
||||
|
||||
}, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showConfirmInternal(options, dialogHelper, resolve, reject) {
|
||||
|
||||
var dialogOptions = {
|
||||
removeOnClose: true
|
||||
};
|
||||
|
||||
var backButton = false;
|
||||
|
||||
if (layoutManager.tv) {
|
||||
dialogOptions.size = 'fullscreen';
|
||||
backButton = true;
|
||||
dialogOptions.autoFocus = true;
|
||||
} else {
|
||||
|
||||
dialogOptions.modal = false;
|
||||
dialogOptions.entryAnimationDuration = 160;
|
||||
dialogOptions.exitAnimationDuration = 160;
|
||||
dialogOptions.autoFocus = false;
|
||||
}
|
||||
|
||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||
var html = '';
|
||||
|
||||
if (options.title) {
|
||||
html += '<h2>' + options.title + '</h2>';
|
||||
}
|
||||
|
||||
var text = options.html || options.text;
|
||||
|
||||
if (text) {
|
||||
html += '<div>' + text + '</div>';
|
||||
}
|
||||
|
||||
html += '<div class="buttons">';
|
||||
|
||||
html += '<button is="emby-button" type="button" class="btnConfirm" autofocus>' + globalize.translate('sharedcomponents#ButtonOk') + '</button>';
|
||||
|
||||
html += '<button is="emby-button" type="button" class="btnCancel">' + globalize.translate('sharedcomponents#ButtonCancel') + '</button>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
dlg.innerHTML = html;
|
||||
document.body.appendChild(dlg);
|
||||
|
||||
var confirmed = false;
|
||||
dlg.querySelector('.btnConfirm').addEventListener('click', function () {
|
||||
confirmed = true;
|
||||
dialogHelper.close(dlg);
|
||||
});
|
||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||
confirmed = false;
|
||||
dialogHelper.close(dlg);
|
||||
});
|
||||
|
||||
dialogHelper.open(dlg).then(function () {
|
||||
|
||||
if (confirmed) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showConfirm(options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['dialogHelper', 'emby-button'], function (dialogHelper) {
|
||||
showConfirmInternal(options, dialogHelper, resolve, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
define(['dialog', 'globalize'], function (dialog, globalize) {
|
||||
|
||||
return function (text, title) {
|
||||
|
||||
|
@ -124,10 +12,26 @@ define(['layoutManager', 'globalize'], function (layoutManager, globalize) {
|
|||
options = text;
|
||||
}
|
||||
|
||||
if (layoutManager.tv) {
|
||||
return showTvConfirm(options);
|
||||
}
|
||||
var items = [];
|
||||
|
||||
return showConfirm(options);
|
||||
items.push({
|
||||
name: globalize.translate('sharedcomponents#ButtonOk'),
|
||||
id: 'ok'
|
||||
});
|
||||
|
||||
items.push({
|
||||
name: globalize.translate('sharedcomponents#ButtonCancel'),
|
||||
id: 'cancel'
|
||||
});
|
||||
|
||||
options.buttons = items;
|
||||
|
||||
return dialog(options).then(function (result) {
|
||||
if (result == 'ok') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return Promise.reject();
|
||||
});
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue