/
navigator-countdown.js
71 lines (65 loc) · 1.64 KB
/
navigator-countdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* @license This file is part of LimeSurvey
* See COPYRIGHT.php for copyright notices and details.
*
*/
/**
* Update column and line with sum in a text table
*
* @param {ids} if of the table
* @param {_radix} number seperator
*/
function navigator_countdown(n)
{
$(document).ready(function()
{
$('button.disabled').prop("disabled", true);// Double check : already in navbuttonsJqueryUi
$(window).data('countdown', n);
navigator_countdown_btn().each(function(i, e)
{
$(e).data('text', $(e).text());
});
navigator_countdown_int();
});
}
function navigator_countdown_btn()
{
return $('.ls-move-btn');
}
function navigator_countdown_end()
{
navigator_countdown_btn().each(function(i, e)
{
$(e).prop("disabled",false);
if($(e).is(".ui-button" )){
$(e).button("option", "disabled", false );
}
$(e).removeClass("disabled");
if($(e).find('.ui-button-text').length){
$(e).find('.ui-button-text').html( $(e).data('text'));
}else{
$(e).html($(e).data('text'));
}
});
$(window).data('countdown', null);
}
function navigator_countdown_int()
{
var n = $(window).data('countdown');
if(n)
{
navigator_countdown_btn().each(function(i, e)
{
if($(e).find('.ui-button-text').length){
$(e).find('.ui-button-text').html( $(e).data('text'));
// just count-down for delays longer than 1 second
if(n > 1) $(e).find('.ui-button-text').html( $(e).data('text')+ " (" + n + ")");
}else{
$(e).html($(e).data('text'));
if(n > 1) $(e).html( $(e).data('text')+ " (" + n + ")");
}
});
$(window).data('countdown', --n);
}
window.setTimeout((n > 0? navigator_countdown_int: navigator_countdown_end), 1000);
}