mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: added alert.timeoutfn
Also, various alert methods now pass two arguments, alert and params
This commit is contained in:
@@ -39,7 +39,7 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.timeout) {
|
if (params.timeout) {
|
||||||
startTimeout(alert, params.timeout);
|
startTimeout(alert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof params.clickfn === 'function') {
|
if (typeof params.clickfn === 'function') {
|
||||||
@@ -47,7 +47,7 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
.addClass('pointer')
|
.addClass('pointer')
|
||||||
.on('click', function (e) {
|
.on('click', function (e) {
|
||||||
if (!$(e.target).is('.close')) {
|
if (!$(e.target).is('.close')) {
|
||||||
params.clickfn();
|
params.clickfn(alert, params);
|
||||||
}
|
}
|
||||||
fadeOut(alert);
|
fadeOut(alert);
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,7 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
|
|
||||||
clearTimeout(parseInt(alert.attr('timeoutId'), 10));
|
clearTimeout(parseInt(alert.attr('timeoutId'), 10));
|
||||||
if (params.timeout) {
|
if (params.timeout) {
|
||||||
startTimeout(alert, params.timeout);
|
startTimeout(alert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
alert.children().fadeOut(100);
|
alert.children().fadeOut(100);
|
||||||
@@ -99,9 +99,15 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTimeout(alert, timeout) {
|
function startTimeout(alert, params) {
|
||||||
|
var timeout = params.timeout;
|
||||||
|
|
||||||
var timeoutId = setTimeout(function () {
|
var timeoutId = setTimeout(function () {
|
||||||
fadeOut(alert);
|
fadeOut(alert);
|
||||||
|
|
||||||
|
if (typeof params.timeoutfn === 'function') {
|
||||||
|
params.timeoutfn(alert, params);
|
||||||
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
alert.attr('timeoutId', timeoutId);
|
alert.attr('timeoutId', timeoutId);
|
||||||
|
|||||||
Reference in New Issue
Block a user