Merge pull request #21 from adampresley/master
Added ability to specify a base page path
This commit is contained in:
commit
4b3b2cd032
10
pagify.js
10
pagify.js
|
@ -19,7 +19,8 @@
|
||||||
'animationOut': 'hide',
|
'animationOut': 'hide',
|
||||||
'animationOutSpeed': 0,
|
'animationOutSpeed': 0,
|
||||||
'onChange': function (page) {},
|
'onChange': function (page) {},
|
||||||
'cache': false
|
'cache': false,
|
||||||
|
'basePagePath': ''
|
||||||
};
|
};
|
||||||
this.settings = $.extend({}, this.defaults, options);
|
this.settings = $.extend({}, this.defaults, options);
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Fetch page content
|
// 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)[self.settings.animationOut](self.settings.animationOutSpeed, function() {
|
||||||
$(self).html(content)[self.settings.animation](self.settings.animationSpeed);
|
$(self).html(content)[self.settings.animation](self.settings.animationSpeed);
|
||||||
})
|
})
|
||||||
|
@ -59,12 +60,15 @@
|
||||||
else if(self.settings['default']) self.switchPage(self.settings['default']);
|
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
|
// Cache pages
|
||||||
if(self.settings.cache) {
|
if(self.settings.cache) {
|
||||||
self.pages = {};
|
self.pages = {};
|
||||||
var pageLoads = self.settings.pages.length;
|
var pageLoads = self.settings.pages.length;
|
||||||
$.each(self.settings.pages, function(ndx, page) {
|
$.each(self.settings.pages, function(ndx, page) {
|
||||||
$.get(page+'.html', function(content) {
|
$.get(self.settings.basePagePath+page+'.html', function(content) {
|
||||||
self.pages[page] = content;
|
self.pages[page] = content;
|
||||||
pageLoads--;
|
pageLoads--;
|
||||||
//alert(pageLoads);
|
//alert(pageLoads);
|
||||||
|
|
Loading…
Reference in a new issue