-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdemo.js
65 lines (55 loc) · 2.05 KB
/
demo.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
(function(){
function clean(button, value){
loading.infinite = false;
button.innerHTML = button.querySelector('span').innerHTML;
classie.remove(button, current);
classie.add(button, value);
current = value;
var newButton = button.cloneNode(true);
button.parentNode.replaceChild(newButton, button);
return newButton;
}
function newLoader(button, value, open){
var newButton = clean(button, value);
if(value === 'circular-loading'){
loading = circularLoading();
}else if(value === 'infinity-loading'){
loading = infinityLoading();
}else if(value === 'circle-loading'){
loading = circleLoading();
}
if(open){
newButton.removeAttribute('disabled');
setTimeout(function(){ newButton.click(); }, 300);
}
}
function loadersClick(){
var self = this;
var button = document.querySelector('.loading-button');
if(classie.has(button, 'open-loading')){
classie.remove(button, 'open-loading');
setTimeout(function(){ newLoader(button, self.value, true); }, 300);
}else{
newLoader(button, self.value);
}
}
var loaders = document.getElementsByName('loaders'),
current = 'circular-loading';
for(var i = 0; i < loaders.length; i++){
loaders[i].addEventListener('change', loadersClick, false);
}
var loading = circularLoading();
function positionsClick(){
var button = document.querySelector('.loading-button');
classie.add(button, 'no-transition');
classie.remove(button, currentStyle);
classie.add(button, this.value);
currentStyle = this.value;
setTimeout(function(){ classie.remove(button, 'no-transition'); }, 10);
}
var positions = document.getElementsByName('positions'),
currentStyle = 'top';
for(i = 0; i < positions.length; i++){
positions[i].addEventListener('change', positionsClick, false);
}
})();