diff --git a/getJSON.php b/getJSON.php index 6c8a32c..2e27ce2 100644 --- a/getJSON.php +++ b/getJSON.php @@ -88,10 +88,8 @@ if ($currentPage->containsBook ()) { $out ["containsBook"] = 1; } - $out["abouturl"] = "about.html"; - if (getCurrentOption ('use_fancyapps') == 0) { - $out["abouturl"] = "index.php" . addURLParameter ("?page=16", DB, $database); - } + + $out["abouturl"] = "index.php" . addURLParameter ("?page=16", DB, $database); if ($page == Base::PAGE_ABOUT) { $out ["fullhtml"] = file_get_contents('about.html'); diff --git a/index.php b/index.php index 8eead90..1db7d2c 100644 --- a/index.php +++ b/index.php @@ -81,6 +81,7 @@ updatePage (data [0]); cache.put (url, data [0]); history.replaceState(url, "", window.location); + handleLinks (); }); }); diff --git a/styles/style-default.css b/styles/style-default.css index 89cedf2..c7c395c 100644 --- a/styles/style-default.css +++ b/styles/style-default.css @@ -104,8 +104,6 @@ border:0; .container{ background: #414141; border:1px solid #000; border-radius:10px; max-width:800px;width:95%;margin:0 auto;position:relative; } - -.fancyabout { font-weight:400; text-decoration: none; } /* ============================================================================= Header stuff goes here diff --git a/styles/style-eink.css b/styles/style-eink.css index 2bb018f..ae42a7b 100644 --- a/styles/style-eink.css +++ b/styles/style-eink.css @@ -112,8 +112,6 @@ border:0; max-width:800px;width:95%;margin:0 auto;position:relative; background-color: white; } - -.fancyabout { font-weight:400; text-decoration: none; } /* ============================================================================= Header stuff goes here diff --git a/util.js b/util.js index 2d8951e..6cbb9ac 100644 --- a/util.js +++ b/util.js @@ -260,10 +260,12 @@ function updatePage (data) { } else { $("#sortForm").hide (); } - - if (currentData.page !== "19") { ajaxifyLinks (); } - - $("#sort").click(function(){ +} + +function handleLinks () { + $("body").on ("click", "a[href^='index']", link_Clicked); + $("body").on ("submit", "#searchForm", search_Submitted); + $("body").on ("click", "#sort", function(){ $('.books').sortElements(function(a, b){ var test = 1; if ($("#sortorder").val() === "desc") @@ -274,7 +276,7 @@ function updatePage (data) { }); }); - $(".headright").click(function(){ + $("body").on ("click", ".headright", function(){ if ($("#tool").is(":hidden")) { $("#tool").slideDown("slow"); $.cookie('toolbar', '1', { expires: 365 }); @@ -283,58 +285,62 @@ function updatePage (data) { $.removeCookie('toolbar'); } }); - - if (getCurrentOption ("use_fancyapps") === "1") { - $(".fancydetail").click(function(event){ - event.preventDefault(); - before = new Date (); - var url = $(this).attr("href"); - var jsonurl = url.replace ("index", "getJSON"); - $.getJSON(jsonurl, function(data) { - data ["const"] = currentData ["const"]; - var detail = templateBookDetail (data); - $.magnificPopup.open({ - items: { - src: detail, - type: 'inline' - } - }); - debug_log (elapsed ()); - }); - }); - - - $('section').magnificPopup({ - delegate: '.fancycover', // child items selector, by clicking on it popup will open - type: 'image', - gallery:{enabled:true, preload: [0,2]} - // other options - }); - - - - $('.fancyabout').magnificPopup({ type: 'ajax' }); - } + $("body").magnificPopup({ + delegate: '.fancycover', // child items selector, by clicking on it popup will open + type: 'image', + gallery:{enabled:true, preload: [0,2]}, + disableOn: function() { + if( getCurrentOption ("use_fancyapps") === "1" ) { + return true; + } + return false; + } + }); } -function ajaxifyLinks () { - if (isPushStateEnabled) { - var links = $("a[href^='index']"); - if (getCurrentOption ("use_fancyapps") === "1") { links = links.not (".fancydetail"); } - links.click (function (event) { - event.preventDefault(); - - var url = $(this).attr('href'); - navigateTo (url); - }); - - $("#searchForm").submit (function (event) { - event.preventDefault(); - - var url = strformat ("index.php?page=9¤t={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId); - navigateTo (url); - }); +function link_Clicked (event) { + var currentLink = $(this); + if (!isPushStateEnabled || + currentData.page === "19") { + return; } + event.preventDefault(); + var url = currentLink.attr('href'); + + // The bookdetail / about should be displayed in a lightbox + if (getCurrentOption ("use_fancyapps") === "1" && + (currentLink.hasClass ("fancydetail") || currentLink.hasClass ("fancyabout"))) { + before = new Date (); + var jsonurl = url.replace ("index", "getJSON"); + $.getJSON(jsonurl, function(data) { + data ["const"] = currentData ["const"]; + var detail = ""; + if (data.page === "16") { + detail = data.fullhtml; + } else { + detail = templateBookDetail (data); + } + $.magnificPopup.open({ + items: { + src: detail, + type: 'inline' + } + }); + debug_log (elapsed ()); + }); + return; + } + navigateTo (url); +} + +function search_Submitted (event) { + if (!isPushStateEnabled || + currentData.page === "19") { + return; + } + event.preventDefault(); + var url = strformat ("index.php?page=9¤t={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId); + navigateTo (url); } window.onpopstate = function(event) {