Commit c31ecf6d authored by fvtorres's avatar fvtorres

[ENH] Added the option to disable scroll in feedback()

parent 67e35457
......@@ -3724,15 +3724,16 @@ $.clickModal = function (options, href) {
/**
* Send feeback to a popup modal or to div#tikifeedback using bootstrap alert variations (error, warning, success, info)
*
* @param mes array The message
* @param type string Type of alert: error, warning, success or info (default)
* @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)
* @param mes array The message
* @param type string Type of alert: error, warning, success or info (default)
* @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 disablescroll boolean true for disabling the scrollTo feedback, false for scrollTo feedback (default),
* @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, killall, custom)
function feedback (mes, type, modal, title, icon, disablescroll, killall, custom)
{
mes = mes || [];
if (!$.isArray(mes)) {
......@@ -3747,7 +3748,7 @@ function feedback (mes, type, modal, title, icon, killall, custom)
meshtml += '<li>' + val + '</li>';
});
meshtml += '</ul>';
type = type || 'info'; modal = modal || false; killall = killall || false; custom = $(custom).length ? $(custom).first() : null;
type = type || 'info'; modal = modal || false; disablescroll = disablescroll || false; killall = killall || false; custom = $(custom).length ? $(custom).first() : null;
var target, map =
{
'error': {title:tr('Error'), class:'danger', icon:'error'},
......@@ -3793,9 +3794,12 @@ function feedback (mes, type, modal, title, icon, killall, custom)
).on('click' , 'button.close' , function() {
$(this).parent().remove();
});
$('html, body').animate({
scrollTop: $(custom ? custom : 'div#tikifeedback').offset().top
}, 500);
if (!disablescroll) {
$('html, body').animate({
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