/** * Darkbox - by Roko.CB * https://github.com/rokobuljan/Darkbox-Gallery */ ;(function() { jQuery(function($) { var $imagesGroup, n = 0, // number of images c = 0, // current image index (counter 0-based) $prevNext = $("").on("touchstart mousedown", function(e) { e.preventDefault(); e.stopPropagation(); var isNext = this.id === "darkbox_next"; c = isNext ? ++c : --c; showImage(); }), $darkbox = $("
", { id: "darkbox", append: $prevNext, appendTo : "body" }), $darkboxClose = $("", { id: "darkbox_close", appendTo: $darkbox, on: { "touchstart mousedown" : function(e) { e.preventDefault(); $darkbox.removeClass("show"); } } }), $darkboxDescription = $("", { id: "darkbox_description", appendTo : $darkbox }), $darkboxStats = $("", { id: "darkbox_stats", appendTo : $darkbox }); function showImage() { // Prevent counter going out of bounds c = c < 0 ? n - 1 : c % n; // Get size of window so that we can define if // background-size needs to be "contain" or "auto". var doc = document.documentElement, docW = Math.max(doc.clientWidth, window.innerWidth || 0), docH = Math.max(doc.clientHeight, window.innerHeight || 0), $cur = $imagesGroup.eq(c), description = $cur.data("darkbox-description"), src = $cur.data("darkbox"); $darkbox.addClass("show spinner"); $darkboxDescription.html(description); $darkboxStats.html(n < 2 ? "" : (c+1) +"/"+ n); $("