From e868ca09589f6120a6f461a29cf22b9d078b0251 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sat, 11 May 2013 08:51:03 +0200 Subject: [PATCH] Make sure the event is for us before doing anything --- modoboa/static/js/global.js | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/modoboa/static/js/global.js b/modoboa/static/js/global.js index 707ef4504..b8d59c7bd 100644 --- a/modoboa/static/js/global.js +++ b/modoboa/static/js/global.js @@ -38,22 +38,31 @@ function modalbox(e, css, defhref, defcb, defclosecb) { } return; } - var $div = $('') - .one('shown', function() { - $(".help").popover({ - container: "#modalbox" - }).click(function(e) {e.preventDefault();}); - if (modalcb != undefined) { - if (typeof modalcb === "function") modalcb(); else eval(modalcb + '()'); - } - }) - .on('hidden', function() { - $("#modalbox").remove(); - if (closecb != undefined) { - if (typeof closecb === "function") closecb(); else eval(closecb + '()'); - } - }) - .modal(); + var $div = $('
', { + id: "modalbox", 'class': "modal", html: data + }); + + $div.modal({show: false}); + $div.one('shown', function() { + $(".help").popover({ + container: "#modalbox" + }).click(function(e) {e.preventDefault();}); + if (modalcb != undefined) { + if (typeof modalcb === "function") modalcb(); else eval(modalcb + '()'); + } + }) + .on('hidden', function(e) { + var $target = $(e.target); + + if (!$target.is($(this))) { + return; + } + $("#modalbox").remove(); + if (closecb != undefined) { + if (typeof closecb === "function") closecb(); else eval(closecb + '()'); + } + }); + $div.modal('show'); if (css != undefined) { $div.css(css);