1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/alert/alert.js

88 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-03-23 15:03:17 -04:00
define(['dialogHelper', 'layoutManager', 'dialogText', 'html!./../prompt/icons.html', 'css!./../prompt/style.css', 'paper-button', 'paper-input'], function (dialogHelper, layoutManager, dialogText) {
2016-02-26 15:29:27 -05:00
return function (options) {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
var dialogOptions = {
removeOnClose: true
};
var backButton = false;
var raisedButtons = false;
2016-04-19 22:28:51 -04:00
var isFullscreen = false;
2016-02-26 15:29:27 -05:00
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
backButton = true;
raisedButtons = true;
2016-04-19 22:28:51 -04:00
isFullscreen = true;
2016-02-26 15:29:27 -05:00
} else {
dialogOptions.modal = false;
dialogOptions.entryAnimationDuration = 160;
dialogOptions.exitAnimationDuration = 200;
}
2016-03-23 15:03:17 -04:00
var dlg = dialogHelper.createDialog(dialogOptions);
2016-02-26 15:29:27 -05:00
dlg.classList.add('promptDialog');
var html = '';
html += '<div class="promptDialogContent">';
if (backButton) {
html += '<paper-icon-button tabindex="-1" icon="dialog:arrow-back" class="btnPromptExit"></paper-icon-button>';
}
if (options.title) {
html += '<h2>';
html += options.title;
html += '</h2>';
2016-04-19 22:28:51 -04:00
} else if (!isFullscreen) {
// Add a little space so it's not hugging the border
html += '<br/>';
2016-02-26 15:29:27 -05:00
}
2016-04-09 22:27:09 -04:00
var text = options.html || options.text;
if (text) {
2016-02-26 15:29:27 -05:00
if (options.title) {
html += '<p style="margin-top:2em;">';
} else {
html += '<p>';
}
2016-04-09 22:27:09 -04:00
html += text;
2016-02-26 15:29:27 -05:00
html += '</p>';
}
var buttonText = options.type == 'error' ? 'Ok' : 'GotIt';
if (raisedButtons) {
html += '<paper-button raised class="btnSubmit"><iron-icon icon="dialog:check"></iron-icon><span>' + dialogText.get(buttonText) + '</span></paper-button>';
} else {
2016-04-18 01:58:08 -04:00
html += '<div class="buttons" style="text-align:right;">';
2016-02-26 15:29:27 -05:00
html += '<paper-button class="btnSubmit">' + dialogText.get(buttonText) + '</paper-button>';
html += '</div>';
}
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.querySelector('.btnSubmit').addEventListener('click', function (e) {
2016-03-23 15:03:17 -04:00
dialogHelper.close(dlg);
2016-02-26 15:29:27 -05:00
});
2016-03-23 15:03:17 -04:00
return dialogHelper.open(dlg);
2016-02-26 15:29:27 -05:00
};
});