jStyling is a plugin for styling of selects, checkboxes, radio buttons and file selects with JQuery.
You can download jStyling here: https://github.com/polsad/jStyling
$.jStyling({'fileButtonText': 'Upload file'})
Changing anything except fileButtonText is NOT recommended.
Use latest stable version of jQuery for working with jStyling (1.4.4 at the moment of writing)
jStyling is tested and works in:
Select with additional settings {extraClass:'extra'}
Before styling:
<select name="select1" >...</select>
After styling:
<div class="jstyling-select">
<div class="jstyling-select-l">
<div class="item-1">Option 1</div>
<div class="item-2" disabled="true">Option 2</div>
<div class="item-3">Option 3</div>
</div>
<div class="jstyling-select-s">
<div class="jstyling-select-t">Option 1</div>
</div>
<select name="select1" style="display: none;">...</select>
</div>
There are 3 methods for working with selects in jStyling:
/**
* Style all selects
*/
$.jStyling.createSelect($('select'));
/**
* Style select with name=extra, styles select will have additional class "extra".
* Width of the styled select equals width of the select.
*/
$.jStyling.createSelect($('select[name="extra"]'), {extraClass: 'myExtraClass'});
elements = what selects will be updated.
Method is used when update of select values is needed (for example after ajax load), blocking/unblocking of certain <option> or of the whole select.
Examples:
/**
* Update all selects
*/
$.jStyling.updateSelect($('select'));
/**
* Block select with name=extra
*/
$('select[name="extra"]).attr('disabled','true');
$.jStyling.updateSelect($('select[name="extra"]'));
elements = selects, for wchich styling will be removed.
Examples:
/**
* Delete styling of all selects
*/
$.jStyling.destroySelect($('select'));
/**
* Delete styling of select with name=extra
*/
$.jStyling.destroySelect($('select[name="extra"]'));
Before styling:
<input type="checkbox" name="checkbox">
After styling:
<div class="jstyling-checkbox">
<input type="checkbox" name="checkbox">
</div>
There are 3 methods for working with checkboxes:
/**
* Add styling to all checkboxes
*/
$.jStyling.createCheckbox($('input[type=checkbox]'));
elements — checkboxes, which will be updated.
Examples:
/**
* Update all checkboxes
*/
$.jStyling.updateCheckbox($('input[type=checkbox]'));
/**
* Block checkbox with id=terms
*/
$('#terms).attr('disabled','true');
$.jStyling.updateCheckbox($('#terms'));
elements — checkboxes, which styling will be removed.
Пример:
/**
* Delete styling for all checkboxes
*/
$.jStyling.destroyCheckbox($('input[type=checkbox]'));
Before styling:
<input type="radio" name="radio">
After styling:
<div class="jstyling-radio">
<input type="radio" name="radio">
</div>
There are 3 methods for working with radio buttons in jStyling
Input parameters and principles of work are the same as for checkboxes
Before styling:
<input type="file" size="30" name="file" id="file">
After styling:
<div class="jstyling-file">
<div class="jstyling-file-f"></div>
<div class="jstyling-file-b">Upload file
<input type="file" size="30" name="file" id="file" style="...">
</div>
</div>
There are 2 methods in jStying to work with file selects:
/**
* Add styling to all file selects
*/
$.jStyling.createFileInput($('input[type=file]'));
/**
* Add styling to file selects with id=file, text on the button = "Browse"
*/
$.jStyling.createFileInput($('#file'), {fileButtonText: 'Browse'});
elements — file selects, for which styling will be removed
Example:
/**
* Delete styling for all file selects
*/
$.jStyling.destroyFileInput($('input[type=file]'));