Merge pull request #15 from gillesfabio/issue-14

Fix issue #14 (click on current url don't make a full reload anymore).
This commit is contained in:
Maxime Thirouin
2014-09-16 06:47:06 +02:00

View File

@@ -27,6 +27,7 @@
this.options.switches = this.options.switches || {}
this.options.switchesOptions = this.options.switchesOptions || {}
this.options.history = this.options.history || true
this.options.clickReload = this.options.clickReload || false
this.options.analytics = this.options.analytics || function(options) {
// options.backward or options.foward can be true or undefined
// by default, we do track back/foward hit
@@ -271,10 +272,13 @@
event.preventDefault()
// dont do "nothing" if user try to reload the page
if (el.href === window.location.href) {
window.location.reload()
return -6
// If options.clickReload is true, when a user click twice on a link,
// try to reload the page. Otherwise, do nothing.
if (this.options.clickReload) {
if (el.href === window.location.href) {
window.location.reload()
return -6
}
}
this.loadUrl(el.href, Pjax.clone(this.options))