]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
disable infobox overlay
[tt-rss.git] / functions.js
index d5ac2c087f79bf55f5ff8897207b13aefbdb6f22..817946c397737ca2153b90f5cd1b2ce823352258 100644 (file)
@@ -1,5 +1,10 @@
 var hotkeys_enabled = true;
 
+function browser_has_opacity() {
+       return navigator.userAgent.match("Gecko") != null || 
+               navigator.userAgent.match("Opera") != null;
+}
+
 function exception_error(location, e) {
        var msg;
 
@@ -28,7 +33,6 @@ function xmlhttp_ready(obj) {
        return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
 }
 
-
 function notify_callback() {
        var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {
@@ -73,10 +77,31 @@ function delay(gap) {
        }
 }
 
-function p_notify(msg) {
+var notify_hide_timerid = false;
+var notify_last_doc = false;
+
+function hide_notify() {
+       if (notify_last_doc) {
+               var n = notify_last_doc.getElementById("notify");               
+               if (browser_has_opacity()) {
+                       if (notify_opacity >= 0) {
+                               notify_opacity = notify_opacity - 0.2;
+                               n.style.opacity = notify_opacity;
+                               notify_hide_timerid = window.setTimeout("hide_notify()", 20);   
+                       } else {
+                               n.style.display = "none";
+                               n.style.opacity = 1;
+                       }
+               } else {
+                       n.style.display = "none";
+               }
+       }
+}
+
+function notify_real(msg, doc, no_hide, is_err) {
 
-       var n = parent.document.getElementById("notify");
-       var nb = parent.document.getElementById("notify_body");
+       var n = doc.getElementById("notify");
+       var nb = doc.getElementById("notify_body");
 
        if (!n || !nb) return;
 
@@ -85,25 +110,37 @@ function p_notify(msg) {
        } else {
                n.style.display = "block";
        }
-       
-       nb.innerHTML = msg;
-}
 
-function notify(msg) {
+       if (is_err) {
+               n.style.backgroundColor = "#ffcccc";
+               n.style.color = "black";
+               n.style.borderColor = "#ff0000";
+       } else {
+               n.style.backgroundColor = "#fff7d5";
+               n.style.borderColor = "#d7c47a";
+               n.style.color = "black";
+       }
+
+       nb.innerHTML = msg;
 
-       var n = document.getElementById("notify");
-       var nb = document.getElementById("notify_body");
+       if (notify_hide_timerid) {
+               window.clearTimeout(notify_hide_timerid);
+       }
 
-       if (!n || !nb) return;
+       notify_last_doc = doc;
+       notify_opacity = 1;
 
-       if (msg == "") {
-               n.style.display = "none";
-       } else {
-               n.style.display = "block";
+       if (!no_hide) {
+               notify_hide_timerid = window.setTimeout("hide_notify()", 3000);
        }
+}
 
-       nb.innerHTML = msg;
+function p_notify(msg, no_hide, is_err) {
+       notify_real(msg, parent.document, no_hide, is_err);
+}
 
+function notify(msg, no_hide, is_err) {
+       notify_real(msg, document, no_hide, is_err);
 }
 
 function printLockingError() {
@@ -947,6 +984,7 @@ function displayDlg(id, param) {
        xmlhttp.send(null);
 
        disableHotkeys();
+
 }
 
 function infobox_submit_callback() {
@@ -1009,4 +1047,14 @@ function qaddFilter() {
 
 }
 
+function toggleSubmitNotEmpty(e, submit_id) {
+       try {
+               document.getElementById(submit_id).disabled = (e.value == "")
+       } catch (e) {
+               exception_error("toggleSubmitNotEmpty", e);
+       }
+}
 
+function isValidURL(s) {
+       return s.match("http://") != null || s.match("https://") != null;
+}