This repository was archived by the owner on Nov 8, 2022. It is now read-only.
forked from kenirwin/Weeding-Helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiphone-toggle.php
More file actions
73 lines (49 loc) · 1.84 KB
/
iphone-toggle.php
File metadata and controls
73 lines (49 loc) · 1.84 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
64
65
66
67
68
69
70
71
72
<?php
//By Hidayat Sagita
//https://www.webstuffshare.com/2010/03/stylize-your-own-checkboxes/
?>
<link rel="stylesheet" type="text/css" media="screen, projection" href="iphone-toggle.css" />
<script type="text/javascript" src="jquery.backgroundPosition.js"></script>
<script>
$(document).ready(function() {
$('.iphone-style').live('click', function() {
checkboxID = '#' + $(this).attr('rel');
if($(checkboxID)[0].checked == false) {
$(this).animate({backgroundPosition: '0% 100%'});
$(checkboxID)[0].checked = true;
$(this).removeClass('off').addClass('on');
} else {
$(this).animate({backgroundPosition: '100% 0%'});
$(checkboxID)[0].checked = false;
$(this).removeClass('on').addClass('off');
}
});
$('.firerift-style').live('click', function() {
checkboxID = '#' + $(this).attr('rel');
if($(checkboxID)[0].checked == false) {
$(checkboxID)[0].checked = true;
$(this).removeClass('off').addClass('on');
} else {
$(checkboxID)[0].checked = false;
$(this).removeClass('on').addClass('off');
}
});
$('.iphone-style-checkbox, .firerift-style-checkbox').each(function() {
thisID = $(this).attr('id');
thisClass = $(this).attr('class');
switch(thisClass) {
case "iphone-style-checkbox":
setClass = "iphone-style";
break;
case "firerift-style-checkbox":
setClass = "firerift-style";
break;
}
$(this).addClass('hidden');
if($(this)[0].checked == true)
$(this).after('<div class="'+ setClass +' on" rel="'+ thisID +'"> </div>');
else
$(this).after('<div class="'+ setClass +' off" rel="'+ thisID +'"> </div>');
});
});
</script>