installer.js
1.74 KB
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
/**
* Installer progress JS app plugin
*
* @package JMAP::CPANEL::administrator::components::com_jmap
* @subpackage js
* @author Joomla! Extensions Store
* @copyright (C)2015 Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
// Use plugin installer progress
jQuery(function($) {
/**
* jQuery Installer progress bar plugin
*/
$.fn.InstallerProgress = function(options) {
var targetProgressElements = new Array();
// Init options
var defaultOptions = {
'cascade': new Array({'perc':20, 'time':500},
{'perc':40, 'time':800},
{'perc':50, 'time':800},
{'perc':30, 'time':400},
{'perc':80, 'time':800})
}
pluginOptions = $.extend({}, defaultOptions, options );
// Cycle on pre initialized wrapped set
this.each(function(index, progress) {
// Instance of Pingomatic manager
targetProgressElements.push(progress);
});
// Reverse stack structure
targetProgressElements.reverse();
var counterCall = 0;
// Start install process
(function install() {
var singleProgress = targetProgressElements.pop();
if (singleProgress) {
// Do stuff
setTimeout(function() {
$(singleProgress).css('width', pluginOptions.cascade[counterCall].perc + '%');
setTimeout(function() {
$(singleProgress).css('width', '100%').addClass('progress-bar-success');
// Show step details
$('span.step_details', singleProgress).show();
counterCall++;
// Recurse to the end
install();
}, pluginOptions.cascade[counterCall].time);
}, 300);
} else {
$('div.alert-success.hidden').show().css('visibility','visible');
return;
}
})();
};
$('div.progress-bar').InstallerProgress({});
});