Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var FormiCheck = function () { |
| 2 | return { |
||
| 3 | //main function to initiate the module |
||
| 4 | init: function () { |
||
| 5 | |||
| 6 | $('.icheck-colors li').click(function() { |
||
| 7 | var self = $(this); |
||
| 8 | |||
| 9 | if (!self.hasClass('active')) { |
||
| 10 | self.siblings().removeClass('active'); |
||
| 11 | |||
| 12 | var skin = self.closest('.skin'), |
||
| 13 | color = self.attr('class') ? '-' + self.attr('class') : '', |
||
| 14 | colorTmp = skin.data('color') ? '-' + skin.data('color') : '-grey', |
||
| 15 | colorTmp = (colorTmp === '-black' ? '' : colorTmp); |
||
| 16 | |||
| 17 | checkbox_default = 'icheckbox_minimal', |
||
| 18 | radio_default = 'iradio_minimal', |
||
| 19 | checkbox = 'icheckbox_minimal' + colorTmp, |
||
| 20 | radio = 'iradio_minimal' + colorTmp; |
||
| 21 | |||
| 22 | if (skin.hasClass('skin-square')) { |
||
| 23 | checkbox_default = 'icheckbox_square'; |
||
| 24 | radio_default = 'iradio_square'; |
||
| 25 | checkbox = 'icheckbox_square' + colorTmp; |
||
| 26 | radio = 'iradio_square' + colorTmp; |
||
| 27 | }; |
||
| 28 | |||
| 29 | if (skin.hasClass('skin-flat')) { |
||
| 30 | checkbox_default = 'icheckbox_flat'; |
||
| 31 | radio_default = 'iradio_flat'; |
||
| 32 | checkbox = 'icheckbox_flat' + colorTmp; |
||
| 33 | radio = 'iradio_flat' + colorTmp; |
||
| 34 | }; |
||
| 35 | |||
| 36 | if (skin.hasClass('skin-line')) { |
||
| 37 | checkbox_default = 'icheckbox_line'; |
||
| 38 | radio_default = 'iradio_line'; |
||
| 39 | checkbox = 'icheckbox_line' + colorTmp; |
||
| 40 | radio = 'iradio_line' + colorTmp; |
||
| 41 | }; |
||
| 42 | |||
| 43 | skin.find('.icheck').each(function() { |
||
| 44 | var element = $(this).hasClass('state') ? $(this) : $(this).parent(); |
||
| 45 | var element_class = element.attr('class').replace(checkbox, checkbox_default + color).replace(radio, radio_default + color); |
||
| 46 | element.attr('class', element_class); |
||
| 47 | }); |
||
| 48 | |||
| 49 | skin.data('color', self.attr('class') ? self.attr('class') : 'black'); |
||
| 50 | self.addClass('active'); |
||
| 51 | }; |
||
| 52 | }); |
||
| 53 | } |
||
| 54 | }; |
||
| 55 | }(); |
||
| 56 | |||
| 57 | jQuery(document).ready(function() { |
||
| 58 | FormiCheck.init(); |
||
| 59 | }); |