Skip to content

Commit 8f51b4b

Browse files
committed
Edit README.md
1 parent 80eab83 commit 8f51b4b

File tree

4 files changed

+128
-73
lines changed

4 files changed

+128
-73
lines changed

README.markdown

Lines changed: 0 additions & 69 deletions
This file was deleted.

README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
## rcSwitcher Jquery Plugin
2+
3+
![rcSwitcher](http://i707.photobucket.com/albums/ww71/ashekfadl/Screen%20Shot%202015-04-26%20at%208.30.33%20PM.png)
4+
5+
6+
>rcSwitcher plugin *'Radio Checbox Switcher'* let you transform your input checkboxs and radios into a nice switch buttons with a nice interfaces.
7+
8+
9+
### Requirements
10+
>browser supports css3 transition and transform, latest versions of *__modern browsers support css3 transform and transitions__*
11+
12+
>built with jquery 2.3.1
13+
>>*__requires jquery >= 1.7.0__*
14+
15+
16+
### License
17+
18+
>This Plugin is distributed under [GNU GPL V3 License](http://choosealicense.com/licenses/gpl-3.0/)
19+
20+
21+
### Copyright
22+
>@author Ahmed Saad <a7mad.sa3d.2014@gmail.com>
23+
24+
### Version
25+
> 2.1.0
26+
27+
28+
----
29+
30+
### Features:
31+
32+
33+
1. no need for extra or specific html
34+
2. _`smooth`_ as uses css3 transform and transition properties with full vendor prefixs
35+
3. support checkbox of type array _ex: `<input name="delete_users[]">`_
36+
4. multiple themes
37+
5. you can manipulate switch style as:
38+
* control switch width and height.
39+
* control switch blob offset.
40+
* control switch on off direction.
41+
* control switch on state text and off state text.
42+
* ability to automatic fit font size.
43+
* ability to automatic stick switch to its parent side.
44+
* show switch corresponding input for functionality testing.
45+
* fire custom events on turnon, turnoff and change. so you can perform your tasks depends on switch status.
46+
* >on firing events an information plain object is passed to event handler function as the second argument. it contains jquery objects of each switch piece and also input jquery object
47+
48+
49+
---
50+
### Usage:
51+
52+
This example explains:
53+
* Basic usage
54+
* Available options with its defaults
55+
* Using Custom Event
56+
57+
```javascript
58+
59+
// convert all checkboxs to switchs
60+
$('input[type=checkbox]').rcSwitcher();
61+
62+
63+
// Options
64+
$('input[type=checkbox]').rcSwitcher({
65+
// Default value // info
66+
67+
theme: 'flat', // light select theme between 'flat, light, dark, modern'
68+
width: 80, // 56 in 'px'
69+
height: 26, // 22
70+
blobOffset: 0, // 2
71+
reverse: true, // false reverse on off order
72+
onText: 'YES', // 'ON' text displayed on ON state
73+
offText: 'NO', // 'OFF' text displayed on OFF state
74+
inputs: true, // false show corresponding inputs
75+
autoFontSize: true, // false auto fit text size with respect to switch height
76+
autoStick: true // false auto stick switch to its parent side
77+
});
78+
79+
80+
// assign event handler
81+
$(':radio').rcSwitcher().on({
82+
83+
'turnon.rcSwitcher': function( e, dataObj ){
84+
85+
// to do on turning on a switch
86+
87+
// dataObj.$input current input jq object
88+
// dataObj.$switcher current switch jq object
89+
// dataObj.components.$toggler swich toggler jq object
90+
// dataObj.components.$on switch on jq object
91+
// dataObj.components.$off switch off jq object
92+
// dataObj.components.$blob switch blob jq object
93+
94+
},
95+
96+
'turnoff.rcSwitcher': function( e, dataObj ){
97+
98+
// to do on turning off a switch
99+
},
100+
101+
'change.rcSwitcher': function( e, dataObj, changeType ){
102+
103+
// to do on turning on or off a switch
104+
// changeType is 'turnon' || 'turnoff'
105+
}
106+
107+
});
108+
109+
```
110+
111+
__Options that could be set inside html input as attributes__
112+
113+
>_`rcswitcher-ontext=""`_
114+
>_`rcswitcher-offtext=""`_
115+
>>those attributes are equivalent to onText, offText options
116+
>>__*but they have more priority and if set they will override options values*__
117+
118+
```html
119+
<!-- Set OnText and offText inside input element itself -->
120+
<input type="checkbox" name="" value="" rcswitcher-ontext="YES" rcswitcher-offtext="NO" />
121+
122+
```

js/rcswitcher.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*
99
*
1010
* @package rcSwitcher
11+
* @name rcSwitcher
1112
* @version 2.1.0
1213
* @author ahmed saad <a7mad.sa3d.2014@gmail.com><ahmedfadlshaker@gmail.com>
1314
* @copyright ahmed saad april 2015
@@ -105,8 +106,8 @@
105106

106107
data.components.$toggler = templates.$toggler.clone();
107108

108-
data.components.$on = templates.$on.clone().html( $input.attr('switcher-ontext') || options.onText );
109-
data.components.$off = templates.$off.clone().html( $input.attr('switcher-offtext') || options.offText );
109+
data.components.$on = templates.$on.clone().html( $input.attr('rcswitcher-ontext') || options.onText );
110+
data.components.$off = templates.$off.clone().html( $input.attr('rcswitcher-offtext') || options.offText );
110111
data.components.$blob = templates.$blob.clone();
111112

112113

js/rcswitcher.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)