1!function($){ 2 3 4 var colors = new Array("#009ddb","#009ddb","#009ddb"); 5 var angles = new Array("NE","SE","SW", "NW"); 6 7 var defaults = { 8 fade: false, 9 color: "random", 10 boxShadow: false, 11 angle: "random" 12 }; 13 14 function convertHex(hex,opacity){ 15 hex = hex.replace('#',''); 16 r = parseInt(hex.substring(0,2), 16); 17 g = parseInt(hex.substring(2,4), 16); 18 b = parseInt(hex.substring(4,6), 16); 19 20 result = 'rgba('+r+','+g+','+b+','+opacity/100+')'; 21 return result; 22 } 23 24 function colorLuminance(hex, lum) { 25 // validate hex string 26 hex = String(hex).replace(/[^0-9a-f]/gi, ''); 27 if (hex.length < 6) { 28 hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; 29 } 30 lum = lum || 0; 31 // convert to decimal and change luminosity 32 var rgb = "#", c, i; 33 for (i = 0; i < 3; i++) { 34 c = parseInt(hex.substr(i*2,2), 16); 35 c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); 36 rgb += ("00"+c).substr(c.length); 37 } 38 return rgb; 39 } 40 41 $.fn.flatshadow = function(options){ 42 var settings = $.extend({}, defaults, options); 43 44 return this.each(function(){ 45 el = $(this); 46 if (settings.fade == true) { 47 width = Math.round(el.outerWidth() / 3); 48 height = Math.round(el.outerHeight() / 3); 49 } else { 50 width = Math.round(el.outerWidth()); 51 height = Math.round(el.outerHeight()); 52 } 53 54 if (settings.boxShadow != false) { 55 var bg_color = settings.boxShadow; 56 } 57 58 if (settings.color != "random" && !el.attr('data-color')) { 59 var color = settings.color; 60 } else { 61 var color = colors[Math.floor(Math.random() * colors.length)]; 62 63 if (el.attr('data-color')) { 64 var color = el.attr('data-color'); 65 } 66 } 67 68 if (settings.angle != "random" && !el.attr('data-angle')) { 69 var angle = settings.angle; 70 } else { 71 var angle = angles[Math.floor(Math.random() * angles.length)]; 72 73 if (el.attr('data-angle')) { 74 var angle = el.attr('data-angle'); 75 } 76 } 77 78 var darkercolor = colorLuminance(color, -0.3); 79 var text_shadow = ""; 80 81 if (settings.boxShadow != false) { 82 var box_shadow = ""; 83 } else { 84 var box_shadow = "none"; 85 } 86 87 switch (angle) { 88 case 'N': 89 for( var i=1; i <= height; i++ ) { 90 if (settings.boxShadow != false) box_shadow += "0px " + (i * 2) * -1 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 91 if (settings.fade != false) { 92 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 93 } else { 94 var text_color = darkercolor; 95 } 96 text_shadow += "0px " + i * -1 + "px 0px " + text_color 97 if (i != height ) { 98 text_shadow += ", " 99 box_shadow += ", " 100 } 101 } 102 break; 103 case 'NE': 104 for( var i=1; i <= height; i++ ) { 105 if (settings.boxShadow != false) box_shadow += i * 2 + "px " + (i * 2) * -1 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 106 if (settings.fade != false) { 107 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 108 } else { 109 var text_color = darkercolor; 110 } 111 text_shadow += i + "px " + i * -1 + "px 0px " + text_color 112 if (i != height ) { 113 text_shadow += ", " 114 box_shadow += ", " 115 } 116 } 117 break; 118 case 'E': 119 for( var i=1; i <= width; i++ ) { 120 if (settings.boxShadow != false) box_shadow += i * 2 + "px " + "0px 0px " + convertHex( bg_color, (50 - i/ width * 100) ) 121 if (settings.fade != false) { 122 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 123 } else { 124 var text_color = darkercolor; 125 } 126 text_shadow += i + "px " + "0px 0px " + text_color 127 if (i != width ) { 128 text_shadow += ", " 129 box_shadow += ", " 130 } 131 } 132 break; 133 case 'SE': 134 for( var i=1; i <= height; i++ ) {
135 if (settings.boxShadow != false) box_shadow += i * 2 + "px " + i * 2 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 136 if (settings.fade != false) { 137 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 138 } else { 139 var text_color = darkercolor; 140 } 141 text_shadow += i + "px " + i + "px 0px " + text_color 142 if (i != height ) { 143 text_shadow += ", " 144 box_shadow += ", " 145 } 146 } 147 break; 148 case 'S': 149 for( var i=1; i <= height; i++ ) { 150 if (settings.boxShadow != false) box_shadow += "0px " + i * 2 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 151 if (settings.fade != false) { 152 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 153 } else { 154 var text_color = darkercolor; 155 } 156 text_shadow += "0px " + i + "px 0px " + text_color 157 if (i != height ) { 158 text_shadow += ", " 159 box_shadow += ", " 160 } 161 } 162 break; 163 case 'SW': 164 for( var i=1; i <= height; i++ ) { 165 if (settings.boxShadow != false) box_shadow += (i * 2) * -1 + "px " + i * 2 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 166 if (settings.fade != false) { 167 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 168 } else { 169 var text_color = darkercolor; 170 } 171 text_shadow += i * -1 + "px " + i + "px 0px " + text_color 172 if (i != height ) { 173 text_shadow += ", " 174 box_shadow += ", " 175 } 176 } 177 break; 178 case 'W': 179 for( var i=1; i <= height; i++ ) { 180 if (settings.boxShadow != false) box_shadow += (i * 2) * -1 + "px " + "0px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 181 if (settings.fade != false) { 182 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 183 } else { 184 var text_color = darkercolor; 185 } 186 text_shadow += i * -1 + "px " + "0px 0px " + text_color 187 if (i != height ) { 188 text_shadow += ", " 189 box_shadow += ", " 190 } 191 } 192 break; 193 case 'NW': 194 for( var i=1; i <= height; i++ ) { 195 if (settings.boxShadow != false) box_shadow += (i * 2) * -1 + "px " + (i * 2) * -1 + "px 0px " + convertHex( bg_color, (50 - i/ height * 100) ) 196 if (settings.fade != false) { 197 var text_color = convertHex( darkercolor, 100 - i/height * 100 ); 198 } else { 199 var text_color = darkercolor; 200 } 201 text_shadow += i * -1 + "px " + i * -1 + "px 0px " + text_color 202 if (i != height ) { 203 text_shadow += ", " 204 box_shadow += ", " 205 } 206 } 207 break; 208 } 209 el.css({ 210 //"background": color, 211 "color": colorLuminance(color, 1), 212 "text-shadow": text_shadow 213 //"box-shadow": box_shadow 214 }); 215 }); 216 } 217 218}(window.jQuery); 219 220
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.