jellyfin-web/dashboard-ui/scripts/actionsheet.js

68 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-06-18 21:23:55 -07:00
(function () {
2015-06-19 09:36:51 -07:00
function onClosed() {
$(this).remove();
}
2015-06-18 21:23:55 -07:00
function show(options) {
2015-06-19 09:36:51 -07:00
require(['paperbuttonstyle'], function() {
// items
// positionTo
// showCancel
// title
var id = 'dlg' + new Date().getTime();
var html = '';
2015-06-19 11:34:21 -07:00
html += '<paper-dialog id="' + id + '" entry-animation="scale-up-animation" exit-animation="fade-out-animation" with-backdrop>';
2015-06-19 09:36:51 -07:00
if (options.title) {
html += '<h2>';
html += options.title;
html += '</h2>';
}
html += '<paper-dialog-scrollable>';
for (var i = 0, length = options.items.length; i < length; i++) {
var option = options.items[i];
2015-06-19 11:34:21 -07:00
html += '<paper-button class="block blue ripple btnOption" data-id="' + option.id + '" style="margin:0;">';
//html += '<iron-icon icon="close"></iron-icon>';
html += '<span>' + option.name + '</span>';
html += '</paper-button>';
2015-06-19 09:36:51 -07:00
}
html += '</paper-dialog-scrollable>';
2015-06-18 21:23:55 -07:00
2015-06-19 09:36:51 -07:00
if (options.showCancel) {
html += '<div class="buttons">';
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
html += '</div>';
}
html += '</paper-dialog>';
$(html).appendTo(document.body);
setTimeout(function () {
var dlg = document.getElementById(id);
dlg.open();
// Has to be assigned a z-index after the call to .open()
$(dlg).css('z-index', '999999').on('iron-overlay-closed', onClosed);
$('.btnOption', dlg).on('click', function () {
if (options.callback) {
options.callback(this.getAttribute('data-id'));
}
dlg.close();
});
}, 100);
});
2015-06-18 21:23:55 -07:00
}
2015-06-19 09:36:51 -07:00
window.ActionSheetElement = {
2015-06-18 21:23:55 -07:00
show: show
};
})();