namibia
c449ac80b48405f72fd700d5cd406397b3a17d8a
namibia / public / js / app / form-helpers.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 |
;(function(){ var ie = (function(){ var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0] ); return v > 4 ? v : undef; }()); var updateCheckboxes = function($_form){ var $$_checkboxes = $_form.find('input[type=checkbox]'); $.each($$_checkboxes, function(i, checkbox){ var $_checkbox = $(checkbox); var label = $_checkbox.parent('label'); if(label.length){ $(label).addClass('checkbox'); }else{ $_checkbox.wrap('<label class="checkbox"/>'); } $('<span class="styled-checkbox" />').insertAfter($_checkbox); if( !!ie && ie < 9){ checkbox.set_checked = function(){ if(this.checked){ $_form.find('input[name="'+this.name+'"] + span').removeClass('checked'); $(this).next('span').addClass('checked').blur(); } }; checkbox.set_checked(); $_checkbox.bind('change', function(){ this.set_checked(); }); } if(checkbox.value == 'on'){ checkbox.value = true; } }); }; $(document).ready( function(){ $('form').each(function(i, form){ updateCheckboxes( $(form) ); }); }); })(); |
Commits for namibia/public/js/app/form-helpers.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |