1;(function($, w) { 2 w.HappySimplaMagnify = function magnify(selector, zoom) { 3 4 var img, glass, w, h, bw; 5 //img = document.getElementById(imgID); 6 img = selector; 7 8 /* Create magnifier glass: */ 9 glass = document.createElement("DIV"); 10 glass.setAttribute("class", "ha-img-magnifier-glass"); 11 12 /* Insert magnifier glass: */ 13 img.parentElement.insertBefore(glass, img); 14 15 /* Set background properties for the magnifier glass: */ 16 glass.style.backgroundImage = "url('" + img.src + "')"; 17 glass.style.backgroundRepeat = "no-repeat"; 18 glass.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px"; 19 bw = 3; 20 w = glass.offsetWidth / 2; 21 h = glass.offsetHeight / 2; 22 23 /* Execute a function when someone moves the magnifier glass over the image: */ 24 glass.addEventListener("mousemove", moveMagnifier); 25 img.addEventListener("mousemove", moveMagnifier); 26 27 /*and also for touch screens:*/ 28 glass.addEventListener("touchmove", moveMagnifier); 29 img.addEventListener("touchmove", moveMagnifier); 30 31 function moveMagnifier(e) { 32 var pos, x, y; 33 /* Prevent any other actions that may occur when moving over the image */ 34 e.preventDefault(); 35 /* Get the cursor's x and y positions: */ 36 pos = getCursorPos(e); 37 x = pos.x; 38 y = pos.y; 39 /* Prevent the magnifier glass from being positioned outside the image: */ 40 if (x > img.width - (w / zoom)) {x = img.width - (w / zoom);} 41 if (x < w / zoom) {x = w / zoom;} 42 if (y > img.height - (h / zoom)) {y = img.height - (h / zoom);} 43 if (y < h / zoom) {y = h / zoom;} 44 /* Set the position of the magnifier glass: */ 45 glass.style.left = (x - w) + "px"; 46 glass.style.top = (y - h) + "px"; 47 /* Display what the magnifier glass "sees": */ 48 glass.style.backgroundPosition = "-" + ((x * zoom) - w + bw) + "px -" + ((y * zoom) - h + bw) + "px"; 49 } 50 51 function getCursorPos(e) { 52 var a, x = 0, y = 0; 53 e = e || window.event; 54 /* Get the x and y positions of the image: */ 55 a = img.getBoundingClientRect(); 56 /* Calculate the cursor's x and y coordinates, relative to the image: */ 57 x = e.pageX - a.left; 58 y = e.pageY - a.top; 59 /* Consider any page scrolling: */ 60 x = x - window.pageXOffset; 61 y = y - window.pageYOffset; 62 return {x : x, y : y}; 63 } 64 65 } 66}(jQuery, 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.