Handle links better. re #73
This commit is contained in:
parent
948c1cb3fa
commit
fb51523b33
|
@ -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');
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
updatePage (data [0]);
|
||||
cache.put (url, data [0]);
|
||||
history.replaceState(url, "", window.location);
|
||||
handleLinks ();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
114
util.js
114
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) {
|
||||
|
|
Loading…
Reference in a new issue