Advertisement
Speeedfire

Untitled

Oct 3rd, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. //forms
  2. $(document).ready(function(){
  3. $('.form').each(function(){
  4.  
  5. $this = $(this);
  6.  
  7. //checkbox
  8. $checkbox = $this.find('input[type=checkbox]');
  9.  
  10. $checkbox.css({
  11. 'opacity': 0
  12. });
  13.  
  14. value = 0;
  15. $checkbox_val = $checkbox.is(':checked');
  16. if($checkbox_val == false) {
  17. value = '';
  18. } else {
  19. value = ' checked';
  20. }
  21. $checkbox.wrap( '<span class="input-checkbox'+value+'"></span>' );
  22.  
  23. //radio
  24. $radio = $this.find('input[type=radio]');
  25.  
  26. $radio.css({
  27. 'opacity': 0
  28. });
  29.  
  30. value = 0;
  31. $radio_val = $radio.is(':checked');
  32. if($radio_val == false) {
  33. value = '';
  34. } else {
  35. value = ' checked';
  36. }
  37. $radio.wrap( '<span class="input-radio'+value+'"></span>' );
  38.  
  39. });
  40.  
  41. //checkbox actions
  42. $('.form .input-checkbox').on({
  43. hover: function() {
  44. $(this).toggleClass('hover');
  45. },
  46. mousedown: function() {
  47. $(this).toggleClass('active');
  48. },
  49. mouseup: function() {
  50. $(this).toggleClass('active');
  51. },
  52. click: function() {
  53. $(this).toggleClass('checked');
  54. }
  55. });
  56.  
  57. //radio actions
  58. $('.form .input-radio').on({
  59. hover: function() {
  60. $(this).toggleClass('hover');
  61. },
  62. mousedown: function() {
  63. $(this).toggleClass('active');
  64. },
  65. mouseup: function() {
  66. $(this).toggleClass('active');
  67. },
  68. click: function() {
  69. $input_name = $(this).children().attr('name');
  70. $('.form [name="'+$input_name+'"]').parent().removeClass('checked');
  71. $(this).toggleClass('checked');
  72. }
  73. });
  74.  
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement