From 6f45de10d7251f4b3da8e28575c535f911c10ac6 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 4 Oct 2012 15:05:17 +0300 Subject: support multi-line error messages in exceptions --- install/ui/ipa.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'install/ui/ipa.js') diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 45195bc4..e20d3c08 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -1419,6 +1419,25 @@ IPA.error_dialog = function(spec) { that.visible_buttons = spec.visible_buttons || ['retry', 'cancel']; }; + that.beautify_message = function(container, message) { + var lines = message.split(/\n/g); + var line_span; + for(var i=0; i', { + 'class': 'error-message-hinted', + text: lines[i].substr(1) + }).appendTo(container); + } else { + line_span = $('

', { + text: lines[i] + }).appendTo(container); + } + } + }; + that.create = function() { if (that.error_thrown.url) { $('

', { @@ -1426,9 +1445,9 @@ IPA.error_dialog = function(spec) { }).appendTo(that.container); } - $('

', { - html: that.error_thrown.message - }).appendTo(that.container); + var error_message = $('

', {}); + that.beautify_message(error_message, that.error_thrown.message); + error_message.appendTo(that.container); if(that.errors && that.errors.length > 0) { //render errors @@ -1457,9 +1476,9 @@ IPA.error_dialog = function(spec) { for(var i=0; i < that.errors.length; i++) { var error = that.errors[i]; if(error.message) { - var error_div = $('
  • ', { - text: error.message - }).appendTo(errors_container); + var error_div = $('
  • ', {}); + that.beautify_message(error_div, error.message); + error_div.appendTo(errors_container); } } -- cgit