Skip to content

Commit 7bf44e5

Browse files
committed
Readme: Update jQuery & code style in code snippets
1 parent 674a3b0 commit 7bf44e5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ div {
6565
border: 1px solid green;
6666
}
6767
</style>
68-
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
68+
<script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>
6969
<script src="jquery.color.min.js"></script>
7070
</head>
7171
<body>
7272
<button id="go">Simple</button>
7373
<button id="sat">Desaturate</button>
7474
<div id="block">Hello!</div>
7575
<script>
76-
jQuery("#go").click(function(){
77-
jQuery("#block").animate({
76+
$( "#go" ).on( "click", function() {
77+
$( "#block" ).animate( {
7878
backgroundColor: "#abcdef"
7979
}, 1500 );
8080
});
81-
jQuery("#sat").click(function(){
82-
jQuery("#block").animate({
81+
$( "#sat" ).on( "click", function() {
82+
$( "#block" ).animate( {
8383
backgroundColor: jQuery.Color({ saturation: 0 })
8484
}, 1500 );
8585
});
@@ -109,8 +109,8 @@ The `jQuery.Color()` function allows you to create and manipulate color objects
109109
```javascript
110110
// Parsing String Colors:
111111
jQuery.Color( "#abcdef" );
112-
jQuery.Color( "rgb(100,200,255)" );
113-
jQuery.Color( "rgba(100,200,255,0.5)" );
112+
jQuery.Color( "rgb(100, 200, 255)" );
113+
jQuery.Color( "rgba(100, 200, 255, 0.5)" );
114114
jQuery.Color( "aqua" );
115115

116116
// Creating Color Objects in Code:
@@ -147,14 +147,14 @@ lightness( val ) // returns a copy of the color object with the lightness set t
147147
rgba() // returns a rgba "tuple" [ red, green, blue, alpha ]
148148
// rgba() setters: returns a copy of the color with any defined values set to the new value
149149
rgba( red, green, blue, alpha )
150-
rgba({ red: red, green: green, blue: blue, alpha: alpha })
151-
rgba([ red, green, blue, alpha ])
150+
rgba( { red: red, green: green, blue: blue, alpha: alpha } )
151+
rgba( [ red, green, blue, alpha ] )
152152

153153
hsla() // returns a HSL tuple [ hue, saturation, lightness, alpha ]
154154
// much like the rgb setter - returns a copy with any defined values set
155155
hsla( hue, saturation, lightness, alpha )
156-
hsla({ hue: hue, saturation: saturation, lightness: lightness, alpha: alpha )
157-
hsla([ hue, saturation, lightness, alpha ])
156+
hsla( { hue: hue, saturation: saturation, lightness: lightness, alpha: alpha } )
157+
hsla( [ hue, saturation, lightness, alpha ] )
158158
```
159159

160160
### String methods
@@ -192,7 +192,7 @@ There is also a named color `"_default"` which by default is white, this is used
192192
A special note about the color `"transparent"` - It returns `null` for red green and blue unless you specify colors for these values.
193193

194194
```javascript
195-
jQuery.Color("#abcdef").transition("transparent", 0.5)
195+
jQuery.Color( "#abcdef" ).transition( "transparent", 0.5 )
196196
```
197197

198198
Animating to or from the value `"transparent"` will still use "#abcdef" for red green and blue.
@@ -211,11 +211,11 @@ It is possible for you to add your own functions to the color object. For insta
211211
```javascript
212212
// method taken from https://gist.github.com/960189
213213
jQuery.Color.fn.contrastColor = function() {
214-
var r = this._rgba[0], g = this._rgba[1], b = this._rgba[2];
215-
return (((r*299)+(g*587)+(b*144))/1000) >= 131.5 ? "black" : "white";
214+
var r = this._rgba[ 0 ], g = this._rgba[ 1 ], b = this._rgba[ 2 ];
215+
return ( ( ( r * 299 ) + ( g * 587 ) + ( b * 144 ) ) / 1000 ) >= 131.5 ? "black" : "white";
216216
};
217217

218218
// usage examples:
219-
jQuery.Color("#bada55").contrastColor(); // "black"
219+
jQuery.Color( "#bada55" ).contrastColor(); // "black"
220220
element.css( "color", jQuery.Color( element, "backgroundColor" ).contrastColor() );
221221
```

0 commit comments

Comments
 (0)