Add a callback option to Phraseanet Alerts

This commit is contained in:
Romain Neutron
2012-01-31 11:43:45 +01:00
parent ce11876411
commit 6fb9efe1b3

View File

@@ -12,21 +12,24 @@ var p4 = p4 || {};
return $('#p4_alerts'); return $('#p4_alerts');
} }
function alert(title, message) function alert(title, message, callback)
{ {
var dialog = create_dialog(); var dialog = create_dialog();
var button = new Object(); var button = new Object();
button[language.annuler] = function(){ button['Ok'] = function(){
dialog.dialog('close'); if(typeof callback === 'function')
callback();
else
dialog.dialog('close');
}; };
dialog.attr('title',title) dialog.dialog('destroy').attr('title',title)
.empty() .empty()
.append(message) .append(message)
.dialog({ .dialog({
autoOpen:false, autoOpen:false,
closeOnEscape:true, closeOnEscape:true,
resizable:false, resizable:false,
@@ -40,6 +43,15 @@ var p4 = p4 || {};
} }
}).dialog('open'); }).dialog('open');
if(typeof callback === 'function')
{
dialog.bind( "dialogclose", function(event, ui) {callback();});
}
else
{
}
return; return;
} }