Skip to content

Commit 9ec5779

Browse files
committed
map rgb arrays to rgb strings
1 parent a3052bf commit 9ec5779

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

dist/jquery.adaptive-background.min.js

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

src/jquery.adaptive-background.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
/* jshint debug: true, expr: true */
3+
14
;(function($){
25

36
/* Constants. */
@@ -21,8 +24,8 @@
2124
var isRemoteImageURL = function(url){
2225
var parser = document.createElement('a');
2326
parser.href = url;
24-
return !(parser.hostname === location.hostname && parser.protocol === location.protocol && parser.port === location.port)
25-
}
27+
return !(parser.hostname === location.hostname && parser.protocol === location.protocol && parser.port === location.port);
28+
};
2629

2730
/* Our main function declaration. */
2831
$.adaptiveBackground = {
@@ -37,26 +40,29 @@
3740
var $this = $(this);
3841

3942
if ( isRemoteImageURL( $this.attr('src') ) ){
40-
console.log('Not processing remote image: ' + $this.attr('src'))
43+
console.log('Not processing remote image: ' + $this.attr('src'));
4144
return;
4245
}
4346

4447
/* Small helper function which applies colors, attrs, and triggers events. */
4548
var handleColors = function(){
46-
var color = "rgb(" + ct.getColor( $this[0] ).join(',') + ")";
47-
var palette = ct.getPalette( $this[0] );
49+
var arrayToRGB = function(a){ return "rgb(" + a.join(',') + ")"; };
50+
var color = arrayToRGB( ct.getColor( $this[0] ) );
51+
var palette = ct.getPalette( $this[0] )
52+
.map(function(a){ return arrayToRGB(a); });
53+
4854
$this.attr(DATA_COLOR, color);
4955
$this.trigger(EVENT_CF, { color: color, palette: palette });
50-
}
56+
};
5157

5258
/* Subscribe to our color-found event. */
5359
$this.on( EVENT_CF, function(ev, data){
5460
var $parent;
5561
if ( $this.attr( DATA_PARENT ) ){
56-
$parent = $this.parents( $this.attr( DATA_PARENT ) )
62+
$parent = $this.parents( $this.attr( DATA_PARENT ) );
5763
}
5864
else if (opts.parent) {
59-
$parent = $this.parents( opts.parent )
65+
$parent = $this.parents( opts.parent );
6066
}
6167
else {
6268
$parent = $this.parent();

0 commit comments

Comments
 (0)