diff --git a/plugins b/plugins index 56e0b405..c7969fd1 160000 --- a/plugins +++ b/plugins @@ -1 +1 @@ -Subproject commit 56e0b405985bdc843ec42be80f82a213e2d21198 +Subproject commit c7969fd157eeb53e9d369bc41a21b79d0f661185 diff --git a/resources/assets/src/js/common/notify.js b/resources/assets/src/js/common/notify.js index 4d7785c7..bbc1eb5c 100644 --- a/resources/assets/src/js/common/notify.js +++ b/resources/assets/src/js/common/notify.js @@ -29,9 +29,20 @@ function showAjaxError(json) { showModal(json.responseText.replace(/\n/g, '
'), 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 = ` `; - $(dom).modal(options); + $(dom).on('hidden.bs.modal', function () { + destroyOnClose && $(this).remove(); + }).modal(options); } if (typeof require !== 'undefined' && typeof module !== 'undefined') {