]> dev.renevier.net Git - syj.git/blobdiff - public/js/utils.js
fixes incompatibility between div messenger and closebtn
[syj.git] / public / js / utils.js
index f5817d491a2087f3198089e5dad1d0d77bc87a18..d59a112736ce89d77e79b00c78b9de699c3f7e4c 100644 (file)
@@ -21,6 +21,10 @@ var CloseBtn = Class.create({
         btn = new Element("input", { type: "image", src: imgsrc, alt: "X"}).setStyle(style);
         elt.insert({top: btn});
         btn.observe("click", function(evt) {
+            evt.stop();
+            if (typeof options.callback === "function") {
+                options.callback.call(elt);
+            }
             elt.hide();
         });
     }
@@ -115,12 +119,12 @@ Ajax.TimedRequest = Class.create(Ajax.Request, {
     },
 
     request: function($super, url) {
-        this.timeout = (function() {
+        this.timeout = function() {
             if (this.options.onFailure) {
                 this.options.onFailure(null);
             }
             this.abort();
-        }).bind(this).delay(this.delay);
+        }.bind(this).delay(this.delay);
         $super(url);
     }
 });
@@ -186,7 +190,7 @@ Element.addMethods('form', {
         });
     },
 
-    focus: function(form) {
+    setfocus: function(form) {
         var tofocus, error;
 
         tofocus = null;
@@ -307,9 +311,13 @@ Element.addMethods('div', {
 
     addMessage: function(div, message) {
         var node = (div.ownerDocument || document).createTextNode(message);
-        if (!div.empty()) {
+
+        if ($A(div.childNodes).filter(function(node) {
+                return (node.nodeType === 3 || node.tagName.toLowerCase() === 'br');
+             }).length) {
             div.insert(new Element('br'));
         }
+
         div.appendChild(node);
         return div.show();
     },