Advertisement
ulfben

ZenPhoto preloading

Jul 29th, 2011
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Image preloading for ZenPhoto default theme. Just add to your image.php.
  2. Ulf Benjaminsson 2011-07-30 */
  3. jQuery(document).ready(function($) {
  4.     var $nextlink = $('.imgnext > a:first-child');
  5.     var nextURL = ($nextlink) ? $nextlink.attr('href') : '';
  6.     if(nextURL == ''){return;} 
  7.     $.get(nextURL, function(data, textStatus) {
  8.         if(textStatus !== "success"){return;}  
  9.         if(console){
  10.             var n = nextURL.length;
  11.             console.log('Preloaded: '+nextURL.substring(n, n-17));
  12.         }  
  13.         $nextlink.click(function(e) {
  14.             e.preventDefault();
  15.             if(history && (typeof history.pushState == 'function')){
  16.                 history.pushState({}, "", nextURL);
  17.             }
  18.             document.open();
  19.             document.write(data);
  20.             document.close();
  21.         }) 
  22.     });
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement