/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from Common-Services Co., Ltd.
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe Common-Services Co., Ltd.
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la Common-Services Co. Ltd. est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @package So Colissimo Flexibilite
* @author Alexandre D.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @license Commercial license
* Support by mail : support.soflexibilite@common-services.com
*/
$(document).ready(function () {
//window.console && console.log('Colissimo Flexibilite');
if ($('#SubmitLogin, #submitAccount, #submitGuestAccount').length)
$('#SubmitLogin, #submitAccount, #submitGuestAccount').click(function () {
$(document).ajaxStop(function () {
$(document).unbind('ajaxStop');
setTimeout(function () {
if ($('.address_firstname:first').text()) {
$('#sl-0-firstname').val($('.address_firstname:first').text().split(' ')[0]);
$('#sl-0-lastname').val($('.address_firstname:first').text().split(' ')[1]);
$('#sl-0-address1').val($('li.address_address1:first').text());
$('#sl-0-address2').val($('li.address_address2:first').text());
$('#sl-0-postcode').val($('li.address_postcode:first').text().substring(0, 5));
$('#sl-0-city').val($('li.address_postcode:first').text().substring(6));
$('#sl-0-company').val($('li.address_company:first').text());
$('#sl-0-country').val($('li[class="address_country_name"]:first').text());
$('#sl-0-phone').val($('li[class="address_phone_mobile"]:first').text());
}
else {
$('#sl-0-firstname').val($('#firstname').val());
$('#sl-0-lastname').val($('#lastname').val());
$('#sl-0-address1').val($('#address1').val());
$('#sl-0-address2').val('');
$('#sl-0-postcode').val($('#postcode').val());
$('#sl-0-city').val($('#city').val());
$('#sl-0-company').val($('#company').val());
$('#sl-0-country').val($('#id_country option:selected').text());
$('#sl-0-phone').val($('#phone_mobile').val());
}
setTimeout(function () {
startSoFlexibiliteEngine();
}, 800);
}, 800);
});
});
else
startSoFlexibiliteEngine();
function startSoFlexibiliteEngine() {
/* if ENTER is pressed in input address search => click on search button. */
$('.lookup').keypress(function (e) {
if (e.keyCode === 13) {
e.preventDefault();
$('#soflex-search').click();
}
});
/* If click outside of #so_box_hors, quit the overlay or click on boxlcose (x) */
$('#soflexibilite_overlay, a#boxclose').click(function () {
$('#soflexibilite_overlay').fadeOut('fast', function () {
$('#so_box_hors').fadeOut('slow');
setTimeout(resetOverlay, 300);
});
});
/* Hooking to a target div in the theme. Center Column is present in the PS default theme. */
var target_action_div = null;
if ($('#center_column').length)
target_action_div = $('#center_column');
else if ($('div.column.full:first').length)
target_action_div = $('div.column.full:first');
else if ($('#carrier_area').length)
target_action_div = $('#carrier_area');
else if ($('#content').length)
target_action_div = $('#content');
else
return (false);
/* Carrier selector */
var carrier_selector = parseInt($.fn.jquery.split('.').join('')) < 172 ? 'input:radio[name="id_carrier"]' : 'input.delivery_option_radio';
/* PS16 - Select carrier when click on carrier image */
if (parseInt($.fn.jquery.split('.').join('')) > 172)
target_action_div.delegate('.delivery_option_logo', 'click', function () {
$(this).parent().find(carrier_selector).attr('checked', true).click().parent().addClass('checked');
//SoFlexibilite.updateCarrierSelectionAndGift();
});
var dom_id = $('input#soflexibilite_dom_id').val();
var dos_id = $('input#soflexibilite_dos_id').val();
var rdv_id = $('input#soflexibilite_rdv_id').val();
var bpr_id = $('input#soflexibilite_bpr_id').val();
var a2p_id = $('input#soflexibilite_a2p_id').val();
var cit_id = $('input#soflexibilite_cit_id').val();
/* Check if at least one So Colissimo Liberte carrier is available */
var pass = false;
$(carrier_selector).each(function () {
switch ($(this).val().split(',').join('')) {
// Case : standard
case dom_id :
case dos_id :
case rdv_id :
case bpr_id :
case a2p_id :
case cit_id :
// Case : envoi differe
case dom_id + dom_id:
case dos_id + dos_id:
case rdv_id + rdv_id:
case bpr_id + bpr_id:
case a2p_id + a2p_id:
case cit_id + cit_id:
pass = true;
break;
}
// Case : 2 products with 2 different carriers
if ($(this).val().search(dom_id) > -1 || $(this).val().search(dos_id) > -1 || $(this).val().search(rdv_id) > -1 ||
$(this).val().search(bpr_id) > -1 || $(this).val().search(a2p_id) > -1 || $(this).val().search(cit_id) > -1)
pass = true;
});
if (!pass) {
//window.console && console.log('No So Colissimo Flexibilite carriers, script stop.');
return false;
}
/* Retrieving carriers ID */
var sf_carriers_id = [];
$('[id^="soflexibilite_"][id$="_id"]').not('#soflexibilite_address_id, #soflexibilite_cart_id').each(function () {
sf_carriers_id.push($(this).val());
});
// If no SF Carrier => STOP
if (!sf_carriers_id.length)
return false;
/* Check if processCarrier or opc_payment_methods is present in theme in order to check parameters before payment. */
if (!$('#opc_payment_methods, input[name="processCarrier"], button[name="processCarrier"]').length) {
alert($('#error-target-payment').val());
return;
}
/* Variables */
var sf_customer_address = $('#sl-0-address1').val() + ', ' + $('#sl-0-postcode').val() + ' ' + $('#sl-0-city').val() + ', ' + $('#sl-0-country').val();
sf_customer_address = sf_customer_address.split(/France|FRANCE|france/).length > 1 ? sf_customer_address.split(/France|FRANCE|france/)[0] + 'France' : sf_customer_address;
$('.lookup').val(sf_customer_address);
var soflex_image_url = $('#soflex_image_url').val();
var sf_delivery_mode_is_selected = false;
var sf_customer_lat = null;
var sf_customer_lng = null;
var sf_customer_mail = $('#sl-0-mail').val();
var sf_customer_phone = $('#sl-0-phone').val();
var sf_latlng = null;
var sf_map_zoom = 14;
var sf_map_options = null;
var sf_map = null;
var sf_customer_house = null;
var sf_markers = [];
var sf_info_windows = [];
var sf_bounds = null;
var sf_direction_service = new google.maps.DirectionsService();
var sf_directions_display = new google.maps.DirectionsRenderer({suppressMarkers: true});
var sf_panorama = null;
var search_address_parameters = [];
var sf_icon_home = new google.maps.MarkerImage(
soflex_image_url + 'home.png',
null,
null,
null,
new google.maps.Size(32, 32)
);
var sf_icon_relay = new google.maps.MarkerImage(
soflex_image_url + 'picto.png',
null,
null,
null,
new google.maps.Size(32, 32)
);
var sf_center_control_div = null;
var sf_center_control = null;
var sf_relay_control_div = null;
var sf_relay_control = null;
$('#so_box_hors a.boxclose').css('backgroundImage', 'url(' + soflex_image_url + 'close.png)');
$('#super-selector').css('backgroundImage', 'url(' + soflex_image_url + 'picto.png)');
$('#super-selector').css('background-repeat', 'no-repeat');
$('#super-selector').css('background-position', '2% center');
$(carrier_selector).attr('checked', false);
/* Overlay */
target_action_div.delegate(carrier_selector, 'click', function () {
sf_delivery_mode_is_selected = false;
var selected_carrier = $(this).val().split(',')[0];
if (!in_array(selected_carrier, sf_carriers_id)) {
$('#soflexibilite_description_address').remove();
return (true);
}
if (in_array(selected_carrier, [bpr_id, a2p_id])) {
$('[id^="PR"]').hide();
if (selected_carrier == bpr_id) {
$('[id^="PR"].BPR, [id^="PR"].BDP, [id^="PR"].CDI, [id^="PR"].ACP').show();
$('#super-selector option[value="choixPoste"]').attr('selected', true);
}
else if (selected_carrier == a2p_id) {
$('[id^="PR"].A2P, [id^="PR"].CMT, [id^="PR"].PCS').show();
$('#super-selector option[value="choixCom"]').attr('selected', true);
}
$('#soflexibilite_overlay').fadeIn('fast', function () {
$('#so_box_hors').fadeIn(1000);
if (typeof (sf_map) !== 'undefined' && sf_map !== null) {
google.maps.event.trigger(sf_map, 'resize');
sf_map.fitBounds(sf_bounds);
}
});
}
else
showDeliverySumUpHome();
});
if ($('#order-opc').length) {
// Address change
target_action_div.delegate('#id_address_delivery', 'change', function () {
//resetDeliveryInfoFromAddressBloc();
$('.delivery_option').remove();
$('#opc-refresh-carrier').clone().attr('id', 'opc-refresh-carrier-copy').insertAfter('.delivery_options').show();
$('#soflex-search').click();
target_action_div.ajaxComplete(function () {
$(carrier_selector).attr('checked', false).parent().removeClass('checked');
$('#soflexibilite_description_address').remove();
});
target_action_div.ajaxStop(function () {
target_action_div.unbind('ajaxComplete');
target_action_div.unbind('ajaxStop');
$(carrier_selector).attr('checked', false).parent().removeClass('checked');
setTimeout(function () {
resetDeliveryInfoFromAddressBloc();
setTooltips();
}, 500);
});
});
}
/* Google Map */
try {
var geocoder = new google.maps.Geocoder();
}
catch (e) {
/*window.console && console.log('Erreur GeoCODER', e);
alert($('#geocoder_failed').val());*/
}
function geocodeLocation() {
geocoder.geocode({'address': sf_customer_address, 'region': 'FR'}, function (results, status) {
/*if (window.console) {
console.log('Address : ' + sf_customer_address || 'N/A');
if (results[0])
console.log('Google Map Api value : ' + results[0].geometry.location_type);
}*/
if (status === google.maps.GeocoderStatus.OK) {
sf_customer_lat = parseFloat(results[0].geometry.location.lat());
sf_customer_lng = parseFloat(results[0].geometry.location.lng());
}
/*else if (window.console)
window.console && console.log('google.maps.GeocoderStatus != OK', status, results);*/
/*console.log(
$('#sl-0-address1').val(),
$('#sl-0-postcode').val(),
$('#sl-0-city').val()
);*/
$.ajax({
type: 'POST',
url: $('#soflexibilite_point_list_url').val(),
dataType: 'json',
data: {
adresseRecherche: $('#sl-0-address1').val(),
address: $('#sl-0-address1').val(),
postcode: $('#sl-0-postcode').val(),
city: $('#sl-0-city').val(),
country: $('#sl-0-country').val()
},
success: function (data) {
//window.console && console.log(data);
if (data.status === true) {
sf_bounds = new google.maps.LatLngBounds();
sf_latlng = new google.maps.LatLng(sf_customer_lat, sf_customer_lng);
sf_map_options = {
zoom: sf_map_zoom,
center: sf_latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: (typeof(sf_map_style) === 'object') ? sf_map_style : null
};
sf_map = new google.maps.Map(document.getElementById('gmap'), sf_map_options);
sf_center_control_div = document.createElement('div');
sf_center_control = new setControlCenter(sf_center_control_div);
sf_center_control_div.index = 1;
sf_map.controls[google.maps.ControlPosition.TOP_RIGHT].push(sf_center_control_div);
if ($('#soflexibilite_only_map').val() == '0') {
sf_relay_control_div = document.createElement('div');
sf_relay_control = new setControlRelay(sf_relay_control_div);
sf_relay_control_div.index = 1;
sf_map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(sf_relay_control_div);
}
sf_customer_house = new google.maps.Marker({
map: sf_map,
position: new google.maps.LatLng(sf_customer_lat, sf_customer_lng),
icon: sf_icon_home
});
sf_bounds.extend(sf_customer_house.position);
fillPR(data.points, data.horaires, data.fermetures);
}
},
error: function (er) {
/*if (window.console)
console.log('Erreur geocoder.geocode()', er);*/
}
});
});
}
geocodeLocation();
$('#super-selector').change(function () {
var type_de_point = $('#super-selector option:selected').val();
$('#information-pr').hide();
$('#points').show();
sf_directions_display.setMap(null);
$('div[id^="PR"]').hide();
if (type_de_point == 'choixPoste')
$('div[id^="PR"].BPR, div[id^="PR"].CDI, div[id^="PR"].ACP, div[id^="PR"].BDP').show();
else
$('div[id^="PR"].A2P, div[id^="PR"].CMT, div[id^="PR"].PCS').show();
$('#so_constraint').is(':checked') && setConstraint();
});
$('#gmap').delegate('.infoButton', 'click', function () {
var rel_point = $(this).parent().find('.so-infoWindow').attr('rel');
var prez = '' + $('[id="PR' + rel_point + '"]').find('.libelle').html() + '
' +
$('[id="PR' + rel_point + '"]').find('.address1').html() + '
' + $('[id="PR' + rel_point + '"]').find('.code_postal').html() +
' ' + $('[id="PR' + rel_point + '"]').find('.commune').html();
$('#information-pr').attr('rel', rel_point);
$('#points').hide();
$('#information-pr').find('.prez').html(prez);
$('#horaire').html('').append($('[id="PR' + rel_point + '"]').find('.horairesPR').html());
$('#fermeture').html('').append($('[id="PR' + rel_point + '"]').find('.fermeturesPR').html());
$('#information-pr').show();
checkStreetViewAvailability(
parseFloat($('[id="PR' + rel_point + '"] .pr-lat').val().split(',').join('.')),
parseFloat($('[id="PR' + rel_point + '"] .pr-lng').val().split(',').join('.'))
);
});
$('#gmap').delegate('.sf_select', 'click', function () {
var id_point = $(this).parent().find('.so-infoWindow').attr('rel');
id_point = $('[id="PR' + id_point + '"] .pr-id').val();
selectPoint(id_point);
showDeliverySumUpRelay(id_point);
});
function resetDeliveryInfoFromAddressBloc() {
$(carrier_selector).attr('checked', false).parent().removeClass('checked');
if ($('.address_firstname:first').text()) {
$('#sl-0-firstname').val($('.address_firstname:first').text().split(' ')[0]);
$('#sl-0-lastname').val($('.address_firstname:first').text().split(' ')[1]);
$('#sl-0-address1').val($('li.address_address1:first').text());
$('#sl-0-address2').val($('li.address_address2:first').text());
$('#sl-0-postcode').val($('li.address_postcode:first').text().substring(0, 5));
$('#sl-0-city').val($('li.address_postcode:first').text().substring(6));
$('#sl-0-company').val($('li.address_company:first').text());
$('#sl-0-country').val($('li[class="address_country_name"]:first').text());
$('#sl-0-phone').val($('li[class="address_phone_mobile"]:first').text());
sf_customer_phone = $('li[class="address_phone_mobile"]:first').text();
sf_customer_address = $('li.address_address1:first').text() + ' ' + $('li.address_postcode:first').text();
}
else {
$('#sl-0-firstname').val($('#firstname').val());
$('#sl-0-lastname').val($('#lastname').val());
$('#sl-0-address1').val($('#address1').val());
$('#sl-0-address2').val('');
$('#sl-0-postcode').val($('#postcode').val());
$('#sl-0-city').val($('#city').val());
$('#sl-0-company').val($('#company').val());
$('#sl-0-country').val($('#id_country option:selected').text());
$('#sl-0-phone').val($('#phone_mobile').val());
sf_customer_phone = $('#phone_mobile').val();
sf_customer_address = $('#address1').val() + ', ' + $('#postcode').val() + ' ' + $('#city').val();
}
$('input.lookup').val(sf_customer_address);
}
function setTooltips() {
$('a[id^="tooltip"]').remove();
if (parseInt($.fn.jquery.split('.').join('')) < 172)
return false;
$(carrier_selector).each(function () {
var id_carrier = $(this).val().split(',')[0];
var delivery_mode = null;
if (!in_array(id_carrier, sf_carriers_id))
return true;
switch (id_carrier) {
case dom_id:
delivery_mode = 'Dom';
break;
case dos_id:
delivery_mode = 'Dos';
break;
case bpr_id:
delivery_mode = 'Bpr';
break;
case a2p_id:
delivery_mode = 'A2p';
break;
}
$('.for' + delivery_mode).clone().appendTo($(this).closest('tr').find('.delivery_option_logo').next()).attr('id', 'tooltip' + delivery_mode).show().qtip({
content: {
text: $('.for' + delivery_mode + ' span').html().trim()
},
position: {
my: 'bottom center',
at: 'top center'
},
style: {
classes: 'qtip-light qtip-shadow',
width: 500
},
hide: {
fixed: true,
delay: 300
}
}).parent().find('strong').html(
$('#tooltip' + delivery_mode).parent().find('strong').text().split(' - ').join(' - ') + ''
).css('color', '#FB4F14');
// Instead of .parent().find('strong')...
//
// var txt1 = $('#tooltip' + delivery_mode).parent().html().trim().split('Faites')[0];
// var txt2 = $('#tooltip' + delivery_mode).parent().html().trim().split('Faites')[1];
//
// $('#tooltip' + delivery_mode).parent().html('' + txt1 + '' + ' Faites' + txt2);
if ($('#tooltip' + delivery_mode).prev().text() === '')
$('#tooltip' + delivery_mode).prev().remove();
});
}
function setControlCenter(controlDiv) {
// Set CSS for the control center border.
var controlCenterMap = document.createElement('div');
controlCenterMap.style.backgroundColor = '#fff';
controlCenterMap.style.border = '2px solid #fff';
controlCenterMap.style.borderRadius = '3px';
controlCenterMap.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
controlCenterMap.style.cursor = 'pointer';
controlCenterMap.style.margin = '10px';
controlCenterMap.style.textAlign = 'center';
controlCenterMap.title = 'Recentrer la carte et les points de retrait';
controlDiv.appendChild(controlCenterMap);
// Set CSS for the control center interior.
var controlCenterText = document.createElement('div');
controlCenterText.style.color = 'rgb(0, 0, 0)';
controlCenterText.style.fontFamily = 'Roboto, Arial, sans-serif';
controlCenterText.style.fontSize = '11px';
controlCenterText.style.padding = '8px';
controlCenterText.innerHTML = 'Centrer la carte';
controlCenterMap.appendChild(controlCenterText);
// Setup the click event listeners
controlCenterMap.addEventListener('click', function () {
sf_map.fitBounds(sf_bounds);
});
}
function setControlRelay(controlDiv) {
// Set CSS for the control relay border.
var controlRelay = document.createElement('div');
controlRelay.style.backgroundColor = '#fff';
controlRelay.style.border = '2px solid #fff';
controlRelay.style.borderRadius = '3px';
controlRelay.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
controlRelay.style.margin = '10px';
controlRelay.style.textAlign = 'center';
controlRelay.title = 'Cacher les points de retrait qui ne font pas partie du mode de livraison sélectionné';
controlRelay.id = 'so_control_relay';
controlDiv.appendChild(controlRelay);
// Set CSS for the control relay interior.
var controlRelayText = document.createElement('div');
controlRelayText.style.color = 'rgb(0, 0, 0)';
controlRelayText.style.fontFamily = 'Roboto, Arial, sans-serif';
controlRelayText.style.fontSize = '11px';
controlRelayText.style.padding = '8px';
controlRelayText.innerHTML = ' Filtrer les points de retrait';
controlRelay.appendChild(controlRelayText);
// Setup the click event listeners
controlRelay.addEventListener('click', function () {
setConstraint();
});
}
function fillPR(points, horaires, fermetures) {
deleteMarkers();
$('div[id^=PR]').remove();
$('#so-no-points').hide();
var type_de_point = $('#super-selector option:selected').val();
$.each(points, function (p, point) {
var point_div = $('#model-points').clone().appendTo('div#points').attr('id', 'PR' + p).attr('class', point.typeDePoint);
var distance = null;
var position = new google.maps.LatLng(point.coordGeolocalisationLatitude, point.coordGeolocalisationLongitude);
if (point.distanceEnMetre < 1000)
distance = '(env ' + point.distanceEnMetre + 'm)';
else
distance = '(env ' + (point.distanceEnMetre / 1000).toFixed(2) + 'Km)';
// Fill divs
point_div.children('span.libelle').html(point.nom);
point_div.children('span.so_distance').html(distance);
point_div.children('span.address1').html(point.adresse1);
point_div.children('span.code_postal').html(point.codePostal);
point_div.children('span.commune').html(point.localite);
point_div.children('span.point-choose').find('img').attr('class', 'choosethePR PR' + p).click(function () {
selectPoint(point.identifiant);
showDeliverySumUpRelay(point.identifiant);
});
if (point.accesPersonneMobiliteReduite)
point_div.find('img.handicap').attr('src', soflex_image_url + 'picto-handicap.png');
var so_info = '
L\'adresse recherchée est incorrecte.
'); //window.console && console.log('google.maps.GeocoderStatus != OK', results, status); } }); }); target_action_div.delegate('#sf_phone, #custMail, #infoCommande', 'change', function () { $.ajax({ type: 'POST', url: $('#saveInfoCommande_url').val(), dataType: 'json', data: { email: $('#custMail').val(), phone: $('#sf_phone').val(), infoDelivery: $('#infoCommande').val(), cart: $('#soflexibilite_cart_id').val() }, success: function (data) { if (data.status === true) { //window.console && console.log('Informations saved !'); sf_customer_mail = $('#custMail').val(); sf_customer_phone = $('#sf_phone').val(); $('#custPhone').val($('#sf_phone').val()); } /*else window.console && console.log('Error', data);*/ }, error: function (er) { /*window.console && console.log('Une erreur sur save information !', er);*/ } }); }); $('#otherPR, #so-info-close').click(function () { $('#picStreetView').hide(); $('#points').show(); $('#information-pr').hide(); $('#driving').attr('checked', true); sf_directions_display.setMap(null); if (sf_panorama) sf_panorama.setVisible(false); }); $('#infoChoosePR').click(function () { var id_point = $('#information-pr').attr('rel'); id_point = $('[id="PR' + id_point + '"] .pr-id').val(); selectPoint(id_point); showDeliverySumUpRelay(id_point); }); $('#picDriving').click(function () { var id_point = $('#information-pr').attr('rel'); var request = { origin: sf_customer_house.position, destination: new google.maps.LatLng( $('#PR' + id_point + ' .pr-lat').val(), $('#PR' + id_point + ' .pr-lng').val() ), travelMode: google.maps.TravelMode.DRIVING }; closeSFInfoWindows(); sf_directions_display.setMap(null); sf_direction_service.route(request, function (res, stat) { if (stat === google.maps.DirectionsStatus.OK) sf_directions_display.setDirections(res); }); sf_directions_display.setMap(sf_map); }); $('#picWalking').click(function () { var id_point = $('#information-pr').attr('rel'); var request = { origin: sf_customer_house.position, destination: new google.maps.LatLng( $('#PR' + id_point + ' .pr-lat').val(), $('#PR' + id_point + ' .pr-lng').val() ), travelMode: google.maps.TravelMode.WALKING }; closeSFInfoWindows(); sf_directions_display.setMap(null); sf_direction_service.route(request, function (res, stat) { if (stat === google.maps.DirectionsStatus.OK) sf_directions_display.setDirections(res); }); sf_directions_display.setMap(sf_map); }); $('#picStreetView').click(function () { var id_point = $('#information-pr').attr('rel'); sf_panorama = sf_map.getStreetView(); sf_panorama.setPosition(new google.maps.LatLng( $('#PR' + id_point + ' .pr-lat').val(), $('#PR' + id_point + ' .pr-lng').val() )); sf_panorama.setVisible(true); }); // New address search $('#sf_search_button').click(function () { var address = $('#sf_search_input').val(); $('#sf_search_button > span').toggle(); geocoder.geocode({'address': address, 'region': 'fr'}, function (results, status) { if (status === google.maps.GeocoderStatus.OK) { var address_lat = parseFloat(results[0].geometry.location.lat()); var address_lng = parseFloat(results[0].geometry.location.lng()); codeLatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); setTimeout(function () { $.ajax({ type: 'POST', url: $('#sf_get_delivery_point_url').val(), dataType: 'jsonp', data: { postcode: search_address_parameters['postcode'], city: search_address_parameters['city'], country: search_address_parameters['country'] }, success: function (data) { $('#sf_search_button > span').toggle(); $('#sf_delivery_point_info').hide(); $('#sf_delivery_point').scrollTop(0).show(); /*if (window.console) console.log(data);*/ if (typeof(data.pickup_points) !== 'undefined' && data.pickup_points) { sf_bounds = new google.maps.LatLngBounds(); sf_bounds.extend(new google.maps.LatLng(address_lat, address_lng)); sf_customer_house.setMap(null); sf_customer_house = new google.maps.Marker({ map: sf_map, position: new google.maps.LatLng(address_lat, address_lng), icon: sf_icon_home }); fillMRPickupPoints(data.pickup_points); setupSFPointList(); setLocationGeoCode(address_lat, address_lng); } else { var error_message = 'Aucun point de retrait n\'a été retourné.'; if (data.output) { error_message += '\n' + data.output; } alert(error_message); } }, error: function (e) { $('#sf_search_button > span').toggle(); alert('erreur recherche adresse'); /*if (window.console) console.log(e);*/ } }); }, 800); } else { $('#search-btn, #search-btn-pending, #soflex-search img').toggle(); $('#gmap').html('L\'adresse de recherche est incorrecte.
'); /*if (window.console) console.log('google.maps.GeocoderStatus != OK');*/ } }); }); function checkStreetViewAvailability(lat, lng) { $('#picStreetView').hide(); var streetViewLatLng = new google.maps.LatLng(lat, lng); geocoder.geocode({'latLng': streetViewLatLng, 'region': 'fr'}, function (results, status) { if (status === google.maps.GeocoderStatus.OK) { if (results[0].geometry.location_type === 'ROOFTOP') $('#picStreetView').show(); else $('#picStreetView').hide(); } else $('#picStreetView').hide(); }); } /* Set tooltips */ setTooltips(); /* PrestaShop functions compatibility */ if (typeof('in_array') === 'undefined') in_array = function (b, a) { for (var c in a) if (a[c] + "" === b + "") return !0; return !1; }; if (in_array($(carrier_selector).val().split(',')[0], sf_carriers_id)) $(carrier_selector).attr('checked', false).parent().removeClass('checked'); // Theme setting if ($('#soflexibilite_only_map').val() !== '0') { $('#so_box_hors > p, #super-selector, #so_box_hors > div.float-left.keep-left, .infoButton').hide(); $('#gmap').css('width', '100%').css('height', '86%'); } } });