/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ if(typeof Product=='undefined') { var Product = {}; } /********************* IMAGE ZOOMER ***********************/ Product.Zoom = Class.create(); /** * Image zoom control * * @author Magento Core Team */ Product.Zoom.prototype = { initialize: function(imageEl, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){ this.containerEl = $(imageEl).parentNode; this.imageEl = $(imageEl); this.handleEl = $(handleEl); this.trackEl = $(trackEl); this.hintEl = $(hintEl); this.containerDim = Element.getDimensions(this.containerEl); this.imageDim = Element.getDimensions(this.imageEl); this.imageDim.ratio = this.imageDim.width/this.imageDim.height; this.floorZoom = 1; if (this.imageDim.width > this.imageDim.height) { this.ceilingZoom = this.imageDim.width / this.containerDim.width; } else { this.ceilingZoom = this.imageDim.height / this.containerDim.height; } if (this.imageDim.width <= this.containerDim.width && this.imageDim.height <= this.containerDim.height) { this.trackEl.up().hide(); this.hintEl.hide(); this.containerEl.removeClassName('product-image-zoom'); return; } this.imageX = 0; this.imageY = 0; this.imageZoom = 1; this.sliderSpeed = 0; this.sliderAccel = 0; this.zoomBtnPressed = false; this.showFull = false; this.selects = document.getElementsByTagName('select'); this.draggable = new Draggable(imageEl, { starteffect:false, reverteffect:false, endeffect:false, snap:this.contain.bind(this) }); this.slider = new Control.Slider(handleEl, trackEl, { axis:'horizontal', minimum:0, maximum:Element.getDimensions(this.trackEl).width, alignX:0, increment:1, sliderValue:0, onSlide:this.scale.bind(this), onChange:this.scale.bind(this) }); this.scale(0); Event.observe(this.imageEl, 'dblclick', this.toggleFull.bind(this)); Event.observe($(zoomInEl), 'mousedown', this.startZoomIn.bind(this)); Event.observe($(zoomInEl), 'mouseup', this.stopZooming.bind(this)); Event.observe($(zoomInEl), 'mouseout', this.stopZooming.bind(this)); Event.observe($(zoomOutEl), 'mousedown', this.startZoomOut.bind(this)); Event.observe($(zoomOutEl), 'mouseup', this.stopZooming.bind(this)); Event.observe($(zoomOutEl), 'mouseout', this.stopZooming.bind(this)); }, toggleFull: function () { this.showFull = !this.showFull; //TODO: hide selects for IE only for (i=0; ixMin ? xMin : x; x = xyMin ? yMin : y; y = y