|
| 1 | + |
| 2 | +/* jshint debug: true, expr: true */ |
| 3 | + |
1 | 4 | ;(function($){
|
2 | 5 |
|
3 | 6 | /* Constants. */
|
|
21 | 24 | var isRemoteImageURL = function(url){
|
22 | 25 | var parser = document.createElement('a');
|
23 | 26 | 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 | + }; |
26 | 29 |
|
27 | 30 | /* Our main function declaration. */
|
28 | 31 | $.adaptiveBackground = {
|
|
37 | 40 | var $this = $(this);
|
38 | 41 |
|
39 | 42 | 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')); |
41 | 44 | return;
|
42 | 45 | }
|
43 | 46 |
|
44 | 47 | /* Small helper function which applies colors, attrs, and triggers events. */
|
45 | 48 | 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 | + |
48 | 54 | $this.attr(DATA_COLOR, color);
|
49 | 55 | $this.trigger(EVENT_CF, { color: color, palette: palette });
|
50 |
| - } |
| 56 | + }; |
51 | 57 |
|
52 | 58 | /* Subscribe to our color-found event. */
|
53 | 59 | $this.on( EVENT_CF, function(ev, data){
|
54 | 60 | var $parent;
|
55 | 61 | if ( $this.attr( DATA_PARENT ) ){
|
56 |
| - $parent = $this.parents( $this.attr( DATA_PARENT ) ) |
| 62 | + $parent = $this.parents( $this.attr( DATA_PARENT ) ); |
57 | 63 | }
|
58 | 64 | else if (opts.parent) {
|
59 |
| - $parent = $this.parents( opts.parent ) |
| 65 | + $parent = $this.parents( opts.parent ); |
60 | 66 | }
|
61 | 67 | else {
|
62 | 68 | $parent = $this.parent();
|
|
0 commit comments