Convert error dialog to new Popup class
authorJoey Schulze <joey@infodrom.org>
Mon, 4 Jun 2018 19:28:43 +0000 (21:28 +0200)
committerJoey Schulze <joey@infodrom.org>
Sat, 6 Oct 2018 17:30:26 +0000 (19:30 +0200)
src/infodrom.css
src/infodrom.js

index 0404a1e..ad15cbe 100644 (file)
@@ -159,15 +159,18 @@ div.popup {
   position: absolute;
 }
 div.popup_title {
+  top: 0px;
   width: 100%;
   background: #b0e2ff;
   margin-top: -1em;
   margin-bottom: 0px;
   font-weight: bold;
-  padding-bottom: 1em;
+  padding-top: 0px;
+  padding-bottom: 1.35ex;
   border-bottom: 1px solid #777;
 }
 div.popup_title p {
+  padding-left: 3px;
   padding-bottom: 0px;
   margin-bottom: -0.65em;
   cursor: move;
@@ -187,6 +190,21 @@ div.popup label {
   margin-top: 2px;
   display: block;
 }
+div.popup#errorwindow div.popup_title {
+  background: #ffa54f;
+  background: #ff3030;
+}
+div.popup#errorwindow div.popup_title p {
+  color: white;
+}
+div.popup#errorwindow div#errorbody {
+  padding: 5px;
+  font-weight: bold;
+  font-size: 110%;
+}
+div.popup#errorwindow div.popup_body {
+  background: #ffe4c4;
+}
 
 /*
  * Calendar
@@ -205,22 +223,6 @@ div#message_div {
     font-size: 120%;
     padding: 5px;
 }
-div#error_div {
-    background: white;
-    color: black;
-    border: 2px solid red;
-}
-div#error_div div {
-    font-size: 120%;
-    font-weight: bold;
-    padding: 5px;
-}
-div#error_div p {
-    text-align: right;
-    padding: 2px;
-    margin: 0;
-    border-bottom: 1px solid #CCC;
-}
 
 .autocomplete-suggestions {
     background: white;
index e76b2ae..1190b40 100644 (file)
@@ -22,30 +22,22 @@ function hide_message(text)
     $('#message_div').hide();
 }
 
+var errorwindow = false;
 function show_error(text, timeout)
 {
-    var div = $('#error_div');
-    if (!div.length) {
-       div = $('<div>');
-       div.attr('id', 'error_div').css('z-index','1000');
-       div.hide();
-       div.append($('<p ><img src="/pix/close.gif" title="close" onclick="return hide_error()"/></p>'));
-       div.append($('<div />'));
-       $(document.body).append(div);
+    if (!errorwindow) {
+       errorwindow = new Popup('Fehler', '500px', false, '<div id="errorbody"></div>');
+       errorwindow.setId('errorwindow');
+       $('#errorwindow').css('z-index','1000');
+       errorwindow.centerPopup();
+    } else {
+       errorwindow.openPopup();
     }
 
-    div.find('div').html(text);
-    div.center();
-    div.show();
+    $('#errorbody').html(text);
 
     if (typeof timeout != 'undefined')
-       window.setTimeout(hide_error,timeout*1000);
-}
-
-function hide_error(text)
-{
-    $('#error_div').hide();
-    return false;
+       window.setTimeout(function(){errorwindow.closePopup()},timeout*1000);
 }
 
 function editable_callback(data)
@@ -179,6 +171,11 @@ Popup.prototype = {
        this.popup.hide();
     },
 
+    setId: function(name)
+    {
+       this.popup.attr('id', name);
+    },
+
     setTitle: function(title)
     {
        this.popup.find('div.popup_title p.popup_title').html(title);