home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_4190 < prev    next >
Encoding:
Text File  |  2010-01-28  |  1.1 KB  |  40 lines

  1. /*
  2.  * images management
  3.  * Copyright 2008 Kovid Goyal
  4.  * License: GNU GPL v3
  5.  */
  6.  
  7. function scale_images() {
  8.     $("img:visible").each(function() {
  9.         var offset = $(this).offset();
  10.         //window.py_bridge.debug(window.getComputedStyle(this, '').getPropertyValue('max-width'));
  11.         $(this).css("max-width", (window.innerWidth-offset.left-5)+"px");
  12.         $(this).css("max-height", (window.innerHeight-5)+"px");
  13.     });
  14. }
  15.  
  16. function setup_image_scaling_handlers() {
  17.    scale_images();
  18.    $(window).resize(function(){
  19.         scale_images();
  20.    });
  21. }
  22.  
  23. function extract_svged_images() {
  24.     $("svg").each(function() {
  25.         var children = $(this).children("img");
  26.         if (children.length == 1) {
  27.             var img = $(children[0]);
  28.             var href = img.attr('xlink:href');
  29.             if (href != undefined) {
  30.                 $(this).replaceWith('<div style="text-align:center; margin: 0; padding: 0"><img style="height: 98%" alt="SVG Image" src="' + href +'"></img></div>');
  31.             }
  32.         }
  33.     });
  34. }
  35.  
  36. $(document).ready(function() {
  37.    //extract_svged_images();
  38. });
  39.  
  40.