Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

djaxified

  • Loading branch information...
commit 58aadde224d74f8aaa3266a4bd76e961f2888ada 1 parent 31fc5e7
@beezee authored
View
2  archive.php
@@ -4,7 +4,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col620 left first clearfix" role="main">
<?php if (is_category()) { ?>
<h1 class="archive_title h2">
View
2  author.php
@@ -4,7 +4,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col620 left first clearfix" role="main">
<h1 class="archive_title h2">
<span><?php _e("Posts By:", "bonestheme"); ?></span>
View
14 header.php
@@ -31,13 +31,23 @@
<!--[if (lt IE 9) & (!IEMobile)]>
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/library/css/ie.css">
<![endif]-->
-
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/library/js/libs/jquery.djax.js"></script>
+ <script type="text/javascript">
+ jQuery('document').ready(function($) {
+ $('body').djax('.updatable', ['wp-admin', 'wp-login', '?s=']);
+ $(window).bind('djaxLoad', function(e, data) {
+ console.log('triggered');
+ console.log(data);
+ });
+ });
+ </script>
</head>
<body <?php body_class(); ?>>
<div id="container">
-
+The time you last loaded this whole site is <?php echo date('r'); ?>
<header role="banner" class="header">
<div id="inner-header" class="wrap clearfix">
View
2  index.php
@@ -4,7 +4,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col620 left first clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
View
68 library/js/libs/jquery.djax.js
@@ -0,0 +1,68 @@
+(function($, exports) {
+
+ $.fn.djax = function(selector, exceptions) {
+ if (!history.pushState) return $(this);
+
+ var self = this;
+
+ window.history.replaceState({'url': window.location.href, 'title' : $('title').text()}, $('title').text(), window.location.href);
+
+ var blockSelector = selector;
+
+ var excludes = (exceptions && exceptions.length) ? exceptions : [];
+
+ self.navigate = function(url, add) {
+ var blocks = $(blockSelector);
+ $.get(url, function(response) {
+ var result = $('"'+response+'"');
+ if (add) window.history.pushState({'url': url, 'title' : $(result).filter('title').text()}, $(result).filter('title').text(), url);
+ else window.history.replaceState({'url': url, 'title' : $(result).filter('title').text()}, $(result).filter('title').text(), url);
+ $('title').text($(result).filter('title').text());
+ var newBlocks = [];
+ var newBlocks = $(result).find(blockSelector);
+ blocks.each(function() {
+ var id = '"#'+$(this).attr('id')+'"';
+ var newBlock = newBlocks.filter(id);
+ var block = $(this);
+ if (newBlock.length) {
+ if (block.html() != newBlock.html()) block.replaceWith(newBlock);
+ } else block.remove();
+ });
+ $.each(newBlocks, function() {
+ var newBlock = $(this);
+ var id = '#'+$(this).attr('id');
+ if (!$(id).length) {
+ var before = $(result).find(id).prev();
+ if (before.length) { var beforeID = '#'+ before.attr('id'); newBlock.insertAfter(beforeID); }
+ else { var parentID = '#' + newBlock.parent().attr('id'); newBlock.prependTo(parentID); }
+ }
+ lastBlock = blocks.filter(id);
+ });
+ $('a').filter(function() { return this.hostname == location.hostname; }).addClass('dJAX_internal');
+ $(window).trigger('djaxLoad', [{'url': url, 'title' : $(result).filter('title').text()}]);
+ });
+ }
+
+ $(this).find('a').filter(function() { return this.hostname == location.hostname; }).addClass('dJAX_internal');
+
+
+ $('a.dJAX_internal').live('click', function(e) {
+ var link = $(this);
+ var exception = false;
+ $.each(excludes, function(k, x) {
+ if (link.attr('href').indexOf(x) != -1) exception = true;
+ if (window.location.href.indexOf(x) != -1) exception = true;
+ });
+ if (exception) return;
+ e.preventDefault();
+ self.navigate(link.attr('href'), true);
+ });
+
+ $(window).bind('popstate', function(event){
+ var popped = false;
+ self.navigate(event.originalEvent.state.url);
+ });
+
+ }
+
+})(jQuery, window);
View
4 page-custom.php
@@ -10,7 +10,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col740 left first clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
@@ -57,8 +57,6 @@
<?php endif; ?>
</div> <!-- end #main -->
-
- <?php get_sidebar(); // sidebar 1 ?>
</div> <!-- end #inner-content -->
View
2  page.php
@@ -4,7 +4,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col620 left first clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
View
2  sidebar.php
@@ -1,4 +1,4 @@
- <div id="sidebar1" class="sidebar col300 right last clearfix" role="complementary">
+ <div id="sidebar1" class="updatable sidebar col300 right last clearfix" role="complementary">
<?php get_search_form(); ?>
View
2  single.php
@@ -4,7 +4,7 @@
<div id="inner-content" class="wrap clearfix">
- <div id="main" class="col620 left first clearfix" role="main">
+ <div id="main" class="updatable col620 left first clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Please sign in to comment.
Something went wrong with that request. Please try again.