From eab4cc2e577862033c59fbf048e3c4d32aa2f05c Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 16 May 2014 15:21:33 +0200 Subject: [PATCH] OO-763: warn and error message boostrapify --- .../commons/fullWebApp/_content/guimsg.html | 2 +- src/main/webapp/static/js/functions.js | 32 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/olat/core/commons/fullWebApp/_content/guimsg.html b/src/main/java/org/olat/core/commons/fullWebApp/_content/guimsg.html index 611103e7611..710cd728e5a 100644 --- a/src/main/java/org/olat/core/commons/fullWebApp/_content/guimsg.html +++ b/src/main/java/org/olat/core/commons/fullWebApp/_content/guimsg.html @@ -14,7 +14,7 @@ var dialog = showMessageBox("warn", "$r.translate("warn.header")", "$r.get("guiMessage").renderWarn()"); setTimeout(function(){ try { - jQuery(dialog).dialog('destroy').remove(); + jQuery(dialog).modal('hide'); } catch(e) { //possible if the user has closed the window } diff --git a/src/main/webapp/static/js/functions.js b/src/main/webapp/static/js/functions.js index 65c7e619197..86e3b206d68 100644 --- a/src/main/webapp/static/js/functions.js +++ b/src/main/webapp/static/js/functions.js @@ -1121,32 +1121,28 @@ function showInfoBox(title, content){ * The last parameter buttonCallback is optional. if a callback js * function is given it will be execute when the user clicks ok or closes the message box */ -function showMessageBox(type, title, message, buttonCallback){ +function showMessageBox(type, title, message, buttonCallback) { if(type == 'info'){ showInfoBox(title, message); return null; } else { - var prefix; + var content = '<div id="myFunctionalModal" class="modal fade" role="dialog"><div class="modal-dialog"><div class="modal-content">'; + content += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; + content += '<h4 class="modal-title">' + title + '</h4></div>'; + content += '<div class="modal-body alert '; if("warn" == type) { - prefix = '<div><div class="alert alert-warning">'; + content += 'alert-warning'; } else if("error" == type) { - prefix = '<div><div class="alert alert-danger">'; + content += 'alert-danger'; } else { - prefix = '<div><div class="alert alert-info">'; + content += 'alert-info'; } - return jQuery(prefix + '<p>' + message + '</p></div></div>').dialog({ - modal: true, - title: title, - resizable:false, - close: function(event, ui) { - try { - jQuery(this).dialog('destroy').remove() - } catch(e) { - //possible if the user has closed the window - } - } - }).dialog('open').dialog("widget").css('z-index', 11000); - + content += '"><p>' + message + '</p></div></div></div></div>'; + jQuery('#myFunctionalModal').remove(); + jQuery('body').append(content); + return jQuery('#myFunctionalModal').modal('show').on('hidden.bs.modal', function (e) { + jQuery('#myFunctionalModal').remove(); + }); } } -- GitLab