(function($) {
$.fn.checkbox = function() {
$(this).each(function() {
var $el = $(this);
var typeClass = $el.attr('type');
$el.hide();
$el.next('.'+typeClass+'-sign').remove();
var $checkbox = $('').insertAfter($el);
$checkbox.click(function() {
if($checkbox.closest('label').length) return;
if($el.attr('type') == 'radio') {
$el.prop('checked', true).trigger('change').trigger('click');
} else {
$el.prop('checked', !($el.is(':checked'))).trigger('change');
}
});
$el.change(function() {
$('input[name="'+$el.attr('name')+'"]').each(function() {
if($(this).is(':checked')) {
$(this).next('.'+$(this).attr('type')+'-sign').addClass('checked');
} else {
$(this).next('.'+$(this).attr('type')+'-sign').removeClass('checked');
}
});
});
if($el.is(':checked')) {
$checkbox.addClass('checked');
} else {
$checkbox.removeClass('checked');
}
});
}
$.fn.combobox = function() {
$(this).each(function() {
var $el = $(this);
$el.insertBefore($el.parent('.combobox-wrapper'));
$el.next('.combobox-wrapper').remove();
$el.css({
'opacity': 0,
'position': 'absolute',
'left': 0,
'right': 0,
'top': 0,
'bottom': 0
});
var $comboWrap = $('').insertAfter($el);
var $text = $('').appendTo($comboWrap);
var $button = $('').appendTo($comboWrap);
$el.appendTo($comboWrap);
$el.change(function() {
$text.text($('option:selected', $el).text());
});
$text.text($('option:selected', $el).text());
$el.comboWrap = $comboWrap;
});
}
})(jQuery);