Handle better if pushState is available or not. re #73

This commit is contained in:
Sébastien Lucas 2013-06-20 14:43:31 +02:00
parent 1c8ddb44d4
commit 3144c528e5

20
util.js
View file

@ -2,6 +2,9 @@ var templatePage, templateBookDetail, templateMain, currentData, before;
var DEBUG = true;
var isEink = /Kobo|Kindle|EBRD1101/i.test(navigator.userAgent);
var isPushStateEnabled = window.history && window.history.pushState && window.history.replaceState &&
// pushState isn't reliable on iOS until 5.
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/);
function debug_log(text) {
if ( DEBUG ) {
@ -131,18 +134,10 @@ function updatePage (data) {
$(".fancyabout").fancybox(fancyBoxObject ('COPS ' + currentData.version, 'ajax'));
}
$("#searchForm").submit (function (event) {
event.preventDefault();
var url = strformat ("index.php?page=9&current={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId);
navigateTo (url);
});
}
function ajaxifyLinks () {
if (history.pushState) {
if (isPushStateEnabled) {
var links = $("a[href^='index']");
if (getCurrentOption ("use_fancyapps") == 1) links = links.not (".fancydetail");
links.click (function (event) {
@ -151,6 +146,13 @@ function ajaxifyLinks () {
var url = $(this).attr('href');
navigateTo (url);
});
$("#searchForm").submit (function (event) {
event.preventDefault();
var url = strformat ("index.php?page=9&current={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId);
navigateTo (url);
});
}
}