UNPKG

coolzoom

Version:

Coolzoom is a jQuery plugin for displaying enlarged images on webpages. Coolzoom works on desktop, mobiles and tablets.

122 lines (104 loc) 4.1 kB
$(document).ready(function () { 'use strict'; var lic, $lic, $download; function htmlEncode(value) { return $('<div/>').text(value).html(); } $(function() { var $pre, code; $pre = $('pre'); $pre.each(function(){ var $this = $(this); code = htmlEncode($this.html()); $this.html(code); }); }); // License lic = 'Copyright (c) 2015 Patrice THIMOTHEE\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.'; $lic = $('.button-license'); $lic.attr('data-title', 'License'); $lic.attr('data-content', lic.replace(/\n/g, '<br />')); // Number of download $download = $('.download-link'); $download.attr('data-title', 'Thank you'); $download.attr('data-content', "Thank you for downloading CoolZoom"); // Smooth scroll $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); // Enable zoom on pictures $('img.mycoolzoom.zoom-standard').CoolZoom({ magnifier: {opacity: 0.8}, zoomArea: { animationSpeed: 1, fadeAnimationSpeed: 1, target: 'popup', width: '200px', height: '200px' }, debug: true }); $('img.mycoolzoom').eq(1).CoolZoom({ magnifier: {opacity: 0.4}, zoomArea: { animationSpeed: 300, fadeAnimationSpeed: 200, width: '240px', height: '160px' }, debug: true }); $('img.mycoolzoom').eq(2).CoolZoom({ magnifier: {opacity: 0.4}, zoomArea: { animationSpeed: 1, fadeAnimationSpeed: 1 }, debug: true, click: function(){ $('#myAlert').modal(); // alert('clicked'); return false; } }); $('img.mycoolzoom.zoom-lens').CoolZoom({ magnifier: { shape: 'round', position: '-70px', size: '200px' }, zoomedImage: { zoomMax: 12, initialZoomValue: 4, zoomIncrease: 1 }, text: { maskValue: '%%%', zoomApplied: 'x%%%', maxReached: 'x%%%', missingImage: 'Zoom unavailable' } }); $('img.mycoolzoom').eq(4).CoolZoom({ zoomArea: { target: '.demo', persistentZoom: true } }); $('img.mycoolzoom').eq(5).CoolZoom(); });