Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

djaxified

commit 58aadde224d74f8aaa3266a4bd76e961f2888ada 1 parent 31fc5e7
beezee authored February 19, 2012
2  archive.php
@@ -4,7 +4,7 @@
4 4
 			
5 5
 				<div id="inner-content" class="wrap clearfix">
6 6
 			
7  
-					<div id="main" class="col620 left first clearfix" role="main">
  7
+					<div id="main" class="updatable col620 left first clearfix" role="main">
8 8
 					
9 9
 						<?php if (is_category()) { ?>
10 10
 							<h1 class="archive_title h2">
2  author.php
@@ -4,7 +4,7 @@
4 4
 			
5 5
 				<div id="inner-content" class="wrap clearfix">
6 6
 			
7  
-					<div id="main" class="col620 left first clearfix" role="main">
  7
+					<div id="main" class="updatable col620 left first clearfix" role="main">
8 8
 					
9 9
 						<h1 class="archive_title h2">
10 10
 							<span><?php _e("Posts By:", "bonestheme"); ?></span> 
14  header.php
@@ -31,13 +31,23 @@
31 31
 		<!--[if (lt IE 9) & (!IEMobile)]>
32 32
     		<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/library/css/ie.css">	
33 33
 		<![endif]-->
34  
-		
  34
+		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  35
+		<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/library/js/libs/jquery.djax.js"></script>
  36
+		<script type="text/javascript">
  37
+		    jQuery('document').ready(function($) {
  38
+		       $('body').djax('.updatable', ['wp-admin', 'wp-login', '?s=']); 
  39
+			$(window).bind('djaxLoad', function(e, data) {
  40
+				console.log('triggered');
  41
+				console.log(data);
  42
+			});
  43
+		    });
  44
+		</script>	
35 45
 	</head>
36 46
 	
37 47
 	<body <?php body_class(); ?>>
38 48
 	
39 49
 		<div id="container">
40  
-			
  50
+The time you last loaded this whole site is <?php echo date('r'); ?>			
41 51
 			<header role="banner" class="header">
42 52
 			
43 53
 				<div id="inner-header" class="wrap clearfix">
2  index.php
@@ -4,7 +4,7 @@
4 4
 			
5 5
 				<div id="inner-content" class="wrap clearfix">
6 6
 			
7  
-					<div id="main" class="col620 left first clearfix" role="main">
  7
+					<div id="main" class="updatable col620 left first clearfix" role="main">
8 8
 					
9 9
 						<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
10 10
 						
68  library/js/libs/jquery.djax.js
... ...
@@ -0,0 +1,68 @@
  1
+(function($, exports) {
  2
+    
  3
+    $.fn.djax = function(selector, exceptions) {
  4
+        if (!history.pushState) return $(this);
  5
+        
  6
+        var self = this;
  7
+        
  8
+        window.history.replaceState({'url': window.location.href, 'title' : $('title').text()}, $('title').text(), window.location.href);
  9
+        
  10
+        var blockSelector = selector;
  11
+        
  12
+        var excludes = (exceptions && exceptions.length) ? exceptions : [];
  13
+        
  14
+        self.navigate = function(url, add) {
  15
+            var blocks = $(blockSelector);
  16
+             $.get(url, function(response) {
  17
+              var result = $('"'+response+'"');
  18
+              if (add) window.history.pushState({'url': url, 'title' : $(result).filter('title').text()}, $(result).filter('title').text(), url);
  19
+              else window.history.replaceState({'url': url, 'title' : $(result).filter('title').text()}, $(result).filter('title').text(), url);
  20
+              $('title').text($(result).filter('title').text());
  21
+                  var newBlocks = [];
  22
+                  var newBlocks = $(result).find(blockSelector);
  23
+                  blocks.each(function() {
  24
+                      var id = '"#'+$(this).attr('id')+'"';
  25
+                      var newBlock = newBlocks.filter(id);
  26
+                      var block = $(this);
  27
+                      if (newBlock.length) {
  28
+                          if (block.html() != newBlock.html()) block.replaceWith(newBlock);
  29
+                      } else block.remove();
  30
+                  });
  31
+                  $.each(newBlocks, function() {
  32
+                     var newBlock = $(this);
  33
+                     var id = '#'+$(this).attr('id');
  34
+                     if (!$(id).length) {
  35
+                          var before = $(result).find(id).prev();
  36
+                          if (before.length) { var beforeID = '#'+ before.attr('id'); newBlock.insertAfter(beforeID); }
  37
+                          else { var parentID = '#' + newBlock.parent().attr('id'); newBlock.prependTo(parentID); }
  38
+                     }
  39
+                      lastBlock = blocks.filter(id);
  40
+                  });
  41
+                  $('a').filter(function() { return this.hostname == location.hostname; }).addClass('dJAX_internal');
  42
+                  $(window).trigger('djaxLoad', [{'url': url, 'title' : $(result).filter('title').text()}]);
  43
+             });
  44
+          }
  45
+    
  46
+        $(this).find('a').filter(function() { return this.hostname == location.hostname; }).addClass('dJAX_internal');
  47
+        
  48
+        
  49
+        $('a.dJAX_internal').live('click', function(e) {
  50
+            var link = $(this);
  51
+           var exception = false;
  52
+           $.each(excludes, function(k, x) {
  53
+             if (link.attr('href').indexOf(x) != -1) exception = true;
  54
+             if (window.location.href.indexOf(x) != -1) exception = true;
  55
+           });
  56
+           if (exception) return;
  57
+           e.preventDefault();
  58
+           self.navigate(link.attr('href'), true);
  59
+        });
  60
+        
  61
+        $(window).bind('popstate', function(event){
  62
+            var popped = false;
  63
+            self.navigate(event.originalEvent.state.url);
  64
+        });
  65
+        
  66
+    }
  67
+    
  68
+})(jQuery, window);
4  page-custom.php
@@ -10,7 +10,7 @@
10 10
 			
11 11
 				<div id="inner-content" class="wrap clearfix">
12 12
 			
13  
-					<div id="main" class="col620 left first clearfix" role="main">
  13
+					<div id="main" class="updatable col740 left first clearfix" role="main">
14 14
 					
15 15
 						<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
16 16
 						
@@ -57,8 +57,6 @@
57 57
 						<?php endif; ?>
58 58
 					
59 59
 					</div> <!-- end #main -->
60  
-    				
61  
-					<?php get_sidebar(); // sidebar 1 ?>
62 60
 					
63 61
 				</div> <!-- end #inner-content -->
64 62
     
2  page.php
@@ -4,7 +4,7 @@
4 4
 				
5 5
 				<div id="inner-content" class="wrap clearfix">
6 6
 			
7  
-					<div id="main" class="col620 left first clearfix" role="main">
  7
+					<div id="main" class="updatable col620 left first clearfix" role="main">
8 8
 					
9 9
 						<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
10 10
 						
2  sidebar.php
... ...
@@ -1,4 +1,4 @@
2  single.php
@@ -4,7 +4,7 @@
4 4
 			
5 5
 				<div id="inner-content" class="wrap clearfix">
6 6
 			
7  
-					<div id="main" class="col620 left first clearfix" role="main">
  7
+					<div id="main" class="updatable col620 left first clearfix" role="main">
8 8
 					
9 9
 						<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
10 10
 						

0 notes on commit 58aadde

Please sign in to comment.
Something went wrong with that request. Please try again.