Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //iWebKit 6.0 Fullscreen + Slide + touch=hover
  2.  
  3.    
  4.     function hijackLinks() {
  5.  
  6.         $('a').live("click", function (e) {
  7.             e.preventDefault();
  8.             loadPage(e.target.href);            
  9.             $(this).addClass('click');
  10.            
  11.         });
  12.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {$('a').live("touchstart", function (e) {
  13.              direction = $(this).attr('class');
  14.             $(this).addClass('temp');
  15.              setTimeout(function () {
  16.                     $('.temp').addClass('click');
  17.                 }, 100);
  18.         });
  19.         $('a').live("touchmove", function (e) {
  20.             $('.temp').removeClass('temp');
  21.             setTimeout(function () {
  22.                     $('.click').removeClass('click');
  23.                 }, 1);})
  24.        
  25.             $('.click').live("touchend", function (e) {
  26.            
  27.            
  28.              setTimeout(function () {
  29.                     $('.click').removeClass('click');
  30.                 }, 1);})}
  31.                 else{
  32.          $('a').live("mouseenter", function (e) {
  33.             direction = $(this).attr('class');
  34.              $(this).addClass('click');})
  35.               $('a').live("mouseleave", function (e) {
  36.            
  37.              $(this).removeClass('click');})
  38.            
  39.                 }
  40.          
  41.     }
  42.    
  43.  
  44.     function loadPage(url) {
  45.        
  46.         if (url === undefined) {
  47.            
  48.             $('body').load('url', 'header:first,#content,footer', hijackLinks);
  49.              window.history.pushState(null, null, url);
  50.         } else {
  51.             $.get(url, function (data) {
  52.                 $('body').append(data);
  53.                 sm = $(window).width();
  54.                 sn = $(window).scrollTop();
  55.                
  56.              window.scrollTo(0,0);
  57.            
  58.              window.history.pushState(null, null, url);
  59.              
  60.              
  61.                 if (direction === "leftnav") {
  62.                     $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate( -" + sm + "px,0px)");
  63.                     footerheight = $('body>#content:last').outerHeight(false) + $('body>header:last').outerHeight(true);
  64.                     $('footer:last').css("top", footerheight);
  65.                     $('body>header,body>#content,footer').css("-webkit-transition-duration", "0.4s");
  66.                     $('body>header:first,body>#content:first,footer:first').css("-webkit-transform", "translate(" + sm + "px,0px)");
  67.                     $('body>header:last,body>#content:last,footer:last').css({"-webkit-transform": "translate(0,0)"});
  68.                 $('body>header:last a,body>header:last div,body>header:last h1').css({'-webkit-transition': 'opacity 0.4s linear','opacity':'1'});
  69.                 $('body>header:first a,body>header:first div,body>header:first h1').css({'-webkit-transition': 'opacity 0.4s linear','opacity':'0'});
  70.  
  71.                 }
  72.                 if (direction !== "leftnav") {
  73.                     $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate(" + sm + "px,0px)");
  74.                    
  75.                     footerheight = $('body>#content:last').outerHeight(false) + $('body>header:last').outerHeight(true);
  76.                     $('footer:last').css("top", footerheight);
  77.                     $('body>header,body>#content,footer').css("-webkit-transition-duration", "0.4s");
  78.                    
  79.                    
  80.                     $('body>header:first,body>#content:first,footer:first').css("-webkit-transform", "translate( -" + sm + "px,0px)");
  81.                     $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate(0,0)");
  82.                 $('body>header:last a,body>header:last div,body>header:last h1').css({'-webkit-transition': 'opacity 0.4s linear','opacity':'1'});
  83.                 $('body>header:first a,body>header:first div,body>header:first h1').css({'-webkit-transition': 'opacity 0.4s linear','opacity':'0'});
  84.                 }
  85.                
  86.                
  87.                
  88.                 setTimeout(function () {
  89.                     $('body>header:not(:last),body>footer:not(:last),body>#content:not(:last)').remove();
  90.                    
  91.                     $('body>header,body>footer,body>#content').removeAttr('style');
  92.                    
  93.                 },1000);
  94.                
  95.                
  96.  
  97.  
  98.  
  99.             });
  100.  
  101.  
  102.         }
  103.     }
  104.  
  105.  
  106.  
  107.     $(document).ready(function () {
  108.         loadPage();
  109.         window.addEventListener("popstate", function(e) {    
  110.         if (direction === leftnav) {
  111.     direction = rightnav;
  112. } else {
  113.     direction = leftnav;
  114. }
  115.        
  116.        
  117.         loadPage(location.pathname);});
  118.        
  119.        
  120.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement