User:DrTrigon/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// Show little face-icons (cf. [[MediaWiki:FileContentsByBot.js]])
$(function() {
 $('div.bot-Faces-Position-icon').each(function(i, el) {
  var $el = $(el),                                     // turn DOM-node into jQuery-object (array-like-object)
      $scaleDiv = $el.children('div:first'),           // find scale-div
      $img = $scaleDiv.find('a.image > img'),          // find image
      ratio = parseFloat($scaleDiv.attr('class'), 10); // Making explicit we want a float
 
  // Prevent running twice
  if ($el.is(':visible')) return false;
  // Scaling
  $img.width($img.width()*ratio);
  $img.height($img.height()*ratio);
 }).show(); // Finally show the image
})