forked from WebStackPage/WebStackPage.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxenon-api.js
91 lines (71 loc) · 1.75 KB
/
xenon-api.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Xenon API Functions
*
* Theme by: www.laborator.co
**/
function rtl() // checks whether the content is in RTL mode
{
if(typeof window.isRTL == 'boolean')
return window.isRTL;
window.isRTL = jQuery("html").get(0).dir == 'rtl' ? true : false;
return window.isRTL;
}
// Page Loader
function show_loading_bar(options)
{
var defaults = {
pct: 0,
delay: 1.3,
wait: 0,
before: function(){},
finish: function(){},
resetOnEnd: true
};
if(typeof options == 'object')
defaults = jQuery.extend(defaults, options);
else
if(typeof options == 'number')
defaults.pct = options;
if(defaults.pct > 100)
defaults.pct = 100;
else
if(defaults.pct < 0)
defaults.pct = 0;
var $ = jQuery,
$loading_bar = $(".xenon-loading-bar");
if($loading_bar.length == 0)
{
$loading_bar = $('<div class="xenon-loading-bar progress-is-hidden"><span data-pct="0"></span></div>');
public_vars.$body.append( $loading_bar );
}
var $pct = $loading_bar.find('span'),
current_pct = $pct.data('pct'),
is_regress = current_pct > defaults.pct;
defaults.before(current_pct);
TweenMax.to($pct, defaults.delay, {css: {width: defaults.pct + '%'}, delay: defaults.wait, ease: is_regress ? Expo.easeOut : Expo.easeIn,
onStart: function()
{
$loading_bar.removeClass('progress-is-hidden');
},
onComplete: function()
{
var pct = $pct.data('pct');
if(pct == 100 && defaults.resetOnEnd)
{
hide_loading_bar();
}
defaults.finish(pct);
},
onUpdate: function()
{
$pct.data('pct', parseInt($pct.get(0).style.width, 10));
}});
}
function hide_loading_bar()
{
var $ = jQuery,
$loading_bar = $(".xenon-loading-bar"),
$pct = $loading_bar.find('span');
$loading_bar.addClass('progress-is-hidden');
$pct.width(0).data('pct', 0);
}