Guest User

Untitled

a guest
Jan 10th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var $iframe = $('.html_photoset iframe');
  2.  
  3. $iframe.ready(function() {
  4.   tryChange = setInterval(function() {
  5.     $contents = $iframe.contents();
  6.     $rows = $contents.find('.photoset_row');
  7.  
  8.     if ($rows.length) {
  9.       clearInterval(tryChange);
  10.     } else {
  11.       return;
  12.     }
  13.  
  14.     $rows.width('540px').each(function() {
  15.       $row = $(this);
  16.       height = $row.height();
  17.       $(this).height(height / 700 * 540);
  18.  
  19.       $images = $row.find('img');
  20.       if ($images.length == 1) $images.width('540px');
  21.       if ($images.length == 2) $images.width('268px');
  22.       if ($images.length == 3) $images.width('177px').eq(1).width(
  23.         '178px');
  24.  
  25.       $links = $row.find('a');
  26.       if ($links.length > 2) $links.css('margin-left', '4px').eq(
  27.         0).css('margin-left', '0px');
  28.     }).css('margin-top', '4px').eq(0).css('margin-top', '0px');
  29.  
  30.     setTimeout(function() {
  31.       finalHeight = $contents.find('body').height();
  32.       $iframe.attr('height', finalHeight);
  33.     }, 1000);
  34.   }, 100);
  35. });
  36.  
  37. $iframe.ready(function() {
  38.   var fixZoom = setInterval(function() {
  39.     var $contents = $iframe.contents();
  40.     var $photoset = $contents.find('.photoset');
  41.     var zoom = $photoset.css('zoom');
  42.     var transform = $photoset.css('transform');
  43.     var $rows = $photoset.find('.photoset_row');
  44.     var zoomSet = zoom != null && zoom != "" && zoom < 1;
  45.     var transformSet = transform != null && transform != "" &&
  46.       transform != "none";
  47.     $photoset.css('zoom', '').css('transform', '');
  48.  
  49.     // Also fix retina.
  50.     var $body = $contents.find('body');
  51.     $body.prepend(
  52.       "<style>\
  53.            img, canvas {\
  54.                image-rendering: optimizeSpeed;\
  55.                image-rendering: -moz-crisp-edges;\
  56.                image-rendering: -o-crisp-edges;\
  57.                image-rendering: -webkit-optimize-contrast;\
  58.                image-rendering: pixelated;\
  59.                image-rendering: optimize-contrast;\
  60.                -ms-interpolation-mode: nearest-neighbor\
  61.            }</style>"
  62.     );
  63.  
  64.     if (zoomSet || transformSet) clearInterval(fixZoom);
  65.   }, 100);
  66. });
Advertisement
Add Comment
Please, Sign In to add comment