1////////////////////////////////////////////////////////////////////////////////// 2// Cloud Zoom V1.0.3 3// Rev 201209181857 4// (c) 2010-2012 by R Cecco. <http://www.professorcloud.com> 5// MIT License 6// 7// Please retain this copyright header in all versions of the software 8// 9////////////////////////////////////////////////////////////////////////////////// 10(function (jQuery, $) { 11 'use strict'; 12 var scripts = document.getElementsByTagName("script"), 13 index = scripts[scripts.length - 1].src.lastIndexOf('/'), 14 lastScriptPath = scripts[scripts.length - 1].src.slice(0, index); 15 16 $(document).ready(function () { 17 $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom(); 18 }); 19 20 function format(str) { 21 for (var i = 1; i < arguments.length; i++) { 22 str = str.replace('%' + (i - 1), arguments[i]); 23 } 24 return str; 25 } 26 27 function CloudZoom(jWin, opts) { 28 var sImg = $('img', jWin); 29 var img1; 30 var img2; 31 var zoomDiv = null; 32 var $mouseTrap = null; 33 var lens = null; 34 var $tint = null; 35 var softFocus = null; 36 var $ie6Fix = null; 37 var zoomImage; 38 var controlTimer = 0; 39 var cw, ch; 40 var destU = 0; 41 var destV = 0; 42 var currV = 0; 43 var currU = 0; 44 var filesLoaded = 0; 45 var mx, my; 46 var ctx = this, 47 zw; 48 setTimeout(function () { 49 if ($mouseTrap === null) { 50 var w = jWin.width(); 51 jWin.parent().append(format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>', w / 3, (w / 2) - (w / 6))); 52 $('cloud-zoom-loading', jWin.parent()).css('opacity', 0.5) 53 } 54 }, 200); 55 var ie6FixRemove = function () { 56 if ($ie6Fix !== null) { 57 $ie6Fix.remove(); 58 $ie6Fix = null; 59 } 60 }; 61 this.removeBits = function () { 62 if (lens) { 63 lens.remove(); 64 lens = null; 65 } 66 if ($tint) { 67 $tint.remove(); 68 $tint = null; 69 } 70 if (softFocus) { 71 softFocus.remove(); 72 softFocus = null; 73 } 74 ie6FixRemove(); 75 $('.cloud-zoom-loading', jWin.parent()).remove(); 76 }; 77 this.destroy = function () { 78 jWin.data('zoom', null); 79 if ($mouseTrap) { 80 $mouseTrap.unbind(); 81 $mouseTrap.remove(); 82 $mouseTrap = null; 83 } 84 if (zoomDiv) { 85 zoomDiv.remove(); 86 zoomDiv = null; 87 } 88 this.removeBits(); 89 }; 90 this.fadedOut = function () { 91 if (zoomDiv) { 92 zoomDiv.remove(); 93 zoomDiv = null; 94 } 95 this.removeBits(); 96 }; 97 this.controlLoop = function () { 98 if (lens) { 99 var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0; 100 var y = (my - sImg.offset().top - (ch * 0.5)) >> 0; 101 if (x < 0) { 102 x = 0; 103 } else if (x > (sImg.outerWidth() - cw)) { 104 x = (sImg.outerWidth() - cw); 105 } 106 if (y < 0) { 107 y = 0; 108 } else if (y > (sImg.outerHeight() - ch)) { 109 y = (sImg.outerHeight() - ch) 110 } 111 lens.css({ 112 left: x, 113 top: y 114 }); 115 lens.css('background-position', (-x) + 'px ' + (-y) + 'px'); 116 destU = (((x) / sImg.outerWidth()) * zoomImage.width) >> 0; 117 destV = (((y) / sImg.outerHeight()) * zoomImage.height) >> 0; 118 currU += (destU - currU) / opts.smoothMove; 119 currV += (destV - currV) / opts.smoothMove; 120 zoomDiv.css('background-position', (-(currU >> 0) + 'px ') + (-(currV >> 0) + 'px')) 121 } 122 controlTimer = setTimeout(function () {
123 ctx.controlLoop(); 124 }, 30); 125 }; 126 this.init2 = function (img, id) { 127 filesLoaded++; 128 if (id === 1) { 129 zoomImage = img; 130 } 131 if (filesLoaded === 2) { 132 this.init(); 133 } 134 }; 135 this.init = function () { 136 $('.cloud-zoom-loading', jWin.parent()).remove(); 137 var $m = $("<div class='mousetrap' style='background-image:url(\"" + lastScriptPath + "/blank.png\")" + "\'></div>"); 138 $mouseTrap = jWin.parent().append($m).find(':last'); 139 $mouseTrap = $('.mousetrap', jWin.parent()); 140 $mouseTrap.css({ 141 width: sImg.outerWidth(), 142 height: sImg.outerHeight(), 143 top: 0, 144 left: 0, 145 position: 'absolute', 146 zIndex: 9999 147 }); 148 $mouseTrap.bind('mousemove', this, function (event) { 149 mx = event.pageX; 150 my = event.pageY; 151 }); 152 $mouseTrap.bind('mouseleave', this, function (event) { 153 cw = (sImg.outerWidth() / zoomImage.width) * opts.zoomWidth; 154 ch = (sImg.outerHeight() / zoomImage.height) * opts.zoomHeight; 155 if ((parseFloat($('body').css('width').replace('px', '')) < 980) || 156 (cw === sImg.outerWidth() && ch === sImg.outerWidth())) return; 157 clearTimeout(controlTimer); 158 if (lens) { 159 lens.fadeOut(299); 160 } 161 if ($tint) { 162 $tint.fadeOut(299); 163 } 164 if (softFocus) { 165 softFocus.fadeOut(299); 166 } 167 zoomDiv.fadeOut(300, function () { 168 ctx.fadedOut(); 169 }); 170 return false; 171 }); 172 $mouseTrap.bind('mouseenter', this, function (event) { 173 mx = event.pageX; 174 my = event.pageY; 175 zw = event.data; 176 if (zoomDiv) { 177 zoomDiv.stop(true, false); 178 zoomDiv.remove(); 179 } 180 var xPos = opts.adjustX, 181 yPos = opts.adjustY; 182 var siw = sImg.outerWidth(); 183 var sih = sImg.outerHeight(); 184 var w = opts.zoomWidth; 185 var h = opts.zoomHeight; 186 if (opts.zoomWidth == 'auto') { 187 w = siw; 188 } 189 if (opts.zoomHeight == 'auto') { 190 h = sih; 191 } 192 var appendTo = jWin.parent(); 193 switch (opts.position) { 194 case 'top': 195 yPos -= h; 196 break; 197 case 'right': 198 xPos += siw; 199 break; 200 case 'bottom': 201 yPos += sih; 202 break; 203 case 'left': 204 xPos -= w; 205 break; 206 case 'inside': 207 w = siw; 208 h = sih; 209 break; 210 default: 211 appendTo = $('#' + opts.position); 212 if (!appendTo.length) { 213 appendTo = jWin; 214 xPos += siw; 215 yPos += sih; 216 } else { 217 w = appendTo.innerWidth(); 218 h = appendTo.innerHeight(); 219 } 220 } 221 zoomDiv = appendTo.append(format('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:99;"></div>', xPos+4, yPos-4, w, h, zoomImage.src)).find(':last'); 222 zoomDiv = $('.cloud-zoom-big', appendTo); 223 cw = zoomImage.width > sImg.outerWidth() ? 224 sImg.outerWidth() / zoomImage.width * zoomDiv.width() : 225 sImg.outerWidth(); 226 ch = zoomImage.height > sImg.outerHeight() ? 227 sImg.outerHeight() / zoomImage.height * zoomDiv.height() : 228 sImg.outerHeight(); 229 if ((parseFloat($('body').css('width').replace('px', '')) < 980) || 230 (cw === sImg.outerWidth() && ch === sImg.outerHeight())) return; 231 232 if (sImg.attr('title') && opts.showTitle) { 233 zoomDiv.append(format('<div class="cloud-zoom-title">%0</div>', sImg.attr('title'))); 234 $('.cloud-zoom-title', zoomDiv).css('opacity', opts.titleOpacity); 235 } 236 if ($.browser && $.browser.msie && $.browser.version < 7) { 237 $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({ 238 position: "absolute", 239 left: xPos, 240 top: yPos, 241 zIndex: 99, 242 width: w, 243 height: h 244 }).insertBefore(zoomDiv); 245 } 246 zoomDiv.fadeIn(500); 247 // fix zoom-big position 248 var bodyWidth = $('body').width(); 249 var zOffset = zoomDiv.offset(); 250 if (zOffset && zOffset.left) { 251 if (zOffset.left + zoomDiv.outerWidth() > bodyWidth) { 252 var zLeft = zoomDiv.css('left'); 253 zoomDiv.css({'left': 'auto', 'right': zLeft}); 254 } else if (zOffset.left < 0) { 255 zoomDiv.css({'right': 'auto', 'left': zoomDiv.outerWidth()}); 256 } 257 } 258 if (lens) { 259 lens.remove(); 260 lens = null; 261 } 262 lens = jWin.append(format("<div class = 'cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>", cw, ch)).find(':last'); 263 lens = $('.cloud-zoom-lens', jWin); 264 $mouseTrap.css('cursor', lens.css('cursor')); 265 var noTrans = false;
266 if (opts.tint) { 267 //lens.css('background', 'url("' + sImg.attr('src') + '")'); не показÑваем Ñон Ð´Ð»Ñ Ð»Ð¸Ð½Ð·Ñ Ð¸Ð·-за пÑоблем пÑи ÑеÑÐ°Ð¹Ð·Ñ 268 //lens.css('background-size', sImg.outerWidth() + 'px auto'); 269 $tint = jWin.append(format('<div class="cloud-zoom-tint" style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />', sImg.outerWidth(), sImg.outerHeight(), opts.tint)).find(':last'); 270 $tint = $('.cloud-zoom-tint', jWin); 271 $tint.css('opacity', opts.tintOpacity); 272 noTrans = true; 273 $tint.fadeIn(500); 274 } 275 if (opts.softFocus) { 276 //lens.css('background', 'url("' + sImg.attr('src') + '")'); не показÑваем Ñон Ð´Ð»Ñ Ð»Ð¸Ð½Ð·Ñ Ð¸Ð·-за пÑоблем пÑи ÑеÑÐ°Ð¹Ð·Ñ 277 //lens.css('background-size', sImg.outerWidth() + 'px auto'); 278 jWin.append(format('<div class="cloud-zoom-soft" style="position:absolute;display:none;top:0px; left:0px; width:%0px; height:%1px;" />', sImg.outerWidth() - 2, sImg.outerHeight() - 2, opts.tint)); 279 softFocus = $('.cloud-zoom-soft', jWin); 280 softFocus.css('background', 'url("' + sImg.attr('src') + '")'); 281 softFocus.css('background-size', '100% 100%'); 282 //softFocus.css('opacity', 0.5); 283 noTrans = true; 284 softFocus.fadeIn(500); 285 } 286 if (!noTrans) { 287 lens.css('opacity', opts.lensOpacity); 288 } 289 if (opts.position !== 'inside') { 290 lens.fadeIn(500); 291 } 292 zw.controlLoop(); 293 return; 294 }); 295 }; 296 img1 = new Image(); 297 $(img1).load(function () { 298 ctx.init2(this, 0); 299 }); 300 img1.src = sImg.attr('src'); 301 img2 = new Image(); 302 $(img2).load(function () { 303 ctx.init2(this, 1); 304 }); 305 img2.src = jWin.attr('href'); 306 } 307 $.fn.CloudZoom = function (options) { 308 try { 309 document.execCommand("BackgroundImageCache", false, true) 310 } catch (e) {} 311 this.each(function () { 312 var relOpts, opts; 313 if ($(this).find('img').length > 0 && $(this).attr('href') !== '#'){ 314 var relArray = $(this).attr('rel').replace(/\'/g, '"').split(','); 315 relArray = $.map(relArray, function(value) { 316 var i = value.indexOf(':'), 317 parts = [value.slice(0, i), value.slice(i+1)]; 318 return '"' + $.trim(parts[0]) + '":' + $.trim(parts[1]); 319 }); 320 relOpts = $.parseJSON('{' + relArray.join(',') + '}'); 321 if ($(this).is('.cloud-zoom')) { 322 $(this).css({ 323 'position': 'relative', 324 'display': 'block' 325 }); 326 $('img', $(this)).css({ 327 'display': 'block' 328 }); 329 if ($(this).parent().attr('id') != 'wrap') { 330 $(this).wrap('<div id="wrap" style="top:0px;position:relative;"></div>') 331 } 332 opts = $.extend({}, $.fn.CloudZoom.defaults, options); 333 opts = $.extend({}, opts, relOpts); 334 $(this).data('zoom', new CloudZoom($(this), opts)); 335 } else if ($(this).is('.cloud-zoom-gallery')) { 336 opts = $.extend({}, relOpts, options); 337 $(this).data('relOpts', opts); 338 $(this).bind('click', $(this), function (event) { 339 var data = event.data.data('relOpts'); 340 $('#' + data.useZoom).data('zoom').destroy(); 341 $('#' + data.useZoom).attr('href', event.data.attr('href')); 342 $('#' + data.useZoom + ' img').attr('src', event.data.data('relOpts').smallImage); 343 $('#' + event.data.data('relOpts').useZoom).CloudZoom(); 344 return false;
345 }); 346 } 347 } 348 }); 349 return this; 350 }; 351 $.fn.CloudZoom.defaults = { 352 zoomWidth: "auto", 353 zoomHeight: "auto", 354 position: "right", 355 tint: "#aa00aa", 356 tintOpacity: "0.5", 357 lensOpacity: "0.5", 358 softFocus: false, 359 smoothMove: 3, 360 showTitle: true, 361 titleOpacity: "0.5", 362 adjustX: "0px", 363 adjustY: "0px" 364 }; 365}) (window._$, window._$);
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.