Skip to content

Commit

Permalink
Merge pull request #21 from adampresley/master
Browse files Browse the repository at this point in the history
Added ability to specify a base page path
  • Loading branch information
cmpolis committed Jul 30, 2013
2 parents b932e12 + e18edc2 commit 4b3b2cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pagify.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
'animationOut': 'hide',
'animationOutSpeed': 0,
'onChange': function (page) {},
'cache': false
'cache': false,
'basePagePath': ''
};
this.settings = $.extend({}, this.defaults, options);

Expand All @@ -40,7 +41,7 @@
}
else {
// Fetch page content
$.get(page+'.html', function(content) {
$.get(self.settings.basePagePath+page+'.html', function(content) {
$(self)[self.settings.animationOut](self.settings.animationOutSpeed, function() {
$(self).html(content)[self.settings.animation](self.settings.animationSpeed);
})
Expand All @@ -59,12 +60,15 @@
else if(self.settings['default']) self.switchPage(self.settings['default']);
};

// Clean our base page path. Ensure it has a trailing slash.
if (self.settings.basePagePath.indexOf('/', self.settings.basePagePath.length - 2) === -1) self.settings.basePagePath += '/';

// Cache pages
if(self.settings.cache) {
self.pages = {};
var pageLoads = self.settings.pages.length;
$.each(self.settings.pages, function(ndx, page) {
$.get(page+'.html', function(content) {
$.get(self.settings.basePagePath+page+'.html', function(content) {
self.pages[page] = content;
pageLoads--;
//alert(pageLoads);
Expand Down

0 comments on commit 4b3b2cd

Please sign in to comment.