1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
$(document).ready(function(){
$(".repImage a").click(function(){
openLight();
var titre = $(".repImage").text();
$.ajax({
url: 'Script/Php/Photo.php',
type:'POST',
dataType:'html',
complete: function(resultat, status) {
console.log(resultat);
},
success: function(codehtml, status) {
console.log(codehtml);
$(codehtml).find("#slideShow").appendTo("#zone");
},
error: function(resultat, status, err) {
console.log(err);
}
});
slideShow();
function slideShow(){
/*$("#slideShow").css("position","relative");
$("#slideShow img").css("position","absolute");*/
$("#slideShow img:gt(0)").hide();
// Ajout des liens
$("#slideShow").append("<p><a href=\"#\" class=\"prev\">Précédente</a> | <a href=\"#\" class=\"next\">Suivante</a></p>");
$("#slideShow p").css("padding-top","340px");
// Clic sur le lien suivant
$("#slideShow a.next").click(function() {
var $img_suivante = $("#slideShow img:visible").next("img");
if($img_suivante.length<1) $img_suivante = $("#slideShow img:first");
$("#slideShow img:visible").fadeOut();
$img_suivante.fadeIn();
});
// Clic sur le lien précédent
$("#slideShow a.prev").click(function() {
var $img_precedente = $("#slideShow img:visible").prev("img");
if($img_precedente.length<1) $img_precedente = $("#slideShow img:last");
$("#slideShow img:visible").fadeOut();
$img_precedente.fadeIn();
});
}
function openLight() {
$("body").append("<div id=\"zone\"></div>");
$("body").prepend("<div id=\"cache\"></div>");
$("#cache").css({
"width":"100%",
"height":"100%",
"background":"black",
"z-index":"10",
"position":"absolute",
"top":"0",
"left":"0",
"opacity":0.5
});
$("#zone").css({
"width":"800px",
"height":"630px",
"background":"white",
"z-index":"20",
"position":"absolute",
"top":"50%",
"left":"50%",
"padding":"10px",
"margin-left":"-400px",
"margin-top":"-301px"
});
}
function closeLight(){
$("#slideShow img").remove();
$("#zone,#cache").remove();
}
});
}); |
Partager