First implementation of dynamic requests with dummy data
Not yet tested for mobile.
This commit is contained in:
@ -1,27 +1,41 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('[data-fancybox="exposition"]').fancybox({
|
||||
infobar: false,
|
||||
toolbar: true,
|
||||
smallBtn: false,
|
||||
buttons : [ "arrowLeft", "arrowRight", "close" ],
|
||||
arrows: false,
|
||||
transitionEffect: "fade",
|
||||
baseClass: 'fancybox-custom-layout',
|
||||
|
||||
caption : function( instance, item ) {
|
||||
// index put inside, we can get the number: `item.opts.fancyboxIndex`
|
||||
// and thus what we what inside the caption!
|
||||
|
||||
// TODO read json to input good captions info
|
||||
return '\
|
||||
<div id="info">\
|
||||
<span class="info"><a href="painting.html?number=26">ℹ︎</span></a></span>\
|
||||
<span class="title">La Truite</span><span class="year">1960</span>\
|
||||
<span class="format">Huile sur toile (55x35)</span>\
|
||||
<span class="comment">Reproduction de Courbet</span>\
|
||||
</div>\
|
||||
';
|
||||
jQuery(document).ready(function($)
|
||||
{
|
||||
$.getJSON("data.json", function(data)
|
||||
{
|
||||
for (i of data)
|
||||
{
|
||||
if (i.photo == "ok" || i.photo == "good")
|
||||
{
|
||||
console.log(i.number);
|
||||
paintingHtml = '<a data-fancybox="exposition" href="photos/paintings/normal/' + i.number + '.jpg" data-fancybox-index="' + i.number + '">'
|
||||
paintingHtml += '<img src="photos/paintings/mini/' + i.number + '.jpg"></a>';
|
||||
console.log(paintingHtml);
|
||||
$("#gallery").append(paintingHtml);
|
||||
}
|
||||
}
|
||||
|
||||
$('[data-fancybox="exposition"]').fancybox(
|
||||
{
|
||||
infobar: false,
|
||||
toolbar: true,
|
||||
smallBtn: false,
|
||||
buttons: ["arrowLeft", "arrowRight", "close"],
|
||||
arrows: false,
|
||||
transitionEffect: "fade",
|
||||
baseClass: 'fancybox-custom-layout',
|
||||
|
||||
caption: function(instance, item)
|
||||
{
|
||||
var idx = item.opts.fancyboxIndex - 1; // painting number
|
||||
return '\
|
||||
<div id="info">\
|
||||
<span class="info"><a href="painting.html?number=' + data[idx].number + '">ℹ︎</span></a></span>\
|
||||
<span class="title">' + data[idx].title + '</span><span class="year">' + (data[idx].month != '—' ? data[idx].month + ' ' : '') + data[idx].year + '</span>\
|
||||
<span class="format">' + data[idx].paint + ' sur ' + data[idx].support + ' (' + data[idx].dimension + ')</span>\
|
||||
<span class="comment">' + data[idx].comment + '</span>\
|
||||
</div>\
|
||||
';
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user