Advertisement
Guest User

AJAX for Wordpress

a guest
Jun 3rd, 2012
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //Ajax loader
  2. jQuery(document).ready(function($) {
  3. var $contentLoader = $("#display"),
  4. siteUrl = "http://" + top.location.host.toString(),
  5. url = '';
  6. $(document).delegate("a[href^='" + siteUrl + "']:not([href*='/wp-admin/']):not([href*='/blog/']):not([href*='/tag/']):not([href*='/wp-login.php']):not([href$='/feed/']):not([href*='/vs/index.php']):not([href*='/#/'])", "click", function() {
  7. location.hash = this.pathname;
  8. return false;
  9. });
  10.  
  11. $("#searchform").submit(function(e) {
  12. location.hash = '?s=' + $("#s").val();
  13. e.preventDefault();
  14. });
  15. $(window).bind('hashchange', function() {
  16. url = window.location.hash.substring(1);
  17. if (!url) {
  18. return;
  19. }
  20. url = url + " .load";
  21. $contentLoader.animate({
  22. opacity: "0"
  23. })/* .html('Loading') */.load(url, function() {
  24. $('html, body').animate({
  25. scrollTop: 100
  26. }, 200, function() {
  27. $("#content_slider").delay(100).slideDown(200, function() {
  28. $contentLoader.delay(1000).animate({
  29. opacity: "1"
  30. }, 250);
  31. });
  32. });
  33. });
  34. });
  35. $(window).trigger('hashchange');
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement