mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-30 14:09:58 +08:00
Add option destroyOnClose for showModal
This commit is contained in:
parent
231a91e367
commit
52281dd25c
2
plugins
2
plugins
@ -1 +1 @@
|
||||
Subproject commit 56e0b405985bdc843ec42be80f82a213e2d21198
|
||||
Subproject commit c7969fd157eeb53e9d369bc41a21b79d0f661185
|
@ -29,9 +29,20 @@ function showAjaxError(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), trans('general.fatalError'), 'danger');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a bootstrap modal.
|
||||
*
|
||||
* @param {string} msg Modal content
|
||||
* @param {string} title Modal title
|
||||
* @param {string} type Modal type, default|info|success|warning|error
|
||||
* @param {object} options All $.fn.modal options, plus { btnText, callback, destroyOnClose }
|
||||
* @return {void}
|
||||
*/
|
||||
function showModal(msg, title = 'Message', type = 'default', options = {}) {
|
||||
let btnType = (type != 'default') ? 'btn-outline' : 'btn-primary';
|
||||
let btnText = options.btnText || 'OK';
|
||||
let onClick = (options.callback === undefined) ? 'data-dismiss="modal"' : `onclick="${options.callback}"`;
|
||||
let destroyOnClose = (options.destroyOnClose === false) ? false : true;
|
||||
|
||||
let dom = `
|
||||
<div class="modal modal-${type} fade in">
|
||||
@ -47,13 +58,15 @@ function showModal(msg, title = 'Message', type = 'default', options = {}) {
|
||||
<p>${msg}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" ${onClick} class="btn ${btnType}">OK</button>
|
||||
<button type="button" ${onClick} class="btn ${btnType}">${btnText}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$(dom).modal(options);
|
||||
$(dom).on('hidden.bs.modal', function () {
|
||||
destroyOnClose && $(this).remove();
|
||||
}).modal(options);
|
||||
}
|
||||
|
||||
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
|
||||
|
Loading…
Reference in New Issue
Block a user