PageSourceSearch

https://ohr.edu/v3/js/jquery.color.js

js ohr.edu collected 2026-10-02 02:45:52 UTC 4,627 bytes, 129 lines download raw bytes

1/*
2 * jQuery Color Animations
3 * Copyright 2007 John Resig
4 * Released under the MIT and GPL licenses.
5 */
6
7(function(jQuery){
8
9    // We override the animation for all of these color styles
10    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
11        jQuery.fx.step[attr] = function(fx){
12            if ( !fx.colorInit ) {
13                fx.start = getColor( fx.elem, attr );
14                fx.end = getRGB( fx.end );
15                fx.colorInit = true;
16            }
17
18            fx.elem.style[attr] = "rgb(" + [
19                Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
20                Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
21                Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
22            ].join(",") + ")";
23        }
24    });
25
26    // Color Conversion functions from highlightFade
27    // By Blair Mitchelmore
28    // http://jquery.offput.ca/highlightFade/
29
30    // Parse strings looking for color tuples [255,255,255]
31    function getRGB(color) {
32        var result;
33
34        // Check if we're already dealing with an array of colors
35        if ( color && color.constructor == Array && color.length == 3 )
36            return color;
37
38        // Look for rgb(num,num,num)
39        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
40            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
41
42        // Look for rgb(num%,num%,num%)
43        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
44            return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
45
46        // Look for #a0b1c2
47        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
48            return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
49
50        // Look for #fff
51        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
52            return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
53
54        // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
55        if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
56            return colors['transparent'];
57
58        // Otherwise, we're most likely dealing with a named color
59        return colors[jQuery.trim(color).toLowerCase()];
60    }
61
62    function getColor(elem, attr) {
63        var color;
64
65        do {
66            color = jQuery.curCSS(elem, attr);
67
68            // Keep going until we find an element that has color, or we hit the body
69            if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
70                break;
71
72            attr = "backgroundColor";
73        } while ( elem = elem.parentNode );
74
75        return getRGB(color);
76    };
77
78    // Some named colors to work with
79    // From Interface by Stefan Petre
80    // http://interface.eyecon.ro/
81
82    var colors = {
83        aqua:[0,255,255],
84        azure:[240,255,255],
85        beige:[245,245,220],
86        black:[0,0,0],
87        blue:[0,0,255],
88        brown:[165,42,42],
89        cyan:[0,255,255],
90        darkblue:[0,0,139],
91        darkcyan:[0,139,139],
92        darkgrey:[169,169,169],
93        darkgreen:[0,100,0],
94        darkkhaki:[189,183,107],
95        darkmagenta:[139,0,139],
96        darkolivegreen:[85,107,47],
97        darkorange:[255,140,0],
98        darkorchid:[153,50,204],
99        darkred:[139,0,0],
100        darksalmon:[233,150,122],
101        darkviolet:[148,0,211],
102        fuchsia:[255,0,255],
103        gold:[255,215,0],
104        green:[0,128,0],
105        indigo:[75,0,130],
106        khaki:[240,230,140],
107        lightblue:[173,216,230],
108        lightcyan:[224,255,255],
109        lightgreen:[144,238,144],
110        lightgrey:[211,211,211],
111        lightpink:[255,182,193],
112        lightyellow:[255,255,224],
113        lime:[0,255,0],
114        magenta:[255,0,255],
115        maroon:[128,0,0],
116        navy:[0,0,128],
117        olive:[128,128,0],
118        orange:[255,165,0],
119        pink:[255,192,203],
120        purple:[128,0,128],
121        violet:[128,0,128],
122        red:[255,0,0],
123        silver:[192,192,192],
124        white:[255,255,255],
125        yellow:[255,255,0],
126        transparent: [255,255,255]
127    };
128
129})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.