Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added lightbox support #15

Open
wants to merge 2 commits into from

1 participant

@el-mapache

Was having trouble launching lightboxes with fancybox, so added some code to check if the hash string in the url is one of the defined pages or not. If it isn't the page won't try and redirect, and instead launch the lightbox. I tested it with fancybox and thickbox!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2012
  1. @el-mapache
Commits on Feb 23, 2012
  1. @el-mapache
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 4 deletions.
  1. +13 −4 pagify.js
View
17 pagify.js
@@ -50,8 +50,17 @@
}
// Respond to hash changes
+ // Adds support for additional hash parameters in the URL, like a lightbox
$(window).bind('hashchange', function() {
- self.switchPage();
+ var comparisonHash = location.hash.split('#')[1];
+ var pagesArray = self.settings.pages;
+
+ for(var i = 0;i<pagesArray.length;i++) {
+ if( comparisonHash === pagesArray[i] ) {
+ self.SwitchPage();
+ break;
+ }
+ }
});
// Load initial page - current hash or default page
@@ -63,8 +72,8 @@
if(self.settings.cache) {
self.pages = {};
var pageLoads = self.settings.pages.length;
- $.each(self.settings.pages, function(ndx, page) {
- $.get(page+'.html', function(content) {
+ $.each(self.settings.pages, function(ndx, page) {
+ $.get(page + 'html', function(content) {
self.pages[page] = content;
pageLoads--;
//alert(pageLoads);
@@ -74,5 +83,5 @@
}
else runAfterLoading();
};
-
+
})(jQuery);
Something went wrong with that request. Please try again.