$(document).ready(function() {
// create an ajaxmanager named autoAjax
var loveProAjax = $.manageAjax.create('loveProAjax', {
queue : 'clear',
cacheResponse : true,
preventDoubbleRequests : true,
abortOld : true,
maxRequests : 1
});
// create an ajaxmanager named autoAjax
var addCommentAjax = $.manageAjax.create('addCommentAjax', {
queue : 'clear',
cacheResponse : false,
preventDoubbleRequests : true,
abortOld : true,
maxRequests : 1
});
/**
* On va faire en sorte de mettre les diaporamas de la fiche en vrai
* diaporama *
*/
$('.toDiaporama').fancybox( {
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'titlePosition': 'over'
});
if ($(".addComment").attr('href') != undefined) {
$(".addComment").fancybox( {
'padding' : 5,
'width' : 890,
'height' : 600,
'overlayOpacity' : 0.3,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'autoDimensions' : true,
'scrolling' : 'no'
// 'onClosed': function() {document.location.reload(true);}
});
}
var start_adr = $("#start_adr"), start_cp = $("#start_cp"), start_city = $("#start_city"), end_adr = $("#end_adr"), end_cp = $("#end_cp"), end_city = $("#end_city");
allFields = $( []).add(start_adr).add(start_cp).add(start_city).add(end_adr).add(end_cp).add(end_city), tips = $("#validateTipsStart");
allFields.removeClass('ui-state-error');
function updateTips(t) {
tips.text(t).effect("highlight", {}, 1500);
}
function checkMandatory(o, n) {
if (o.val().length <= 0) {
o.addClass('ui-state-error');
updateTips("Le champs " + n + " est obligatoire.");
return false;
} else {
return true;
}
}
$("#dialogIti").dialog( {
bgiframe : true,
autoOpen : false,
height : 600,
width : 800,
modal : true,
buttons : {
Fermer : function() {
$(this).dialog('close');
}
},
close : function() {
allFields.removeClass('ui-state-error');
}
});
$('#itipop').click(function() {
var start_adr = $("#start_adr"), start_cp = $("#start_cp"), start_city = $("#start_city"), end_adr = $("#end_adr"), end_cp = $("#end_cp"), end_city = $("#end_city");
allFields = $( []).add(start_adr).add(start_cp).add(start_city).add(end_adr).add(end_cp).add(end_city), tips = $("#validateTipsStart");
allFields.removeClass('ui-state-error');
$('#dialogIti').dialog('open');
if ($('#dialogIti').dialog('isOpen')) {
$("#iti_name").replaceWith('
' + $("#shopNameIti").val() + '
');
locateProFiche(end_adr.val(), end_cp.val(), end_city.val(), $("#idCat1").val());
}
});
$('#itiButton').click(function() {
var bValid = true;
var start_adr = $("#start_adr"), start_cp = $("#start_cp"), start_city = $("#start_city"), end_adr = $("#end_adr"), end_cp = $("#end_cp"), end_city = $("#end_city");
allFields = $( []).add(start_adr).add(start_cp).add(start_city).add(end_adr).add(end_cp).add(end_city), tips = $("#validateTipsStart");
allFields.removeClass('ui-state-error');
bValid = bValid && checkMandatory(start_adr, "adresse de départ");
bValid = bValid && checkMandatory(start_city, "ville de départ");
bValid = bValid && checkMandatory(end_adr, "adresse d'arrivée");
bValid = bValid && checkMandatory(end_city, "ville de d'arrivée");
if (bValid) {
calculItineraire(start_adr, start_cp, start_city, end_adr, end_cp, end_city);
}
});
// Appel d'un itinéraire avec coordonnées/adresse
function calculItineraire(startAdr, startCp, startCity, endAdr, endCp, endCity) {
//var i_cat1 = new GIcon();
var i_cat1 = new google.maps.MarkerImage();
//i_cat1.iconSize = new GSize(30, 47);
//i_cat1.iconAnchor = new GPoint(15, 46);
//i_cat1.infoWindowAnchor = new GPoint(15, 0);
i_cat1.image = "/ui/img/icons/z_bulle_cat" + $("#idCat1").val() + ".png";
var deb = {
type_geoc : 0,
type_item : 1,
icon : i_internaute,
adr : startAdr.val(),
cp : startCp.val(),
ville : startCity.val(),
showBulle : 0,
bulle : '' + startAdr.val() + '
' + startCp.val() + ' ' + startCity.val() + '
'
};
var fin = {
icon : i_cat1,
type_geoc : 0,
type_item : 0,
adr : endAdr.val(),
cp : endCp.val(),
ville : endCity.val(),
showBulle : 0,
bulle : '' + $("#shopNameIti").val() + '
' + endAdr.val() + '
' + endCp.val() + ' ' + endCity.val() + '
'
};
var par = {
kmField : '#kmField',
timeField : '#timeField',
map : 'map_iti',
ctrl_zoom : 1,
ctrl_pan : 1
};
itineraire(deb, fin, par);
}
function locateProFiche(endAdr, endCp, endCity, idCat1) {
//var i_cat1 = new GIcon();
var i_cat1 = new google.maps.MarkerImage();
//i_cat1.iconSize = new GSize(30, 47);
//i_cat1.iconAnchor = new GPoint(15, 46);
//i_cat1.infoWindowAnchor = new GPoint(15, 0);
i_cat1.image = "/ui/img/icons/z_bulle_cat" + idCat1 + ".png";
var params = {
map : 'map_iti',
type_geoc : 0,
type_item : 1,
icon : i_cat1,
adr : endAdr,
cp : endCp,
ville : endCity,
showBulle : 0,
zoom : 15,
ctrl_zoom : 1,
ctrl_pan : 1,
bulle : '' + $("#shopNameIti").val() + '
' + endAdr + '
' + endCp + ' ' + endCity + '
'
};
locatePro(params);
}
$("#phones").dialog( {
bgiframe : true,
autoOpen : false,
height : 350,
width : 750,
modal : true,
buttons : {
Fermer : function() {
$(this).dialog('close');
}
},
close : function() {
}
});
$('#allPhones').click(function() {
$('#phones').dialog('open');
});
$("#timeContact").dialog( {
bgiframe : true,
autoOpen : false,
height : 350,
width : 700,
modal : true,
buttons : {
Fermer : function() {
$(this).dialog('close');
}
},
close : function() {
allFields.val('').removeClass('ui-state-error');
}
});
$('#contact').click(function() {
$('#timeContact').dialog('open');
});
$('#cguContact').click(function() {
openCgu();
});
$('#unloveButton').click(function() {
var bValid = true;
var raison = $("#raison");
var etab = $("#etab");
var adr = $("#adr");
allFields = $( []).add(raison).add(etab).add(adr);
allFields.removeClass('ui-state-error');
});
});
function loveShop(idEtab, idAdr, shopName) {
$('#lovePro').html('');
var actionUrl = '/ajax/sheet/lovePro.html';
var inputs = [];
inputs.push("etab=" + idEtab);
inputs.push("adr=" + idAdr);
inputs.push("shopName=" + encodeURIComponent(shopName));
$.manageAjax.add('loveProAjax', {
// try to leverage ajaxQueue plugin to abort previous
data : inputs.join(String.fromCharCode(38)),
mode : "abort",
url : actionUrl,
timeout : 10000,
type : "GET",
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
},
success : function(r) {
$('#lovePro').html(r);
if ($('#lpConnected').val() == 1) {
var oldCount = $('#loverCount').val();
var count = new Number(oldCount + 1);
$('#loverCount').val(count);
$('#loverCountItem').html('' + count);
}
}
});
}
function askContact(idEtab, idAdr) {
submit = true;
// alert(document.forms.contactForm.cguContactBox.checked);
if (document.forms.contactForm.cguContactBox.checked == true) {
if ($("#askingType option:selected").val() == 0) {
alert('Le champs "Type de demande" est obligatoire.');
submit = false;
return false;
}
if ($('#email').val() == '') {
alert('Le champs "E-mail" est obligatoire.');
submit = false;
return false;
}
if ($('#name').val() == '') {
alert('Le champs "Nom" est obligatoire.');
submit = false;
return false;
}
if ($('#vorname').val() == '') {
alert('Le champs "Prénom" est obligatoire.');
submit = false;
return false;
}
if ($('#askingType').val() == '') {
alert('Le champs "Type de demande" est obligatoire.');
submit = false;
return false;
}
if ($('#askingContent').val() == '') {
alert('Le champs "Votre demande" est obligatoire.');
submit = false;
return false;
}
if ($('#sharePhone').checked == true && $('#phone').val() == '') {
alert('Vous devez renseigner votre numéro de téléphone si vous souhaitez le communiquer.');
submit = false;
return false;
}
if ($('#shareAddress').checked == true && $('#address').val() == '') {
alert('Vous devez renseigner votre adresse si vous souhaitez la communiquer.');
submit = false;
return false;
}
if (submit == true) {
$('#askContactSubmit').hide();
var form = $('#contactForm');
var inputs = [];
$(":input", form).each(function() {
if (this.type == 'checkbox' || this.type == 'radio') {
if (this.checked == true) {
inputs.push(this.name + '=' + escape(this.value));
} else {
inputs.push(this.name + '=' + '');
}
} else {
if (this.name != '') {
inputs.push(this.name + '=' + this.value);
}
}
});
var form = $('#timeContactForm');
$(":input", form).each(function() {
if (this.type == 'checkbox') {
if (this.checked == true) {
inputs.push(this.name + '=' + escape(this.value));
} else {
inputs.push(this.name + '=' + '');
}
}
});
inputs.push("idEtab=" + idEtab);
inputs.push("idAdr=" + idAdr);
var actionUrl = '/ajax/sheet/askContact.html';
jQuery.ajax( {
data : inputs.join(String.fromCharCode(38)),
url : actionUrl,
type : "POST",
timeout : 20000,
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
},
success : function(r) {
$('#contactForm').replaceWith(r);
}
});
}
} else {
alert("Vous devez lire, comprendre et accepter les Conditions Générales d'Utilisation (CGU) du site Atoupro pour envoyer une demande.");
$('#cguContactBox').focus();
submit = false;
}
}
function addComment(idEtab, idAdr, idUser) {
var submit = true;
// list des champs à transmettre a la requete AJAX
var inputs = [];
/**
* Les boutons radios de notation
*/
var fieldsList = {
'accueil':"Vous devez noter l'accueil.",
'conseil':"Vous devez noter le conseil.",
'presta':"Vous devez noter la prestation.",
'delay':"Vous devez noter les délais.",
'price':"Vous devez noter le rapport qualité/prix.",
'youAre':"Vous devez renseigner le champs 'Vous êtes'",
'customerType':"Vous devez renseigner votre Type de client",
'recommand':"Vous devez renseigner si vous recommandez ce pro"
}
// On defini les variables
var accueil, presta, conseil, delay, price, youAre, customerType, recommand;
// On parcours toutes les champs bouton pour les récupérer et les checker
$.each(fieldsList, function(index, value){
var checkedElement = $("input[type=radio][name='"+index+"']:checked");
var checkedValue = ( checkedElement.size()==0 ) ? -1 : checkedElement.val();
if( checkedValue == -1 && submit ){
alert(value);
submit = false;
}else {
inputs.push(index + "=" + checkedValue);
}
});
// Le commentaire
/**
*
var comment = trim($('#comment').val());
if (comment.length < 20 && submit) {
alert("Le message doit contenir 20 caractères minimum.");
submit = false;
}
*/
if (submit) {
$.fancybox.showActivity();
$('#addCommentSubmit').hide();
var form = $('#addCommentForm');
inputs.push("submitForm=" + $('#submitForm').val());
inputs.push("comment=" + encodeURIComponent($('#comment').val()));
inputs.push("positive_points=" + encodeURIComponent($('#positive_points').val()));
inputs.push("negative_points=" + encodeURIComponent($('#negative_points').val()));
inputs.push("idEtab=" + idEtab);
inputs.push("idAdr=" + idAdr);
inputs.push("idUser=" + idUser);
var actionUrl = '/ajax/sheet/addComment.html';
$.ajax({
url : actionUrl,
type : "POST",
data : inputs.join(String.fromCharCode(38)),
timeout : 10000,
type : "POST",
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
$.fancybox.hideActivity();
$('#addCommentForm').replaceWith("Une erreur est survenue. Merci de réessayer plus tard.");
},
success : function(r) {
$('#addCommentForm').html();
$('#addCommentForm').replaceWith(r);
$.fancybox.hideActivity();
}
});
/**
$.manageAjax.add('addCommentAjax', {
// try to leverage ajaxQueue plugin to abort previous
data : inputs.join(String.fromCharCode(38)),
mode : "abort",
url : actionUrl,
timeout : 10000,
type : "POST",
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
$.fancybox.hideActivity();
$('#addCommentForm').replaceWith("Une erreur est survenue. Merci de réessayer plus tard.");
},
success : function(r) {
$('#addCommentForm').html();
$('#addCommentForm').replaceWith(r);
$.fancybox.hideActivity();
}
});
**/
}
}
function rateComment(formItem) {
var form = $('#' + formItem);
var submit = true;
var checked = false;
var voteValue = '';
for (i = 0; i < 3; i++) {
if (document.forms[formItem].elements['voteValue'][i].checked == true) {
checked = true;
voteValue = document.forms[formItem].elements['voteValue'][i].value;
}
}
if (!checked && submit) {
alert("Vous devez noter le message.");
submit = false;
}
var inputs = [];
inputs.push("voteValue=" + voteValue);
inputs.push("idUser=" + document.forms[formItem].elements['idUser'].value);
inputs.push("idComment=" + document.forms[formItem].elements['idComment'].value);
var actionUrl = '/ajax/sheet/voteComment.html';
jQuery.ajax( {
data : inputs.join(String.fromCharCode(38)),
url : actionUrl,
type : "POST",
timeout : 5000,
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
},
success : function(r) {
form.replaceWith(r);
}
});
}
function showMsg() {
// Si il est pas sélectionné
// On va cacher tous les onglets
$('.tabbedPane').hide();
// On met tous les bouton qui ont selected a non selected
$('.tabbedNav a.selected').toggleClass('selected');
// On récupère l'id
var ident = "advices";
// On le met en sélectionné
$("#advices").toggleClass('selected');
// On affiche la tab correspondante
$('#' + ident + '_tab').toggle();
enlarge('sheetpart1', 'sheetpart2');
return false;
}
function showFans() {
// Si il est pas sélectionné
// On va cacher tous les onglets
$('.tabbedPane').hide();
// On met tous les bouton qui ont selected a non selected
$('.tabbedNav a.selected').toggleClass('selected');
// On récupère l'id
var ident = "fans";
// On le met en sélectionné
$("#fans").toggleClass('selected');
// On affiche la tab correspondante
$('#' + ident + '_tab').toggle();
enlarge('sheetpart1', 'sheetpart2');
return false;
}
function showContact() {
// Si il est pas sélectionné
// On va cacher tous les onglets
$('.tabbedPane').hide();
// On met tous les bouton qui ont selected a non selected
$('.tabbedNav a.selected').toggleClass('selected');
// On récupère l'id
var ident = "sheet_contact";
// On le met en sélectionné
$("#sheet_contact").toggleClass('selected');
// On affiche la tab correspondante
$('#' + ident + '_tab').toggle();
enlarge('sheetpart1', 'sheetpart2');
return false;
}
function showDevis() {
// Si il est pas sélectionné
// On va cacher tous les onglets
$('.tabbedPane').hide();
// On met tous les bouton qui ont selected a non selected
$('.tabbedNav a.selected').toggleClass('selected');
// On récupère l'id
var ident = "devis";
// On le met en sélectionné
$("#"+ident).toggleClass('selected');
// On affiche la tab correspondante
$('#' + ident + '_tab').toggle();
dislarge('sheetpart1', 'sheetpart2');
return false;
}
function clickLink(idAdr, type, idCat3, idFiche) {
var actionUrl = '/nf/ajax/stat/clickLink.html';
var inputs = [];
inputs.push("type=" + type);
inputs.push("adr=" + idAdr);
inputs.push("cat3=" + idCat3);
if (idFiche != undefined) {
inputs.push("sheet=" + idFiche);
}
// create an ajaxmanager named autoAjax
var clickLinkAjax = $.manageAjax.create('clickLinkAjax', {
queue : 'clear',
cacheResponse : true,
preventDoubbleRequests : true,
abortOld : true,
maxRequests : 1
});
$.manageAjax.add('clickLinkAjax', {
// try to leverage ajaxQueue plugin to abort previous
data : inputs.join(String.fromCharCode(38)),
mode : "abort",
url : actionUrl,
timeout : 5000,
type : "GET",
error : function(XMLHttpRequest, textStatus, errorThrown) {
XMLHttpRequest.abort();
},
success : function(r) {
}
});
return false;
}