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 ($) { 11 12 // Get the path of executing script. 13 var scripts = document.getElementsByTagName("script"); 14 var last = scripts[scripts.length-1].src.lastIndexOf('/'); 15 var scriptPath = scripts[scripts.length-1].src.slice(0,last); 16 17 $(document).ready(function () { 18 //$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom(); 19 }); 20 21 function format(str) { 22 for (var i = 1; i < arguments.length; i++) { 23 str = str.replace('%' + (i - 1), arguments[i]); 24 } 25 return str; 26 } 27 28 function CloudZoom(jWin, opts) { 29 30 var sImg = $('img', jWin); 31 var img1; 32 var img2; 33 var zoomDiv = null; 34 var $mouseTrap = null; 35 var lens = null; 36 var $tint = null; 37 var softFocus = null; 38 var $ie6Fix = null; 39 var zoomImage; 40 var controlTimer = 0; 41 var cw, ch; 42 var destU = 0; 43 var destV = 0; 44 var currV = 0; 45 var currU = 0; 46 var filesLoaded = 0; 47 var mx, 48 my; 49 var ctx = this, zw; 50 // Display an image loading message. This message gets deleted when the images have loaded and the zoom init function is called. 51 // We add a small delay before the message is displayed to avoid the message flicking on then off again virtually immediately if the 52 // images load really fast, e.g. from the cache. 53 //var ctx = this; 54 setTimeout(function () { 55 if ($mouseTrap === null) { 56 var w = jWin.width(); 57 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))); 58 $('cloud-zoom-loading', jWin.parent()).css('opacity', 0.5) 59 } 60 }, 200); 61 62 63 var ie6FixRemove = function () { 64 65 if ($ie6Fix !== null) { 66 $ie6Fix.remove(); 67 $ie6Fix = null; 68 } 69 }; 70 71 // Removes cursor, tint layer, blur layer etc. 72 this.removeBits = function () { 73 //$mouseTrap.unbind(); 74 if (lens) { 75 lens.remove(); 76 lens = null; 77 } 78 if ($tint) { 79 $tint.remove(); 80 $tint = null; 81 } 82 if (softFocus) { 83 softFocus.remove(); 84 softFocus = null; 85 } 86 ie6FixRemove(); 87 88 $('.cloud-zoom-loading', jWin.parent()).remove(); 89 }; 90 91 92 this.destroy = function () { 93 jWin.data('zoom', null); 94 95 if ($mouseTrap) { 96 $mouseTrap.unbind(); 97 $mouseTrap.remove(); 98 $mouseTrap = null; 99 } 100 if (zoomDiv) { 101 zoomDiv.remove(); 102 zoomDiv = null; 103 } 104 //ie6FixRemove(); 105 this.removeBits(); 106 // DON'T FORGET TO REMOVE JQUERY 'DATA' VALUES 107 }; 108 109 110 // This is called when the zoom window has faded out so it can be removed. 111 this.fadedOut = function () { 112 113 if (zoomDiv) { 114 zoomDiv.remove(); 115 zoomDiv = null; 116 } 117 this.removeBits(); 118 //ie6FixRemove(); 119 }; 120 121 this.controlLoop = function () { 122 if (lens) { 123 var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0; 124 var y = (my - sImg.offset().top - (ch * 0.5)) >> 0; 125 126 if (x < 0) { 127 x = 0; 128 } 129 else if (x > (sImg.width() - cw)) { 130 x = (sImg.width() - cw); 131 } 132 if (y < 0) { 133 y = 0; 134 } 135 else if (y > (sImg.height() - ch)) { 136 y = (sImg.height() - ch); 137 } 138 139 lens.css({ 140 left: x, 141 top: y 142 }); 143 lens.css('background-position', (-x) + 'px ' + (-y) + 'px'); 144 145 destU = (((x) / sImg.width()) * zoomImage.width) >> 0;
146 destV = (((y) / sImg.height()) * zoomImage.height) >> 0; 147 currU += (destU - currU) / opts.smoothMove; 148 currV += (destV - currV) / opts.smoothMove; 149 150 zoomDiv.css('background-position', (-(currU >> 0) + 'px ') + (-(currV >> 0) + 'px')); 151 } 152 controlTimer = setTimeout(function () { 153 ctx.controlLoop(); 154 }, 30); 155 }; 156 157 this.init2 = function (img, id) { 158 159 filesLoaded++; 160 //console.log(img.src + ' ' + id + ' ' + img.width); 161 if (id === 1) { 162 zoomImage = img; 163 } 164 //this.images[id] = img; 165 if (filesLoaded === 2) { 166 this.init(); 167 } 168 }; 169 170 /* Init function start. */ 171 this.init = function () { 172 // Remove loading message (if present); 173 $('.cloud-zoom-loading', jWin.parent()).remove(); 174 175 176 /* Add a box (mouseTrap) over the small image to trap mouse events. 177 It has priority over zoom window to avoid issues with inner zoom. 178 We need the dummy background image as IE does not trap mouse events on 179 transparent parts of a div. 180 */ 181 var $m = $("<div class='mousetrap'></div>"); 182 $mouseTrap = jWin.parent().append($m).find(':last'); 183 $mouseTrap = $('.mousetrap',jWin.parent()); 184 $mouseTrap.css({ 185 width:sImg.width(), 186 height:sImg.height(), 187 top:0, 188 left:0, 189 position:'absolute', 190 zIndex:100 191 });
192 ////////////////////////////////////////////////////////////////////// 193 /* Do as little as possible in mousemove event to prevent slowdown. */ 194 $mouseTrap.bind('mousemove touchmove', this, function (event) { 195 // Just update the mouse position 196 mx = event.pageX; 197 my = event.pageY; 198 199 if (event.type == "touchmove") 200 { 201 var touch = event.originalEvent.touches[0]; 202 mx = touch.pageX, 203 my = touch.pageY 204 205 event.preventDefault(); 206 } 207 }).bind('click', this, function (event) { 208 event.preventDefault(); 209 return false; 210 }); 211 ////////////////////////////////////////////////////////////////////// 212 $mouseTrap.bind('mouseleave touchend', this, function (event) { 213 clearTimeout(controlTimer); 214 //event.data.removeBits(); 215 if(lens) { 216 lens.fadeOut(299); 217 } 218 if($tint) { 219 $tint.fadeOut(299); 220 } 221 if(softFocus) { 222 softFocus.fadeOut(299); 223 } 224 zoomDiv.fadeOut(300, function () { 225 ctx.fadedOut(); 226 }); 227 return false; 228 });
229 ////////////////////////////////////////////////////////////////////// 230 $mouseTrap.bind('mouseenter touchstart', this, function (event) { 231 mx = event.pageX; 232 my = event.pageY; 233 zw = event.data; 234 if (zoomDiv) { 235 zoomDiv.stop(true, false); 236 zoomDiv.remove(); 237 } 238 239 var xPos = opts.adjustX, 240 yPos = opts.adjustY; 241 242 var siw = sImg.width(); 243 var sih = sImg.height(); 244 245 var w = opts.zoomWidth; 246 var h = opts.zoomHeight; 247 if (opts.zoomWidth == 'auto') { 248 w = siw; 249 } 250 if (opts.zoomHeight == 'auto') { 251 h = sih; 252 } 253 //$('#info').text( xPos + ' ' + yPos + ' ' + siw + ' ' + sih ); 254 var appendTo = jWin.parent(); // attach to the wrapper 255 switch (opts.position) { 256 case 'top': 257 yPos -= h; // + opts.adjustY; 258 break; 259 case 'right': 260 xPos += siw; // + opts.adjustX; 261 break; 262 case 'bottom': 263 yPos += sih; // + opts.adjustY; 264 break; 265 case 'left': 266 xPos -= w; // + opts.adjustX; 267 break; 268 case 'inside': 269 w = siw; 270 h = sih; 271 break; 272 // All other values, try and find an id in the dom to attach to. 273 default: 274 appendTo = $('#' + opts.position); 275 // If dom element doesn't exit, just use 'right' position as default. 276 if (!appendTo.length) { 277 appendTo = jWin; 278 xPos += siw; //+ opts.adjustX; 279 yPos += sih; // + opts.adjustY; 280 } else { 281 w = appendTo.innerWidth(); 282 h = appendTo.innerHeight(); 283 } 284 } 285 286 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, yPos, w, h, zoomImage.src)).find(':last'); 287 zoomDiv = $('.cloud-zoom-big',appendTo); 288 // Add the title from title tag. 289 if (sImg.attr('title') && opts.showTitle) { 290 zoomDiv.append(format('<div class="cloud-zoom-title">%0</div>', sImg.attr('title'))); 291 $('.cloud-zoom-title', zoomDiv).css('opacity', opts.titleOpacity); 292 } 293 294 // Fix ie6 select elements wrong z-index bug. Placing an iFrame over the select element solves the issue... 295 296 /* 297 if ($.browser.msie && $.browser.version < 7) { 298 $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({ 299 position: "absolute", 300 left: xPos, 301 top: yPos, 302 zIndex: 99, 303 width: w, 304 height: h 305 }).insertBefore(zoomDiv); 306 } 307 */ 308 309 zoomDiv.fadeIn(500); 310 311 if (lens) { 312 lens.remove(); 313 lens = null; 314 } /* Work out size of cursor */ 315 cw = (sImg.width() / zoomImage.width) * zoomDiv.width(); 316 ch = (sImg.height() / zoomImage.height) * zoomDiv.height(); 317 318 // Attach mouse, initially invisible to prevent first frame glitch 319 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'); 320 lens = $('.cloud-zoom-lens',jWin); 321 $mouseTrap.css('cursor', lens.css('cursor')); 322 323 var noTrans = false;
324 325 // Init tint layer if needed. (Not relevant if using inside mode) 326 if (opts.tint) { 327 lens.css('background', 'url("' + sImg.attr('src') + '")'); 328 $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.width(), sImg.height(), opts.tint)).find(':last'); 329 $tint = $('.cloud-zoom-tint',jWin); 330 331 $tint.css('opacity', opts.tintOpacity); 332 noTrans = true; 333 $tint.fadeIn(500); 334 335 } 336 if (opts.softFocus) { 337 lens.css('background', 'url("' + sImg.attr('src') + '")'); 338 jWin.append(format('<div class="cloud-zoom-soft" style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />', sImg.width() - 2, sImg.height() - 2, opts.tint)); 339 softFocus = $('.cloud-zoom-soft',jWin); 340 softFocus.css('background', 'url("' + sImg.attr('src') + '")'); 341 softFocus.css('opacity', 0.5); 342 noTrans = true; 343 softFocus.fadeIn(500); 344 } 345 346 if (!noTrans) { 347 lens.css('opacity', opts.lensOpacity); 348 } 349 if ( opts.position !== 'inside' ) { 350 lens.fadeIn(500); 351 } 352 353 // Start processing. 354 zw.controlLoop(); 355 356 return; // Don't return false here otherwise opera will not detect change of the mouse pointer type. 357 }); 358 }; 359 360 img1 = new Image(); 361 $(img1).load(function () { 362 ctx.init2(this, 0); 363 }); 364 img1.src = sImg.attr('src'); 365 366 img2 = new Image(); 367 $(img2).load(function () { 368 ctx.init2(this, 1); 369 }); 370 img2.src = jWin.attr('href'); 371 } 372 373 $.fn.CloudZoom = function (options) { 374 // IE6 background image flicker fix 375 try { 376 document.execCommand("BackgroundImageCache", false, true); 377 } catch (e) {} 378 this.each(function () { 379 var relOpts, opts; 380 // Hmm...eval...slap on wrist. 381 rel = $(this).attr('data-zoom').replace(/\:([^,$]+)/g,':\'$1\'');//add single quotes to strings to not break below eval 382 eval('var a = {' + rel + '}'); 383 relOpts = a; 384 if ($(this).is('.cloud-zoom')) { 385 $(this).css({ 386 'position': 'relative', 387 'display': 'block' 388 }); 389 $('img', $(this)).css({ 390 'display': 'block' 391 }); 392 // Wrap an outer div around the link so we can attach things without them becoming part of the link. 393 // But not if wrap already exists. 394 if ($(this).parent().attr('id') != 'wrap') { 395 $(this).wrap('<div id="wrap" style="top:0px;z-index:1;position:relative;"></div>'); 396 } 397 opts = $.extend({}, $.fn.CloudZoom.defaults, options); 398 opts = $.extend({}, opts, relOpts); 399 $(this).data('zoom', new CloudZoom($(this), opts)); 400 401 } else if ($(this).is('.cloud-zoom-gallery')) { 402 opts = $.extend({}, relOpts, options); 403 $(this).data('relOpts', opts); 404 405 $(this).bind('click', $(this), function (event) { 406 var data = event.data.data('relOpts'); 407 // Destroy the previous zoom 408 $('#' + data.useZoom).data('zoom').destroy(); 409 // Change the biglink to point to the new big image. 410 $('#' + data.useZoom).attr('href', event.data.attr('href')); 411 // Change the small image to point to the new small image. 412 $('#' + data.useZoom + ' img').attr('src', event.data.data('relOpts').smallImage); 413 // Init a new zoom with the new images. 414 $('#' + event.data.data('relOpts').useZoom).CloudZoom(); 415 416 417 $(this).parents('.owl-item').find('li').addClass('current'); 418 419 $(this).parents('.owl-item').siblings().find('li').removeClass('current'); 420 421 var container=$(this).parents('.product-view').find(".product-image .cloud-zoom img") 422 container.each(function(i){ 423 var img = $(this); 424 var realWidth; 425 var realHeight; 426 $("<img/>").attr("src", $(img).attr("src")).load(function() { 427 realWidth = this.width; 428 429 if(realWidth<container.width()){ 430 $('.product-view .product-image').addClass('zoom_remove') 431 432 } 433 else{ 434 $('.product-view .product-image').removeClass('zoom_remove') 435 } 436 }); 437 }); 438 439 return false;
440 }); 441 } 442 }); 443 return this; 444 }; 445 446 447 448})(jQuery); 449 450 451 452function nico_cloud_zoom() 453{ 454 $.fn.CloudZoom.defaults = 455 { 456 zoomWidth:"auto", 457 zoomHeight:"auto", 458 position:"inside", 459 adjustX:0, 460 adjustY:0, 461 adjustY:"", 462 tintOpacity:0.5, 463 lensOpacity:0.5, 464 titleOpacity:0.5, 465 smoothMove:3, 466 showTitle:false 467 }; 468 469 470 //add a small delay when loaded trough quickview 471 if (jQuery("#cboxLoadedContent .container").length = 0) 472 $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom(); 473 else setTimeout(function () 474 { 475 $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom(); 476 }, 1000); 477 478 479 480} 481 482$(function(){ 483 var containeraa=$(".product-view .product-image .cloud-zoom img") 484 containeraa.each(function(i){ 485 var img = $(this); 486 var realWidth; 487 var realHeight; 488 $("<img/>").attr("src", $(img).attr("src")).load(function() { 489 realWidth = this.width; 490 491 if(realWidth<containeraa.width()){ 492 $('.product-view .product-image').addClass('zoom_remove') 493 494 } else{ 495 $('.product-view .product-image').removeClass('zoom_remove') 496 } 497 }); 498 }); 499 })
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.