function placeOutils() { var height = $(window).height(); var scrollTop = $(window).scrollTop(); //var place = height + scrollTop - $("#admin_outils").height() * 2; place = scrollTop; $("#admin_outils").css("top",place + "px"); } var tailleDepart; function changeTailleColPost(taille) { tailleDepart = taille }; function centrerFenetre() { var bw = $(window).width(); var pw = $("#page").width(); //alert(bw); //alert(pw); // on verifie s'il y a un ascenceur var bh = $(window).height(); var ph = $("#page").height(); if(bh < ph) { // il y a un ascenceur bw = bw + 17; // chrome } var marge = (bw - pw) / 2; var nb62 = marge / 12; marge = 12 * parseInt(nb62); if(marge < 0) { marge = 0; } $("#page").css("z-index","1"); $("#page").css("position","absolute"); $("#page").css("left",marge + "px"); if($("#col_post").height() < $("#col_navigation").height()) { $("#col_post").height($("#col_navigation").height()); } else { } } /********************************************** calendrier galerie ****************************************/ function CalendrierGalerieVerifDate() { // permet de retirer les fleches de selection // du calendrier Galerie //////////////////////////////////////////////////// var AnneeAujourdhui = $('#cg_annee_aujourdhui').html(); var AnneeDebut = $('#cg_annee_debut').html(); valAnnee = $('#cg_annee_encours').html() -1 + 1; if(valAnnee == AnneeAujourdhui) { $('.cg_fleche_droite .fleche').css("display","none"); $('.cg_fleche_droite .fleche_grise').css("display","block"); } else { $('.cg_fleche_droite .fleche').css("display","block"); $('.cg_fleche_droite .fleche_grise').css("display","none"); } if(valAnnee == AnneeDebut) { $('.cg_fleche_gauche .fleche').css("display","none"); $('.cg_fleche_gauche .fleche_grise').css("display","block"); } else { $('.cg_fleche_gauche .fleche').css("display","block"); $('.cg_fleche_gauche .fleche_grise').css("display","none"); } } function initialiseCalendrierGalerieTips() { /*****************************************************************/ /*****************************************************************/ /* Permet de placer les TIPS sur le calendrier des GALERIES */ /*****************************************************************/ /*****************************************************************/ $('#calendrier_galerie .cal_case_noir_1').mouseenter(function(e) { var position = $(this).findPos(); var left = position.x; var top = position.y; $("#tips").css("display","block"); $("#tips").html($(this).attr("tip")); $("#tips").html($(this).attr("tip")); }); $('#calendrier_galerie .cal_case_noir_1').mouseleave(function() { $("#tips").css("display","none"); }); $('#calendrier_galerie .cal_case_noir_1').mousemove(function(e) { $("#tips").css("top",e.pageY+20); $("#tips").css("left",e.pageX+15); }); } function initialiseCalendrierGalerie() { CalendrierGalerieVerifDate(); $("#calendrier_galerie .cal_case_noir_1").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); $(this).css("background-color","white"); } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $("#calendrier_galerie .cal_case_noir").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); $(this).css("background-color","white"); } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $("#calendrier_galerie .cal_case_noir_D").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); $(this).css("background-color","white"); } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); initialiseCalendrierGalerieTips(); } /********************************************** calendrier Post ****************************************/ function CalendrierPostVerifDate() { // permet de retirer les fleches de selection // du calendrier Galerie //////////////////////////////////////////////////// var AnneeAujourdhui = $('#cp_annee_aujourdhui').html(); var AnneeDebut = $('#cp_annee_debut').html(); valAnnee = $('#cp_annee_encours').html() -1 + 1; if(valAnnee == AnneeAujourdhui) { $('.cp_fleche_droite .cp_fleche').css("display","none"); $('.cp_fleche_droite .fleche_grise').css("display","block"); } else { $('.cp_fleche_droite .cp_fleche').css("display","block"); $('.cp_fleche_droite .fleche_grise').css("display","none"); } if(valAnnee == AnneeDebut) { $('.cp_fleche_gauche .cp_fleche').css("display","none"); $('.cp_fleche_gauche .fleche_grise').css("display","block"); } else { $('.cp_fleche_gauche .cp_fleche').css("display","block"); $('.cp_fleche_gauche .fleche_grise').css("display","none"); } $('.cp_fleche_gauche .cp_fleche').css("padding-top","3px"); $('.cp_fleche_droite .cp_fleche').css("padding-top","3px"); $('.cp_fleche_gauche .fleche_grise').css("padding-top","3px"); $('.cp_fleche_droite .fleche_grise').css("padding-top","3px"); } function initialiseCalendrierPostTips() { /*****************************************************************/ /*****************************************************************/ /* Permet de placer les TIPS sur le calendrier de POST */ /*****************************************************************/ /*****************************************************************/ $('#calendrier_post .cal_case_noir_1').mouseenter(function(e) { var position = $(this).findPos(); var left = position.x; var top = position.y; $("#tips").css("display","block"); $("#tips").html($(this).attr("tip")); $("#tips").html($(this).attr("tip")); }); $('#calendrier_post .cal_case_noir_1').mouseleave(function() { $("#tips").css("display","none"); }); $('#calendrier_post .cal_case_noir_1').mousemove(function(e) { $("#tips").css("top",e.pageY+20); $("#tips").css("left",e.pageX+15); }); /**************************** case noir ******************************/ $('#calendrier_post .cal_case_noir').mouseenter(function(e) { var position = $(this).findPos(); var left = position.x; var top = position.y; $("#tips").css("display","block"); $("#tips").html($(this).attr("tip")); $("#tips").html($(this).attr("tip")); }); $('#calendrier_post .cal_case_noir').mouseleave(function() { $("#tips").css("display","none"); }); $('#calendrier_post .cal_case_noir').mousemove(function(e) { $("#tips").css("top",e.pageY+20); $("#tips").css("left",e.pageX+15); }); /**************************** case noir D******************************/ $('#calendrier_post .cal_case_noir_D').mouseenter(function(e) { var position = $(this).findPos(); var left = position.x; var top = position.y; $("#tips").css("display","block"); $("#tips").html($(this).attr("tip")); $("#tips").html($(this).attr("tip")); }); $('#calendrier_post .cal_case_noir_D').mouseleave(function() { $("#tips").css("display","none"); }); $('#calendrier_post .cal_case_noir_D').mousemove(function(e) { $("#tips").css("top",e.pageY+20); $("#tips").css("left",e.pageX+15); }); } function initialiseCalendrierPost() { CalendrierPostVerifDate(); $("#calendrier_post .cal_case_noir_1").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $("#calendrier_post .cal_case_noir").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $("#calendrier_post .cal_case_noir_D").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); /****************************************************************************************** TEST */ initialiseCalendrierPostTips(); /****************************************************************************************** FIN */ } jQuery.fn.extend({ findPos : function() { obj = jQuery(this).get(0); var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } return {x:curleft,y:curtop}; } }); $(document).ready(function() { initialiseCalendrierPostTips(); initialiseCalendrierGalerieTips(); $(".post_jaime").click(function() { var valP = $(this).attr("valp"); var monPost = $(this); //alert(valP); $.ajax({ type: "POST", url: "jaime.php", data: "p="+valP, success: function(msg){ //alert(msg); if(msg != "0") { monPost.html(" x " + msg); } } }); }); $("#btn_rechercher").click(function() { $("#form_rechercher").submit(); }); $(".galerie_date_mois").css("position","absolute"); $(".galerie_date_mois").css("top","76px"); $(".galerie_date_mois").css("left","28px"); $("#galerieAnnee .galerie_date_mois").css("top","75px"); $('.galerie_mois img').mouseenter(function(e) { // nous plaçons la tip à la bonne place var position = $(this).findPos(); var left = position.x; var top = position.y; var save_src = $(this).attr("src"); $(this).attr("src",$(this).attr("src2")) $(this).attr("src2", save_src); $("#tips").css("display","block"); $("#tips").html($(this).attr("tip")); $("#tips").html($(this).attr("tip")); }); $('.galerie_mois img').mousemove(function(e) { $("#tips").css("top",e.pageY+20); $("#tips").css("left",e.pageX+15); }); $('.galerie_mois img').mouseleave(function() { var save_src = $(this).attr("src"); $(this).attr("src",$(this).attr("src2")) $(this).attr("src2", save_src); $("#tips").css("display","none"); }); $('.btn_rafraichir ').click(function() { rand = Math.random(); image = "secret_image.png.php?" + rand; $("#secret_img").attr("src",image); }); $('#checkboxRecevoirMessage').click(function() { if($("#recevoirMessage").attr("value") == 0) { $(this).attr("src","img/chk_ok.png"); $("#recevoirMessage").attr("value","1"); } else { $(this).attr("src","img/chk_vide.png"); $("#recevoirMessage").attr("value","0"); } }); $('.radio').click(function() { var nameRadio = $(this).attr("name"); var valueRadio = $(this).attr("value"); $("#" + nameRadio).attr("value",valueRadio); $("img.radio").each(function() { if($(this).attr("name") == nameRadio) { if($(this).attr("value") == valueRadio) { $(this).attr("src","img/chk_ok.png"); } else { $(this).attr("src","img/chk_vide.png"); } } }); }); $('form').submit(function() { var nom = $.trim($("#chNom").val()); var email = $.trim($("#chEmail").val()); var message = $.trim($("#chMessage").val()); var secret = $.trim($("#secret").val()); erreur = false; if(nom == "") { $("#obl_nom").fadeTo( "slow", 0.1, function() { $("#obl_nom .label").css("color","red"); $("#chNom").val("Le nom est obligatoire"); $("#obl_nom").fadeTo( "slow", 1, function() { $("#obl_nom").fadeTo( "slow", 0.1, function() { $("#obl_nom .label").css("color","black"); $("#chNom").val(nom); $("#obl_nom").fadeTo( "slow", 1); }); }); }); erreur = true; } if(secret == "") { $("#secret").fadeTo( "slow", 0.1, function() { $("#secret").css("color","red"); $("#secret").val("le code est obligatoire"); $("#secret").fadeTo( "slow", 1, function() { $("#secret").fadeTo( "slow", 0.1, function() { $("#secret").css("color","black"); $("#secret").val(secret); $("#secret").fadeTo( "slow", 1); }); }); }); erreur = true; } if(email == "") { $("#obl_email").fadeTo( "slow", 0.1, function() { $("#obl_email .label").css("color","red"); $("#chEmail").val("L'email est obligatoire !"); $("#obl_email").fadeTo( "slow", 1, function() { $("#obl_email").fadeTo( "slow", 0.1, function() { $("#obl_email .label").css("color","black"); $("#chEmail").val(email); $("#obl_email").fadeTo( "slow", 1); }); }); }); erreur = true; } else { var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i'); if(reg.test(email)) { } else { $("#obl_email").fadeTo( "slow", 0.1, function() { $("#obl_email .label").css("color","red"); $("#chEmail").val("L'e-mail n'est pas correct !"); $("#obl_email").fadeTo( "slow", 1, function() { $("#obl_email").fadeTo( "slow", 0.1, function() { $("#obl_email .label").css("color","black"); $("#chEmail").val(email); $("#obl_email").fadeTo( "slow", 1); }); }); }); erreur = true; } } if(message == "") { $("#obl_message").fadeTo( "slow", 0.1, function() { $("#obl_message .label").css("color","red"); $("#chMessage").val("Le message est obligatoire !"); $("#obl_message").fadeTo( "slow", 1, function() { $("#obl_message").fadeTo( "slow", 0.1, function() { $("#obl_message .label").css("color","black"); $("#chMessage").val(message); $("#obl_message").fadeTo( "slow", 1); }); }); }); erreur = true; } if(erreur) { return false; } else { return true; } }); /************************ calendrier Galerie **************************/ function cg_ajouter_anner(nbAnnee) { var valAnnee = 0; valAnnee = $('#cg_annee_encours').html() - 1 + 1 + nbAnnee; $('#cg_annee_encours').html(valAnnee); $('.calendrier_galerie_select .cg_annee').html(""+valAnnee+""); //CalendrierGalerieVerifDate(); return valAnnee; } $('.calendrier_galerie_select .cg_fleche_gauche .fleche').click(function() { var valAnnee = cg_ajouter_anner(-1); $.ajax({ type: "GET", url: "calendrier_galerie.mod.php", data: "cg_annee="+valAnnee, success: function(msg){ $('#calendrier_galerie').html(msg ); initialiseCalendrierGalerie(); } }); }); $('.calendrier_galerie_select .cg_fleche_droite .fleche').click(function() { var valAnnee = cg_ajouter_anner(1); $.ajax({ type: "GET", url: "calendrier_galerie.mod.php", data: "cg_annee="+valAnnee, success: function(msg){ $('#calendrier_galerie').html(msg ); initialiseCalendrierGalerie(); } }); }); /************************ calendrier Post **************************/ function cp_ajouter_anner(nbAnnee) { var valAnnee = 0; valAnnee = $('#cp_annee_encours').html() - 1 + 1 + nbAnnee; $('#cp_annee_encours').html(valAnnee); $('.calendrier_post_select .cp_annee').html(valAnnee); return valAnnee; } $('.calendrier_post_select .cp_fleche_gauche .cp_fleche').click(function() { var valAnnee = cp_ajouter_anner(-1); var dateCalendrierPost = $.trim($("#cp_dateCalendrierPost").html()); var dateCalendrierPostMois = $.trim($("#cp_dateCalendrierMois").html()); $.ajax({ type: "GET", url: "calendrier_post.mod.php", data: "cp_annee="+valAnnee+"&dateCalendrierPost="+dateCalendrierPost+"&dateCalendrierPostMois="+dateCalendrierPostMois, success: function(msg){ $('#calendrier_post').html(msg ); initialiseCalendrierPost(); } }); }); $('.calendrier_post_select .cp_fleche_droite .cp_fleche').click(function() { var valAnnee = cp_ajouter_anner(1); var dateCalendrierPost = $.trim($("#cp_dateCalendrierPost").html()); var dateCalendrierPostMois = $.trim($("#cp_dateCalendrierMois").html()); $.ajax({ type: "GET", url: "calendrier_post.mod.php", data: "cp_annee="+valAnnee+"&dateCalendrierPost="+dateCalendrierPost+"&dateCalendrierPostMois="+dateCalendrierPostMois, success: function(msg){ $('#calendrier_post').html(msg ); initialiseCalendrierPost(); } }); }); placeOutils(); centrerFenetre(); $(window).scroll(function() { placeOutils(); centrerFenetre() }); $(window).resize(function() { placeOutils(); centrerFenetre() }); //initialiseCalendrierGalerie(); CalendrierGalerieVerifDate(); CalendrierPostVerifDate(); $(".cal_case_noir_1").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $(".cal_case_noir").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $(".cal_case_noir_D").hover(function() { if($(this).attr("isHover") == "1") { $(this).attr("isHover","0"); $(this).css("color","black"); if($(this).attr("gris") == "cal_case_aujourdhui") { $(this).css("background-color","#808080"); } else { $(this).css("background-color","white"); } } else { $(this).attr("isHover","1"); $(this).css("color","white"); $(this).css("background-color","black"); $(this).css("cursor","pointer"); } }); $(".post_texte p").css("margin-top","12px"); $(".post_texte p:first").css("margin-top","0px"); }); function calendrier_post(date1, date2) { location.href="archives.php?d1="+date1+"&d2="+date2; } function galerie_post(date1, date2) { location.href="galerie.php?d1="+date1+"&d2="+date2; } function openPost(post) { location.href="post.php?p=" + post; }