function Editor_AjaxConnector(page, params, contentHandler, errorHandler) { var request = typeof(XMLHttpRequest) != "undefined" ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); var url = page + "?" + params.join("&"); request.open("GET", url, true); request.onreadystatechange = function() { if (request.readyState == 4) { var code = request.status; if (code != 200) { //errorHandler(code, page); //return; } // end if contentHandler(request.responseText); } // end if } // end function request.send(null); } // end function function editor_ajaxError(code, message) { alert("Probleme de communication avec le serveur : " + code + " - " + message); } // end function /* test le formulaire d'ajout ---------------------------------------------*/ function checkFormContact(_target, _lang, _contact){ var data = {lang:_lang, contact:_contact}; var check = true; // on vérifie tous les champs de texte $(_target).find("input").each(function(){ if($(this).attr("rel") == "check"){ if($(this).val() == "" || $(this).val() == $(this).attr("alt")) check = false; } // end if if($(this).attr("type") != "submit" && $(this).attr("type") != "button") data[$(this).attr("id")] = $(this).val() != $(this).attr("alt") ? $(this).val() : ""; }); // end each // on vérifie tous les textarea $(_target).find("textarea").each(function(){ if($(this).attr("rel") == "check"){ if($(this).val() == "") check = false; } // end if data[$(this).attr("id")] = $(this).val(); }); // each if(check){ $.ajax({ type: "POST", data: data, url: domain+"sys/php/sendContactMail.php", success: function(data){ if(data == "ok"){ alert("Votre e-mail a été envoyé. Merci de nous avoir contacté."); $(_target).find("input").each(function(){ if($(this).attr("type") != "submit") $(this).val(""); }); $(_target).find("textarea").each(function(){ $(this).val(""); }); }else{ alert("Votre e-mail n'a pas pu être envoyé. Nous vous prions de recommencer ultérieurement."); } // end if } // end success }); // end ajax }else{ alert("Veuillez remplir tous les champs."); } // end if return false; } // end function checkFormContact /* Renseigne la valeur d'un champ du formulaire par sa valeur par défaut quand il perd le focus ou le vide quand il prend le focus s'il avait la valeur par défaut ---------------------------------------------*/ function setFieldValue(_target, _data){ if(_data == ""){ if($(_target).val() == $(_target).attr("alt")){ $(_target).val(""); $(_target).removeClass("field-inactive"); } // end if }else{ if($(_target).val() == ""){ $(_target).val($(_target).attr("alt")); $(_target).addClass("field-inactive"); } // end if } // end if } // end function setFieldValue /* vérifie la syntaxe de l'e-mail ---------------------------------------------*/ function isEmail(_target){ var verif = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); var value = true; if(verif.exec($(_target).val()) == null){ value = false; } //end if return value; } // end function checkNewsletterForm /* ---------------------------------------------- Class Diaporama Créé Par Julien Cousseau pour Egami Creation Modifiée le 20 octobre 2014 Elle permet de zoomer les photos et de les passer en mode diaporama -----------------------------------------------*/ var Diaporama = function(_target, _galery){ var $current = $(_target).attr('src') !== undefined ? _target : $(_target).find('img').eq(0); var $this = this; var $mask; var $container; var $photo; var $title; var $galery = _galery; // objet HTML qui contient toutes les photos du diapo var $max_percent_size = 85; // taille maximale en pourcentage par rapport à la taille de la fenêtre /* création du masque noir et du container ----------------------------------------------*/ $this.init = function(){ // création du mask $mask = $('
'); $mask.click($this.close); $('body').append($mask); // création du container de la photo $container = $('
'); $container.css("display", "none"); $container.css("opacity", 0); $('body').append($container); // création de l'objet img $photo = $('') $photo.click($this.close); $container.append($photo); // création de la zone de texte $title = $('

'); $container.append($title); // création de la nav si plusieurs photos if(typeof($galery) !== "undefined" && $($galery).find("img").length > 1){ $this.nav(); } // end if } // end function init /* création de la navigation ----------------------------------------------*/ $this.nav = function(){ var nav = $('
précédentsuivant
'); $container.append(nav); // action des boutons $('.photozoom-transition-buttons #photozoom-button-next-photo').click($this.nextPhoto); $('.photozoom-transition-buttons #photozoom-button-prev-photo').click($this.prevPhoto); } // end function nav /* initialisation de la photo à afficher ----------------------------------------------*/ $this.initPhoto = function(){ $.ajax({ type: "GET", url: domain+"sys/php/getImageSize.php", data: {url: $($current).attr('src').substr(0, domain.length) == domain ? $($current).attr('src').substr(domain.length) : $($current).attr('src'), type_url:$($current).attr('src').substr(0, domain.length) == domain ? "relative" : "absolute"}, success: function(_data){ // tailles originales var default_size = _data.split(";"); // calcule des nouvelles tailles var size = $this.resize(default_size); // affichage de la photo $this.display(size); } // end success }); // end ajax } // end function initPhoto /* calcule de la taille de la nouvelle photo ----------------------------------------------*/ $this.resize = function(_size){ var default_height = Number(_size[1]); var default_width = Number(_size[0]); var screen_height = $(window).height(); var screen_width = $(window).width(); var mode = "paysage"; var height = 0; var width = 0; // mode d'affichage if(default_height > default_width){ mode = "portrait"; } // end if // calcule des tailles if(mode == "portrait"){ height = $this.setSize(default_height, screen_height); width = Math.round(default_width*(height/default_height)); // on vérifie que la largeur calculée n'est pas plus grande que la taille de l'écran if(width > Math.round(screen_width*$max_percent_size/100)){ width = $this.setSize(width, screen_width); height = Math.round(default_height*(width/default_width)); } // end if }else{ width = $this.setSize(default_width, screen_width); height = Math.round(default_height*(width/default_width)); // on vérifie que la largeur calculée n'est pas plus grande que la taille de l'écran if(height > Math.round(screen_height*$max_percent_size/100)){ height = $this.setSize(height, screen_height); width = Math.round(default_width*(height/default_height)); } // end if } // end if return [width, height]; } // end function resize /* redimentionne une dimension hauteur ou largeur ----------------------------------------------*/ $this.setSize = function(_default, _max){ var size = 0; if(_default > Math.round(_max*$max_percent_size/100)){ size = Math.round(_max*$max_percent_size/100); }else{ size = _default; } // end if return size; } // end function setSize /* affichage de la photo ----------------------------------------------*/ $this.display = function(_size){ // création de la photo $photo.attr('src', $($current).attr('src')); $photo.attr('width', _size[0]); // positionnement du container au centre de l'écran $container.css("top", ($(window).height()-Number(_size[1]))/2+"px"); $container.css("left", ($(window).width()-$container.outerWidth())/2+"px"); // affichage du container $container.css("display", "block"); $container.stop().animate({opacity: 1}, 250); // affichage du titre $title.html($($current).attr('title') != undefined ? $($current).attr('title') : ""); } // end function display /* passage à la photo suivante ----------------------------------------------*/ $this.nextPhoto = function(){ for(var i = 0; i < $($galery).find('img').length; i++){ if($($galery).find('img').eq(i).attr('src') == $($current).attr('src')){ $current = i+1 < $($galery).find('img').length ? $($galery).find('img').eq(i+1) : $($galery).find('img').eq(0); $this.initPhoto(); break; } // end if } // end for i } // end function nextPhoto /* passage à la photo précédente ----------------------------------------------*/ $this.prevPhoto = function(){ for(var i = 0; i < $($galery).find('img').length; i++){ if($($galery).find('img').eq(i).attr('src') == $($current).attr('src')){ $current = i-1 >= 0 ? $($galery).find('img').eq(i-1) : $($galery).find('img').eq($($galery).find('img').length-1); $this.initPhoto(); break; } // end if } // end for i } // end function prevPhoto /* fermeture du diapo ----------------------------------------------*/ $this.close = function(){ $container.remove(); $mask.remove(); } // end function close /* lancement de la classe ----------------------------------------------*/ $this.init(); $this.initPhoto(); } // end class Diaporama /* Ancienne fonction ----------------------------------------------*/ function photoZoom(url, transition, _galery_url, type, position, total, id_project, id_block, title){ // do nothing } // end function