Fix FancyBox in the list view of Explorer
This commit is contained in:
parent
5da19afed3
commit
e5d4f26fc2
@ -447,7 +447,7 @@ jQuery(document).ready(function($)
|
|||||||
else
|
else
|
||||||
result += '<td> </td>'
|
result += '<td> </td>'
|
||||||
|
|
||||||
result += '<td><a data-fancybox="exposition-list" href="';
|
result += '<td><a class="list-preview" data-fancybox="exposition-list" href="';
|
||||||
if (i.photo == "none")
|
if (i.photo == "none")
|
||||||
result += 'images/unknown.jpg';
|
result += 'images/unknown.jpg';
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
function fancyboxInit(data, explorer)
|
function fancyboxInit(data, explorer)
|
||||||
{
|
{
|
||||||
$('[data-fancybox="exposition"], [data-fancybox="exposition-list"]').fancybox(
|
$('[data-fancybox="exposition"]').fancybox(
|
||||||
{
|
{
|
||||||
selector: '.gallery a',
|
selector: '.gallery a',
|
||||||
infobar: false,
|
infobar: false,
|
||||||
@ -14,58 +14,83 @@ function fancyboxInit(data, explorer)
|
|||||||
preventCaptionOverlap: true,
|
preventCaptionOverlap: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
caption: function(instance, item)
|
caption: function(instance, item) { return caption(item, data); },
|
||||||
{
|
beforeShow : function(instance, current) { return beforeShow(instance, current); },
|
||||||
var idx = 0; // search the index of the painting of filtered data
|
afterClose : function(instance) { return afterClose(instance); }
|
||||||
for (i = 0; i < data.length; i++)
|
|
||||||
{
|
|
||||||
if (data[i].number == item.opts.fancyboxIndex)
|
|
||||||
idx = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateCartel()
|
|
||||||
{
|
|
||||||
cartel = '<div id="info"><span class="info">';
|
|
||||||
cartel += '<a href="painting.html?number=' + data[idx].number + '">ℹ︎</span></a></span>';
|
|
||||||
cartel += '<span class="title">' + data[idx].title + '</span><span class="year">';
|
|
||||||
if (data[idx].month != '—')
|
|
||||||
cartel += data[idx].month + ' ';
|
|
||||||
if (data[idx].year != '—')
|
|
||||||
cartel += data[idx].year;
|
|
||||||
cartel += ' </span><span class="format">' + data[idx].paint + ' sur ' + data[idx].support.toLowerCase();
|
|
||||||
if (data[idx].dimension != '—')
|
|
||||||
cartel += ' (' + data[idx].dimension + ')';
|
|
||||||
cartel += '</span>';
|
|
||||||
if (data[idx].comment != '—')
|
|
||||||
cartel += '<span class="comment">' + data[idx].comment + '</span>';
|
|
||||||
cartel += '</div>';
|
|
||||||
return cartel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return generateCartel();
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeShow : function(instance, current)
|
|
||||||
{
|
|
||||||
if (current.opts.fancyboxIndex > previousArray[previousArray.length - 1])
|
|
||||||
$('#pagination').pagination('next');
|
|
||||||
|
|
||||||
if (current.opts.fancyboxIndex < previousArray[0])
|
|
||||||
$('#pagination').pagination('previous');
|
|
||||||
},
|
|
||||||
|
|
||||||
afterClose : function(instance)
|
|
||||||
{
|
|
||||||
// after closing, changing the URL again. I guess there's no better way except by changing fancybox code...
|
|
||||||
// (apparently fancybox changes back to the original url it had when starting)
|
|
||||||
if (explorer)
|
|
||||||
{
|
|
||||||
urlParams = new URLSearchParams(window.location.search)
|
|
||||||
trimSearch = window.location.search.substr(0, window.location.search.lastIndexOf('&'));
|
|
||||||
window.history.replaceState('', '', window.location.pathname + trimSearch + '&page=' + currentPage + window.location.hash);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
window.history.replaceState('', '', window.location.pathname + '?page=' + currentPage + window.location.hash);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('[data-fancybox="exposition-list"]').fancybox(
|
||||||
|
{
|
||||||
|
selector: 'a.list-preview',
|
||||||
|
infobar: false,
|
||||||
|
toolbar: true,
|
||||||
|
smallBtn: false,
|
||||||
|
buttons: ["arrowLeft", "arrowRight", "close"],
|
||||||
|
arrows: false,
|
||||||
|
transitionEffect: "fade",
|
||||||
|
baseClass: 'fancybox-custom-layout',
|
||||||
|
mobile: {
|
||||||
|
preventCaptionOverlap: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
caption: function(instance, item) { return caption(item, data); },
|
||||||
|
beforeShow : function(instance, current) { return beforeShow(instance, current); },
|
||||||
|
afterClose : function(instance) { return afterClose(instance); }
|
||||||
|
});
|
||||||
|
|
||||||
|
function caption(item, data)
|
||||||
|
{
|
||||||
|
var idx = 0; // search the index of the painting of filtered data
|
||||||
|
for (i = 0; i < data.length; i++)
|
||||||
|
{
|
||||||
|
if (data[i].number == item.opts.fancyboxIndex)
|
||||||
|
idx = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateCartel()
|
||||||
|
{
|
||||||
|
cartel = '<div id="info"><span class="info">';
|
||||||
|
cartel += '<a href="painting.html?number=' + data[idx].number + '">ℹ︎</span></a></span>';
|
||||||
|
cartel += '<span class="title">' + data[idx].title + '</span><span class="year">';
|
||||||
|
if (data[idx].month != '—')
|
||||||
|
cartel += data[idx].month + ' ';
|
||||||
|
if (data[idx].year != '—')
|
||||||
|
cartel += data[idx].year;
|
||||||
|
cartel += ' </span><span class="format">' + data[idx].paint + ' sur ' + data[idx].support.toLowerCase();
|
||||||
|
if (data[idx].dimension != '—')
|
||||||
|
cartel += ' (' + data[idx].dimension + ')';
|
||||||
|
cartel += '</span>';
|
||||||
|
if (data[idx].comment != '—')
|
||||||
|
cartel += '<span class="comment">' + data[idx].comment + '</span>';
|
||||||
|
cartel += '</div>';
|
||||||
|
|
||||||
|
return cartel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return generateCartel();
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeShow(instance, current)
|
||||||
|
{
|
||||||
|
if (current.opts.fancyboxIndex > previousArray[previousArray.length - 1])
|
||||||
|
$('#pagination').pagination('next');
|
||||||
|
|
||||||
|
if (current.opts.fancyboxIndex < previousArray[0])
|
||||||
|
$('#pagination').pagination('previous');
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterClose(instance)
|
||||||
|
{
|
||||||
|
// after closing, changing the URL again. I guess there's no better way except by changing fancybox code...
|
||||||
|
// (apparently fancybox changes back to the original url it had when starting)
|
||||||
|
if (explorer)
|
||||||
|
{
|
||||||
|
urlParams = new URLSearchParams(window.location.search)
|
||||||
|
trimSearch = window.location.search.substr(0, window.location.search.lastIndexOf('&'));
|
||||||
|
window.history.replaceState('', '', window.location.pathname + trimSearch + '&page=' + currentPage + window.location.hash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
window.history.replaceState('', '', window.location.pathname + '?page=' + currentPage + window.location.hash);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user