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