fixes #561, font icons for radio buttons

Use the following syntax in HTML:

<label class="font-checkbox">
  <span class="icon-dot-circled"></span>
  <input type="radio" name="radio-name" value="my-value"{if template condition} checked="checked"{/if}>
  A nice label
</label>
This commit is contained in:
plegall
2016-12-02 14:40:25 +01:00
parent e07b4688cc
commit 9113490ad7
+18 -3
View File
@@ -1,5 +1,6 @@
jQuery.fn.fontCheckbox = function() {
this.find('input[type=checkbox], input[type=radio]').each(function() {
/* checkbox */
this.find('input[type=checkbox]').each(function() {
if (!jQuery(this).is(':checked')) {
jQuery(this).prev().toggleClass('icon-check icon-check-empty');
}
@@ -7,9 +8,23 @@ jQuery.fn.fontCheckbox = function() {
this.find('input[type=checkbox]').on('change', function() {
jQuery(this).prev().toggleClass('icon-check icon-check-empty');
});
/* radio */
this.find('input[type=radio]').each(function() {
if (!jQuery(this).is(':checked')) {
jQuery(this).prev().toggleClass('icon-dot-circled icon-circle-empty');
}
});
this.find('input[type=radio]').on('change', function() {
jQuery(this).closest('.font-checkbox').find('input[type=radio][name='+ jQuery(this).attr('name') +']')
.prev().toggleClass('icon-check icon-check-empty');
jQuery('.font-checkbox input[type=radio][name='+ jQuery(this).attr('name') +']').each(function() {
jQuery(this).prev().removeClass();
if (!jQuery(this).is(':checked')) {
jQuery(this).prev().addClass('icon-circle-empty');
}
else {
jQuery(this).prev().addClass('icon-dot-circled');
}
})
});
};