/** * @file * A JavaScript file for the theme. * * In order for this JavaScript to be loaded on pages, see the instructions in * the README.txt next to this file. */ // JavaScript should be made compatible with libraries other than jQuery by // wrapping it with an "anonymous closure". See: // - https://drupal.org/node/1446420 // - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth (function ($, Drupal, window, document, undefined) { // To understand behaviors, see https://drupal.org/node/756722#behaviors Drupal.behaviors.ScaleImgHover = { attach: function(context, settings) { $(window).on('load', function(event) { var $el = $(".view-projekty .view-content .views-row .views-field-field-image-project"); var width = $el.width(); var height = $el.height(); var Nwidth = width * 1.3; var NHeight = height * 1.3; var marginT = (Nwidth - width)/2; var marginL = (NHeight - height)/2; $el.hover(function() { $(this).find('img').stop(true,true).animate({"width": Nwidth+"px", "height": NHeight+"px", "margin-top": (-marginT)+"px", "margin-left": (-marginL)+"px" },500); }, function() { $(this).find('img').stop(true,true).animate({"width": width+"px", "height": height+"px", "margin": "0 0 0 0"},500); }); }); } }; })(jQuery, Drupal, this, this.document);