Commit 42ee66df authored by fvtorres's avatar fvtorres

[ENH] Adds 2 new parameters for feedback() in tiki-query.js. One is killall,...

[ENH] Adds 2 new parameters for feedback() in  tiki-query.js. One is killall, to remove other feedbacks upon the insertion of this one (Useful if lots of feedbacks coming out in same page dynamically with jQuery). Second is custom target for the feedback, so you can select other place than the default feedback div. (I guess is better than creating a new function just for this). *The killall removes only the feedbacks in the target where it is inserted, not the whole page’s feedbacks (guess its more logical this way).
parent 84ba3f9b
......@@ -3729,8 +3729,10 @@ $.clickModal = function (options, href) {
* @param modal boolean true for popup modal, false (default) to use the div#tikifeedback that is on every page
* @param title string Custom message title
* @param icon string Custom icon
* @param killall boolean true for removing other feedbacks already open, false (default) (only for non modal)
* @param custom string Custom target in jquery selection notation (only for non modal)
*/
function feedback (mes, type, modal, title, icon)
function feedback (mes, type, modal, title, icon, killall, custom)
{
mes = mes || [];
if (!$.isArray(mes)) {
......@@ -3745,7 +3747,7 @@ function feedback (mes, type, modal, title, icon)
meshtml += '<li>' + val + '</li>';
});
meshtml += '</ul>';
type = type || 'info'; modal = modal || false;
type = type || 'info'; modal = modal || false; killall = killall || false; custom = ($('"' + custom + '"').length) ? $('"' + custom + '"').first() : null;
var target, map =
{
'error': {title:tr('Error'), class:'danger', icon:'error'},
......@@ -3775,10 +3777,13 @@ function feedback (mes, type, modal, title, icon)
);
target.modal();
} else {
if (killall) {
$(custom ? custom : 'div#tikifeedback').find('div.alert').remove();
}
if (mes.length == 0) {
meshtml = '';
}
$('div#tikifeedback').append(
$(custom ? custom : 'div#tikifeedback').append(
'<div class="alert alert-dismissable alert-' + map[type]['class'] + '">' +
'<button type="button" class="close" data-dismiss="modal">x</button>' +
'<h4 class="text-' + map[type]['class'] + '">' + icon[0].outerHTML + ' ' + title + '</h4>' +
......@@ -3786,7 +3791,7 @@ function feedback (mes, type, modal, title, icon)
'</div>'
);
$('html, body').animate({
scrollTop: $("div#tikifeedback").offset().top
scrollTop: $(custom ? custom : 'div#tikifeedback').offset().top
}, 500);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment