"use strict"; $('ul.slimmenu').slimmenu({ resizeWidth: '992', collapserTitle: 'Main Menu', animSpeed: 250, indentChildren: true, childrenIndenter: '' }); var FACEBOOK_APP_ID = ''; // Countdown $('.countdown').each(function() { var count = $(this); $(this).countdown({ zeroCallback: function(options) { var newDate = new Date(), newDate = newDate.setHours(newDate.getHours() + 130); $(count).attr("data-countdown", newDate); $(count).countdown({ unixFormat: true }); } }); }); $.datepicker.setDefaults( $.datepicker.regional[ "fr" ] ); $( ".jdate" ).datepicker( { onSelect : datePickerChanger } ); function datePickerChanger(date, instance) { if( instance.input.attr('name') == 'start' && $('#home').length > 0 ) { var d = instance.input.datepicker( "getDate" ); d.setDate(d.getDate()+14); $('input[name="end"]').datepicker('setDate', d); } } $('.btn').button(); $("[rel='tooltip']").tooltip(); $('.form-group').each(function() { var self = $(this), input = self.find('input'); input.focus(function() { self.addClass('form-group-focus'); }) input.blur(function() { if (input.val()) { self.addClass('form-group-filled'); } else { self.removeClass('form-group-filled'); } self.removeClass('form-group-focus'); }); }); $('.typeahead').typeahead({ hint: true, highlight: true, minLength: 2, accent: true, limit: 8 }, { source: function(q, cb) { return $.ajax({ dataType: 'json', type: 'get', url: '/ajax/home/searchLocation?l='+currentLanguage+'&callback=?&q=' + q, cache: false, success: function(data) { var result = []; $.each(data, function(index, val) { result.push({ value: val.name , code :val.id , api :val.api }); }); cb(result); } }); } }).on('typeahead:selected', function(input,value) { var name = input.target.name; name = name.substring(0,1); $('.search-form input[name='+name+']').val(value.api); $('.search-form input[name=t]').val(value.api); $('.search-form select.to').html(''); $.get('/ajax/api/getCities/' + value.api, function(data) { $('.search-form select.to').html(data); }); });; $('select.to').change(function() { $(this).parents('form:first').find('input[name=t]').val( $(this).val() ); }); /* $('.input-daterange input[name="start"]').datepicker().on('changeDate', function(event) { var d = event.date; d.setDate(d.getDate()+14); $('.input-daterange input[name="end"]').datepicker('setDate', d); }); */ $('#home input.date-pick, #home input[name="start"],#pays input[name="start"],#ville input[name="start"]').datepicker('setDate', '+60d'); $('#home input[name="end"],#pays input[name="end"],#ville input[name="end"]').datepicker('setDate', '+74d'); /* $('input.date-pick, .input-daterange, .date-pick-inline').datepicker({ todayHighlight: true }); $('input.time-pick').timepicker({ minuteStep: 15, showInpunts: false }) $('input.date-pick-years').datepicker({ startView: 2 }); */ /* $('#payment input[type="radio"]').click(function() { if($(this).attr('id') == 'ecv') { $('#infoecv').show(); } else { $('#infoecv').hide(); } }); */ $('#payment #paymentSubmit').click(function() { if( $(this).data('send') != null ) { return false; } var _this = this; $(this).data('send', true); $(this).data('save', $(this).html()); $(this).html('Veuillez patienter'); var remise = $('input[name=optradio]:checked').val(); var type = $('input[name=mode]:checked').val(); var code = $(this).data('code'); var values = ''; if( $('#adyen-encrypted-form').length > 0 ) { values = $('#adyen-encrypted-form').serialize() + "&"; } values += 'remise='+remise; values += '&type='+type; values += '&code='+code; $.post('/ajax/api/setPayment', values, function(data) { if( data.indexOf('inline:') == 0 && data.indexOf('error') == -1 ) { data = data.substring(7); $('body').html(data); } else if( data.indexOf('form:') == 0 ) { data = data.substring(5); $('#paymentForm').html(data); $('#paymentForm form').submit(); } else if( data.indexOf('url:') == 0 ) { data = data.substring(4); self.location.href = data; } else { alert('Une erreur est survenue'); $(_this).data('send', null); $(_this).html($(_this).data('save')); } }); return false; }); $('.modepayment #adyen-encrypted-form').submit(function() { $('#payment #paymentSubmit').trigger('click'); return false; }); $('.booking-item-price-calc .checkbox label').click(function() { var checkbox = $(this).find('input'), // checked = $(checkboxDiv).hasClass('checked'), checked = $(checkbox).prop('checked'), price = parseInt($(this).find('span.pull-right').html().replace('$', '')), eqPrice = $('#car-equipment-total'), tPrice = $('#car-total'), eqPriceInt = parseInt(eqPrice.attr('data-value')), tPriceInt = parseInt(tPrice.attr('data-value')), value, animateInt = function(val, el, plus) { value = function() { if (plus) { return el.attr('data-value', val + price); } else { return el.attr('data-value', val - price); } }; return $({ val: val }).animate({ val: parseInt(value().attr('data-value')) }, { duration: 500, easing: 'swing', step: function() { if (plus) { el.text(Math.ceil(this.val)); } else { el.text(Math.floor(this.val)); } } }); }; if (!checked) { animateInt(eqPriceInt, eqPrice, true); animateInt(tPriceInt, tPrice, true); } else { animateInt(eqPriceInt, eqPrice, false); animateInt(tPriceInt, tPrice, false); } }); $('div.bg-parallax').each(function() { var $obj = $(this); if($(window).width() > 992 ){ $(window).scroll(function() { var animSpeed; if ($obj.hasClass('bg-blur')) { animSpeed = 10; } else { animSpeed = 15; } var yPos = -($(window).scrollTop() / animSpeed); var bgpos = '50% ' + yPos + 'px'; $obj.css('background-position', bgpos); }); } }); $(document).ready( function() { $('html').niceScroll({ cursorcolor: "#000", cursorborder: "0px solid #fff", railpadding: { top: 0, right: 0, left: 0, bottom: 0 }, cursorwidth: "10px", cursorborderradius: "0px", cursoropacitymin: 0.2, cursoropacitymax: 0.8, boxzoom: true, horizrailenabled: false, zindex: 9999 }); // Owl Carousel var owlCarousel = $('#owl-carousel'), owlItems = owlCarousel.attr('data-items'), owlCarouselSlider = $('#owl-carousel-slider'), owlNav = owlCarouselSlider.attr('data-nav'); // owlSliderPagination = owlCarouselSlider.attr('data-pagination'); owlCarousel.owlCarousel({ items: owlItems, navigation: true, navigationText: ['', ''] }); owlCarouselSlider.owlCarousel({ slideSpeed: 300, paginationSpeed: 400, // pagination: owlSliderPagination, singleItem: true, navigation: true, navigationText: ['', ''], transitionStyle: 'fade', autoPlay: 4500 }); // footer always on bottom var docHeight = $(window).height(); if( $('#main-footer').length > 0 ) { var footerHeight = $('#main-footer').height(); var footerTop = $('#main-footer').position().top + footerHeight; if (footerTop < docHeight) { $('#main-footer').css('margin-top', (docHeight - footerTop) + 'px'); } } } ); if( $('body').hasClass('log') ) { $('.top-user-area .nav-drop.account').dropit(); } $('.top-user-area .nav-symbol, .top-user-area .top-user-area-lang').dropit(); $('.nav-drop.booking-sort').dropit(); $('.top-user-area .nav-symbol li a').click(function() { $('#swapDevise input').val( $(this).attr('rel') ); $('#swapDevise').submit(); return false; }); $('#allMoney a').click(function() { $('#swapDevise input').val( $(this).attr('rel') ); $('#swapDevise').submit(); return false; }); $("#price-slider").ionRangeSlider({ min: parseInt($("#price-slider").attr('min'), 10), max: parseInt($("#price-slider").attr('max'), 10), type: 'double', prefix: "", // maxPostfix: "+", prettify: true, hasGrid: true, onFinish : function(data) { filterPrices(); } }); $('.i-check, .i-radio').iCheck({ checkboxClass: 'i-check', radioClass: 'i-radio' }); $('.search-form .i-check').on('ifChecked', function(event){ $('.search-form .to').hide(); $('select.to').val(''); $('input[name=t]').val(''); }); $('.search-form .i-check').on('ifUnchecked', function(event){ $('.search-form .to').show(); }); if( $('#search-dialog').data('from') != null ) { var url = '/ajax/api/getCities/' + $('#search-dialog').data('from'); if( $('#search-dialog').data('to') != null ) { url += '?current=' + $('#search-dialog').data('to'); } $.get(url, function(data) { $('.search-form select.to').html(data); }); } $('.booking-filters .i-check').on('ifChanged', function(event) { var criteres = {}; $('.booking-filters input.i-check').each(function() { if( $(this).data('target') != null ) { var name = $(this).data('target'); var groupe = $(this).data('group'); if( criteres[groupe] == null ) { criteres[groupe] = {}; } if( $(this).is(':checked') ) { if( criteres[groupe][name] == null ) { criteres[groupe][name] = []; } criteres[groupe][name].push( $(this).val() ); } } }); $('.booking-list .booking-item').show().removeClass('filterko').removeClass('priceko'); $('.booking-list .booking-item').each(function() { var row = this; //console.log('************************************************'); var conditions = {}; $.each( criteres, function(groupe, items) { $.each( items, function(name, values) { var liste = $(row).data(name).toString().split(','); var common = $.grep(liste, function(element) { return $.inArray(element, values ) !== -1; }); var conditionCouchages = false; if( name == 'couchages' ) { $.each( liste, function(i, v1) { $.each( values, function(i, v2) { //console.log(v1 + ' >= ' + v2); if( parseInt(v1) == parseInt(v2) || (parseInt(v2) == 6 && parseInt(v1) >= 6 ) ) { conditionCouchages = true; } }); }); } //console.log('groupe = '+groupe); if( typeof conditions[groupe] == 'undefined' ) { conditions[groupe] = true; } //console.log('avant : '+conditions[groupe]); //console.log('value = ' + (values.length == 0 || common.length > 0)); conditions[groupe] = conditions[groupe] && (values.length == 0 || common.length > 0 || conditionCouchages); //console.log('apres : '+conditions[groupe]); }); }); var condition = true; $.each( conditions, function(name, value) { condition &= value; }); if( !condition ) { $(row).hide().addClass('filterko'); } //console.log('conditinos = '); //console.log(conditions); }); filterPrices(); }); var resultsNbParPage = 10; var resultsPage = 1; if( $('.booking-list.topslider').length > 0 ) { resultsNbParPage = 4; if( $(window).width() < 768 ) { resultsNbParPage = 2; } if( $(window).width() < 500 ) { resultsNbParPage = 1; } } function paginateResults(draw) { var offset = resultsNbParPage * (resultsPage-1); var min = offset; var max = offset + resultsNbParPage; var nb = $('.booking-list .booking-item:not(.filterko):not(.priceko)').length; var nbPages = Math.ceil( nb / resultsNbParPage ); if( nbPages < 2 ) { $('.before_pagination').hide(); } else { $('.before_pagination').show(); } $('.booking-list .booking-item:not(.filterko):not(.priceko)').each(function(index) { if( index < min || index >= max ) { //console.log( index + ' < ' + min + ' || ' + index + ' > ' + max ); $(this).hide(); } else { $(this).show(); } }); $('.before_pagination .start').html(min+1); $('.before_pagination .end').html(max); if( draw ) { $('#searchResults .pagination li').remove(); for(var i = 0; i < nbPages; i++ ) { $('#searchResults .pagination').append('
  • '+(i+1)+'
  • '); } if( resultsPage < nbPages ) { $('#searchResults .pagination').append(''); } $('#searchResults .pagination li:not(.prev):first').addClass('active'); $('#searchResults .pagination li:not(.prev):not(.next)').click(function() { resultsPage = parseInt($(this).attr('rel'), 10); $('#searchResults .pagination li.active').removeClass('active'); $(this).addClass('active'); if( resultsPage == nbPages ) { $('#searchResults .pagination li.next').hide(); } else if( nbPages > 1 ) { $('#searchResults .pagination li.next').show(); } paginateResults(); return false; }); $('#searchResults .pagination li.next').click(function() { resultsPage++; $('#searchResults .pagination li.active').next().addClass('active'); $('#searchResults .pagination li.active:first').removeClass('active'); $(this).addClass('active'); paginateResults(); return false; }); $('#searchResults .pagination li:first').trigger('click'); $('a.listPrev').click(function() { if( resultsPage <= 1 ) { $(this).css('opacity', 0.3); return false; } $('a.listNext').css('opacity', 1); resultsPage--; if( resultsPage == 0 ) { $(this).css('opacity', 0.3); } else { $(this).css('opacity', 1); } paginateResults(); return false; }).css('opacity', 0.3); $('a.listNext').click(function() { if( resultsPage >= nbPages - 2 ) { $(this).css('opacity', 0.3); return false; } $(this).css('opacity', 1); $('a.listPrev').css('opacity', 1); resultsPage++; paginateResults(); return false; }); } } function filterPrices() { var values = $('#price-slider').val().split(';'); var min = parseInt(values[0], 10); var max = parseInt(values[1], 10); $('.booking-list .booking-item').each(function() { var price = parseInt( $(this).data('price'), 10 ); if( price < min || price > max ) { $(this).hide(); $(this).addClass('priceko'); } else { if( !$(this).hasClass('filterko') ) { $(this).show(); $(this).removeClass('priceko'); } } }); paginateResults(true); } function sortByPrices(asc) { var $wrapper = $('.booking-list'); $wrapper.find('> li').sort(function(a, b) { var score = 0; if( asc ) { var prixA = $(a).hasClass('remarket') ? parseInt($(a).find('.booking-item').data('price')) / 1000 : parseInt($(a).find('.booking-item').data('price')); var prixB = $(b).hasClass('remarket') ? parseInt($(b).find('.booking-item').data('price')) / 1000 : parseInt($(b).find('.booking-item').data('price')); score = prixA - prixB; } else { var prixA = $(a).hasClass('remarket') ? parseInt($(a).find('.booking-item').data('price')) * 1000 : parseInt($(a).find('.booking-item').data('price')); var prixB = $(b).hasClass('remarket') ? parseInt($(b).find('.booking-item').data('price')) * 1000 : parseInt($(b).find('.booking-item').data('price')); score = prixB - prixA; } return score; }) .appendTo($wrapper); } function sortByType(asc) { var $wrapper = $('.booking-list'); $wrapper.find('> li').sort(function(a, b) { return $(a).find('.booking-item').data('category').localeCompare($(b).find('.booking-item').data('category')); }) .appendTo($wrapper); } if( $('#searchResults').length > 0 ) { sortByPrices(true); } if( $('#searchResults').length > 0 ) { paginateResults(true); } function sortResults(sort) { if( sort == 'prix_asc' ) { sortByPrices(true); } if( sort == 'prix_desc' ) { sortByPrices(false); } if( sort == 'type' ) { sortByType(); } } $('.booking-list .booking-item').each(function() { var item = $(this); $(this).find('.btn-submit').click(function() { var f = $('#offreForm').get(0); f.query.value = item.data('query'); f.submit(); return false; }); }); $('.booking-sort .nav-drop-menu li').click(function() { $('.booking-sort .nav-drop-menu .active').html( $('.booking-sort h5').html() ); $('.booking-sort h5').html( $(this).html() + '' ); $('.booking-sort .nav-drop-menu li').removeClass('active'); $('.booking-sort .nav-drop-menu li i').remove(); $(this).addClass('active'); sortResults( $('.booking-sort h5 a').data('sort') ); }); $('.booking-item-review-expand').click(function(event) { console.log('baz'); var parent = $(this).parent('.booking-item-review-content'); if (parent.hasClass('expanded')) { parent.removeClass('expanded'); } else { parent.addClass('expanded'); } }); $('.stats-list-select > li > .booking-item-rating-stars > li').each(function() { var list = $(this).parent(), listItems = list.children(), itemIndex = $(this).index(); $(this).hover(function() { for (var i = 0; i < listItems.length; i++) { if (i <= itemIndex) { $(listItems[i]).addClass('hovered'); } else { break; } }; $(this).click(function() { for (var i = 0; i < listItems.length; i++) { if (i <= itemIndex) { $(listItems[i]).addClass('selected'); } else { $(listItems[i]).removeClass('selected'); } }; }); }, function() { listItems.removeClass('hovered'); }); }); $('.booking-item-container').children('.booking-item').click(function(event) { if ($(this).hasClass('active')) { $(this).removeClass('active'); $(this).parent().removeClass('active'); } else { $(this).addClass('active'); $(this).parent().addClass('active'); $(this).delay(1500).queue(function() { $(this).addClass('viewed') }); } }); $('.booking-list .selectpicker').change(function() { $('.booking-item-payment .booking-item-payment-details .optionsrecap').addClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(''); var parent = $(this).parents('tr:first') var key = parent.data('key'); var value = $(this).val(); waitOnOptions(); $.get('/ajax/api/setOption?key='+key+'&value='+value, function(data) { self.location.reload(); /* $('.booking-item-payment .booking-item-payment-details .optionsrecap').removeClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(data); if( $('.booking-item-payment .booking-item-payment-details .optionsrecap ul li').length > 0 ) { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').show(); } else { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').hide(); } */ }); }); $('.booking-list div.i-check').on('ifChanged', function(event) { if( $(this).hasClass('lock') || globalOptionsLock ) { return true; } $('.booking-item-payment .booking-item-payment-details .optionsrecap').addClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(''); var parent = $(this).parents('tr:first') var key = parent.data('key'); var value = event.target.checked ? '1' : '0'; waitOnOptions(); $.get('/ajax/api/setOption?key='+key+'&value='+value, function(data) { self.location.reload(); /* $('.booking-item-payment .booking-item-payment-details .optionsrecap').removeClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(data); if( $('.booking-item-payment .booking-item-payment-details .optionsrecap ul li').length > 0 ) { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').show(); } else { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').hide(); } */ }); }); $('.rowPromoSubmit').click(function() { var values = ''; $('.promo-list div.i-check.checked').each(function() { if( values != '' ) { values += ','; } var parent = $(this).parents('tr:first') var key = parent.data('key'); values += key; }); waitOnOptions(); $.get('/ajax/api/setPromo?keys='+values, function(data) { self.location.reload(); }); }); $('.promo-list div.i-check').on('ifChanged', function(event) { if( $(this).hasClass('lock') || globalOptionsLock ) { return true; } $('.booking-item-payment .booking-item-payment-details .optionsrecap').addClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(''); var parent = $(this).parents('tr:first') var key = parent.data('key'); var value = event.target.checked ? '1' : '0'; if( parseInt(parent.data('max'), 10) > 1 ) { $('.rowPromoSubmit').show(); return; } waitOnOptions(); $.get('/ajax/api/setPromo?key='+key+'&value='+value, function(data) { self.location.reload(); /* $('.booking-item-payment .booking-item-payment-details .optionsrecap').removeClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(data); if( $('.booking-item-payment .booking-item-payment-details .optionsrecap ul li').length > 0 ) { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').show(); } else { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').hide(); } */ }); }); if( $('.booking-item-payment.screenoptions .booking-item-payment-details .optionsrecap').length > 0 ) { $('.booking-item-payment .booking-item-payment-details .optionsrecap').addClass('loading'); waitOnOptions(); $.get('/ajax/api/listOptions', function(data) { self.location.reload(); /* $('.booking-item-payment .booking-item-payment-details .optionsrecap').removeClass('loading'); $('.booking-item-payment .booking-item-payment-details .optionsrecap ul').html(data); if( $('.booking-item-payment .booking-item-payment-details .optionsrecap ul li').length > 0 ) { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').show(); } else { $('.booking-item-payment .booking-item-payment-details .optionsrecap > div').hide(); } */ }); } function waitOnOptions() { //$('body').prepend('
    '+translations['Chargement en cours...']+'
    '); $('body').prepend('
    '); } $('.booking-item-card .payzen .btn-submit').click(function() { $('#payment').modal('show'); /* if( $(this).attr('send') ) { return false; } $(this).val('Chargement...'); $(this).attr('send', true); $.get('/ajax/api/saveOffre', function(data) { $('.booking-item-card form').submit(); }); */ return false; }); $('#payment.modal .btn').click(function() { if( $('#payment.modal #cgv:checked').length == 0 ) { $('#payment.modal .warning2').show(); return false; } $('#payment.modal .warning2').hide(); if( $('#payment.modal input[name=nom] ').val() == '' || $('#payment.modal input[name=prenom]').val() == '' || $('#payment.modal input[name=telephone]').val() == '' ) { $('#payment.modal .warning1').show(); return false; } $('#payment.modal .warning1').hide(); if( $(this).attr('send') ) { return false; } $(this).html('Chargement...'); $(this).attr('send', true); var values = { 'nompilote': $('#payment.modal input[name=nompilote] ').val(), 'prenompilote' : $('#payment.modal input[name=prenompilote] ').val(), 'nom': $('#payment.modal input[name=nom] ').val(), 'prenom' : $('#payment.modal input[name=prenom] ').val(), 'telephone' : $('#payment.modal input[name=telephone] ').val(), 'type' : $('#payment.modal input[name=type]:checked').val() } $.post('/ajax/api/saveOffre?lang='+currentLanguage, values, function(d) { $.get('/ajax/api/setEmpreinte', function(data) { $('.paymentForms').html(data); if( $('#payment.modal input[name=type]:checked').val() == 'cb' ) { $('.cbPayment form').submit(); } else { $('.amexPayment form').submit(); } }); }); }) $('.form-group-cc-number input').payment('formatCardNumber'); $('.form-group-cc-date input').payment('formatCardExpiry'); $('.form-group-cc-cvc input').payment('formatCardCVC'); if ($('#map-canvas').length) { var map, service; jQuery(function($) { $(document).ready(function() { var latlng = new google.maps.LatLng(40.7564971, -73.9743277); var myOptions = { zoom: 16, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false }; map = new google.maps.Map(document.getElementById("map-canvas"), myOptions); var marker = new google.maps.Marker({ position: latlng, map: map }); marker.setMap(map); $('a[href="#google-map-tab"]').on('shown.bs.tab', function(e) { google.maps.event.trigger(map, 'resize'); map.setCenter(latlng); }); }); }); } $('.card-select > li').click(function() { self = this; $(self).addClass('card-item-selected'); $(self).siblings('li').removeClass('card-item-selected'); $('.form-group-cc-number input').click(function() { $(self).removeClass('card-item-selected'); }); }); // Lighbox gallery $('#popup-gallery').each(function() { $(this).magnificPopup({ delegate: 'a.popup-gallery-image', type: 'image', gallery: { enabled: true } }); }); // Lighbox image $('.popup-image').magnificPopup({ type: 'image' }); // Lighbox text $('.popup-text').magnificPopup({ removalDelay: 500, closeBtnInside: true, callbacks: { beforeOpen: function() { this.st.mainClass = this.st.el.attr('data-effect'); } }, midClick: true }); // Lightbox iframe $('.popup-iframe').magnificPopup({ dispableOn: 700, type: 'iframe', removalDelay: 160, mainClass: 'mfp-fade', preloader: false }); $('.form-group-select-plus').each(function() { var self = $(this), btnGroup = self.find('.btn-group').first(), select = self.find('select'); btnGroup.children('label').last().click(function() { btnGroup.addClass('hidden'); select.removeClass('hidden'); }); }); // Responsive videos $(document).ready(function() { $("body").fitVids(); }); $(function($) { $("#twitter").tweet({ username: "remtsoy", //!paste here your twitter username! count: 3 }); }); $(function($) { $("#twitter-ticker").tweet({ username: "remtsoy", //!paste here your twitter username! page: 1, count: 20 }); }); $(document).ready(function() { var ul = $('#twitter-ticker').find(".tweet-list"); var ticker = function() { setTimeout(function() { ul.find('li:first').animate({ marginTop: '-4.7em' }, 850, function() { $(this).detach().appendTo(ul).removeAttr('style'); }); ticker(); }, 5000); }; ticker(); }); $(function() { $('#ri-grid').gridrotator({ rows: 4, columns: 8, animType: 'random', animSpeed: 1200, interval: 1200, step: 'random', preventClick: false, maxStep: 2, w992: { rows: 5, columns: 4 }, w768: { rows: 6, columns: 3 }, w480: { rows: 8, columns: 3 }, w320: { rows: 5, columns: 4 }, w240: { rows: 6, columns: 4 } }); }); $(function() { $('#ri-grid-no-animation').gridrotator({ rows: 4, columns: 8, slideshow: false, w1024: { rows: 4, columns: 6 }, w768: { rows: 3, columns: 3 }, w480: { rows: 4, columns: 4 }, w320: { rows: 5, columns: 4 }, w240: { rows: 6, columns: 4 } }); }); var tid = setInterval(tagline_vertical_slide, 2500); // vertical slide function tagline_vertical_slide() { var curr = $("#tagline ul li.active"); curr.removeClass("active").addClass("vs-out"); setTimeout(function() { curr.removeClass("vs-out"); }, 500); var nextTag = curr.next('li'); if (!nextTag.length) { nextTag = $("#tagline ul li").first(); } nextTag.addClass("active"); } function abortTimer() { // to be called when you want to stop the timer clearInterval(tid); } function statusChangeCallback(response) { if (response.status === 'connected') { facebookAPIResponse(response); } else if (response.status === 'not_authorized') { $('.popup.login .facebook .loader').hide(); } else { $('.popup.signin .facebook .loader').hide(); } } function checkLoginState() { $('.popup.login .facebook .loader').show(); FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } window.fbAsyncInit = function() { FB.init({ appId : FACEBOOK_APP_ID, cookie : true, xfbml : true, version : 'v2.8' }); FB.getLoginStatus(function(response) { // statusChangeCallback(response); }); }; (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/fr_FR/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function facebookAPIResponse(response) { var token = response.authResponse.accessToken; FB.api('/me', function(response) { facebooklogin(response, token); }); } function facebooklogin (response, token) { $('.popup.login .facebook .loader').show(); $.ajax({type:"POST", data: { id : response.id, token : token }, url:"/ajax/clients/loginFacebook", success: function(data) { if( data.indexOf('empty') > -1 ) { alert(translations["Ce compte n'existe pas, veuillez créer un compte en cliquant sur 'Inscrivez-vous'"]); } else if( data.indexOf('ok') > -1 ) { hidePopup(); } else { alert(translations["Une erreur est survenue"]); } $('.popup.login .facebook .loader').hide(); }, error: function() { $('.popup.login .facebook .loader').hide(); alert(translations["Une erreur est survenue"]); } }); } function facebooksignin(response) { $('.popup.signin .facebook .loader').show(); $.ajax({type:"POST", data: { nom : response.last_name, prenom : response.first_name, email : response.email, facebook_link : response.link, facebook_id : response.id }, url:"/ajax/clients/signinFacebook", success: function(data) { $('.popup.signin .facebook .loader').hide(); if( data.indexOf('error') > -1 ) { alert(translations["Une erreur est survenue"]); } else if( data.indexOf('exist') > -1 ) { hidePopup(); showPopup('.login'); alert(translations["Ce compte existe déjà, veuillez vous connecter en cliquant sur 'Se connecter avec Facebook'"]); } else { hidePopup(); showPopup('.bienvenue'); } }, error: function() { $('.popup.signin .facebook .loader').hide(); alert('error', translations["Une erreur est survenue"]); } }); } function statusChangeCallbackSignin(response) { console.log('statusChangeCallback'); console.log(response); if (response.status === 'connected') { facebookAPIResponseSignin(); } else if (response.status === 'not_authorized') { $('.popup.signin .facebook .loader').hide(); } else { $('.popup.signin .facebook .loader').hide(); } } function checkLoginStateSignin() { $('.popup.login .facebook .loader').show(); FB.getLoginStatus(function(response) { statusChangeCallbackSignin(response); }); } window.fbAsyncInit = function() { FB.init({ appId : FACEBOOK_APP_ID, cookie : true, xfbml : true, version : 'v2.7' }); FB.getLoginStatus(function(response) { // statusChangeCallbackSignin(response); }); }; (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/fr_FR/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function facebookAPIResponseSignin() { FB.api('/me?fields=id,first_name,last_name,email', function(response) { console.log(response); facebooksignin(response); }); } $('#signinForm').submit(function() { $(this).find('.message .m').html(''); $(this).find('input').removeClass('error'); var error = false; var message = translations["Veuillez saisir une adresse email et un mot de passe"]; $(this).find('input').removeClass('error'); if( $(this).find('input.email').val() == '') { $(this).find('input.email').addClass('error'); error = true; } else { if( !checkEmail($(this).find('input.email').val()) ) { $(this).find('input.email').addClass('error'); error = true; message = translations["Adresse e-mail non valide"]; } } if( $(this).find('input.password').val() == '') { $(this).find('input.password').addClass('error'); error = true; } else { if( $(this).find('input.password').val().length < 6 ) { $(this).find('input.password').addClass('error'); error = true; message = translations["Veuillez saisir un mot de passe d'au moins 6 caractères"]; } } var _this = this; if( !error ) { $(this).find('button[type=submit]').addClass('load'); $.post('/ajax/clients/signin?lang=', $(this).serialize(), function(data) { $(_this).find('button[type=submit]').removeClass('load'); if( data == 'ok' || data == 'yet' ) { if( $(_this).parents('#connect').length > 0 ) { $('#connect').modal('hide'); $('body').addClass('log'); if( loginAction != null ) { loginAction(); } } else { self.location.href = '/'; } } else if( data == 'exists') { $(_this).find('.field').addClass('error'); $(_this).find('.message .m').html(translations['Ce compte existe déjà']) } else { $(_this).find('.message .m').html(translations['Données incorrectes']) } } ); } else { $(_this).find('.message .m').html(message); } return false; }); $('a.forgot').click(function() { $('#loginForm').hide(); $('#forgotForm').show(); return false; }); $('a.forgotback').click(function() { $('#loginForm').show(); $('#forgotForm').hide(); return false; }); $('.booking-item-card #adyen-encrypted-form').submit(function() { if( $(this).attr('send') || $(this).find('input.invalid').length > 0 ) { return false; } if( $('#adyen-encrypted-form input[name=prenom] ').val() == '' || $('#adyen-encrypted-form input[name=nom] ').val() == '' || $('#adyen-encrypted-form input[name=telephone] ').val() == '' || $('#adyen-encrypted-form input.cvc').val() == '' || $('#adyen-encrypted-form input.number').val() == '' || $('#adyen-encrypted-form input.month').val() == '' || $('#adyen-encrypted-form input.year').val() == '') { return false; } var button = $(this).find('button[type=submit]'); button.html('Chargement...'); $(this).attr('send', true); var emp = 1; if( $(this).hasClass('payment') ) { emp = 0; } var postData = $(this).serialize(); var values = { 'nom': $('#adyen-encrypted-form input[name=nom] ').val(), 'prenom' : $('#adyen-encrypted-form input[name=prenom] ').val(), 'telephone' : $('#adyen-encrypted-form input[name=telephone] ').val(), 'type' : $('#adyen-encrypted-form input[name=type]:checked').val() } if( emp == 0 ) { } else { $.post('/ajax/api/saveOffre?lang='+currentLanguage, values, function(d) { $.post('/ajax/api/submitAdyen/1', postData, function(data) { if( data != null && data.indexOf('PaReq') > - 1) { } $('body').html(data); }); }); } return false; }); $('#loginForm').submit(function() { $(this).find('.message .m').html(''); $(this).find('input').removeClass('error'); var error = false; $(this).find('input').removeClass('error'); var message = translations["Veuillez saisir une adresse email et un mot de passe"]; if( $(this).find('input.email').val() == '') { $(this).find('input.email').addClass('error'); error = true; } if( $(this).find('input.password').val() == '') { $(this).find('input.password').addClass('error'); error = true; } var _this = this; if( !error ) { $(this).find('button[type=submit]').addClass('load'); $.post('/ajax/clients/login', $(this).serialize(), function(data) { $(_this).find('button[type=submit]').removeClass('load'); if( data == 'ok') { if( $(_this).parents('#connect').length > 0 ) { $('#connect').modal('hide'); $('body').addClass('log'); if( loginAction != null ) { loginAction(); } } else { self.location.href="/"; } } else { $(_this).find('.field').addClass('error'); $(_this).find('.message .m').html(translations['Adresse email ou mot de passe incorrect']) } } ); } else { $(_this).find('.message .m').html(message); } return false; }); $('#forgotForm').submit(function() { $(this).find('.message .m').html(''); $(this).find('input').removeClass('error'); var error = false; $(this).find('input').removeClass('error'); var message = "Veuillez saisir une adresse email"; if( $(this).find('input.email').val() == '') { $(this).find('input.email').addClass('error'); error = true; } var _this = this; if( !error ) { $(this).find('input[type=submit]').attr('save', $(this).find('input[type=submit]').val()); $(this).find('input[type=submit]').val('Veuillez patienter...'); $.post('/ajax/clients/forgot', $(this).serialize(), function(data) { $(_this).find('input[type=submit]').val($(_this).find('input[type=submit]').attr('save')); if( data == 'ok') { $('#loginForm').show(); $('#forgotForm').hide(); $('#loginForm').find('.message .m').html(translations['Un email vient de vous être envoyé sur votre adresse.']) } else { $(_this).find('.field').addClass('error'); $(_this).find('.message .m').html(translations['Adresse email incorrecte']) } } ); } else { $(_this).find('.message .m').html(message); } return false; }); $('#offre .booking-item-price-calc .btn-submit, #offre .btn_options_haut').click(function() { function goOptions() { $('#goOptions').submit(); } if( $('body').hasClass('log') ) { goOptions(); } else { loginAction = goOptions; $('#connect').modal('show'); } }); $('.btn.saveoffre').click(function() { var btn = $(this); function saveOffre() { if( $(btn).data('query') != null ) { $('#save input[name=query]').val(btn.data('query')); } $('#save').modal('show'); } if( $('body').hasClass('log') ) { saveOffre(); } else { loginAction = saveOffre; $('#connect').modal('show'); } }); $('.btn.pdfoffre').click(function() { var btn = $(this); function pdfOffre() { if( $(btn).data('query') != null ) { $('#pdf input[name=query]').val(btn.data('query')); } var button = $('#pdf form button') if( button.attr('save') != null ) { button.html(button.attr('save')); button.attr('save', null); } $('#pdf').modal('show'); } if( $('body').hasClass('log') ) { pdfOffre(); } else { loginAction = pdfOffre; $('#connect').modal('show'); } }); $('#pdf.modal form').submit(function() { var button = $(this).find('button'); button.attr('save', button.html()); button.html('Veuillez patienter...'); setTimeout(function() { button.html(button.attr('save')); }, 10000); return true; }); $('#save.modal form').submit(function() { var button = $(this).find('button'); button.attr('save', button.html()); button.html('Veuillez patienter...'); var url = '/ajax/api/saveOffre'; if( $(this).find('input[name=query]').val() != '' ) { url += '?query=' + $(this).find('input[name=query]').val(); } $.get(url, function(data) { if( data == 'ok' ) { $('#save.modal .modal-body').html(translations['Cette offre a bien été enregistrée dans votre espace client.']); $('#save.modal .modal-footer').html(''); } else { $('#save.modal .modal-body').html(translations['Une erreur est survenue.']); $('#save.modal .modal-footer').html(''); } }); return false; }); $('#question.modal form').submit(function() { var button = $(this).find('button'); button.attr('save', button.html()); button.html(translations['Veuillez patienter...']); $.post('/ajax/api/contactOffre?lang='+currentLanguage, $(this).serialize(), function(data) { if( data == 'ok' ) { $('#question.modal .modal-body').html(translations['Votre message a bien été envoyé.']); } else { // à faire corriger par Stéphane // $('#question.modal .modal-body').html(translations['Une erreur est survenue.']); $('#question.modal .modal-body').html(translations['Votre message a bien été envoyé.']); $('#question.modal .modal-footer').html(''); } }); return false; }); upTime(); setInterval( upTime, 1000 * 60 * 3); $('.booking-list .delete').click(function() { var id = $(this).data('id'); var _this = $(this).parent(); $(_this).animate({ 'opacity': 0 }, 2000, function() { $(_this).remove(); }); $.get('/ajax/clients/deleteOffre/'+id, function(data) { }); return false; }); var loginAction = null; var globalOptionsLock = false; function checkEmail(val) { var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; return filter.test(val); } function initOptions() { $('.booking-item-details .pricetotal:not(.local)').html(''); //$('.booking-item-details .form-control').val(0); $('.booking-item-details .form-control').each(function() { if( $(this).parents('#payment').length == 0 ) { $(this).val(0); } }); $('.booking-item-details tr:not(.locked) .form-control').prop('disabled', false); $('.booking-item-details div.i-check').each(function() { $(this).addClass('lock'); if( !$(this).find('.i-check').hasClass('disabled') ) { $(this).iCheck('enable').iCheck('uncheck'); } }); $('.booking-item-details tr:not(.locked) .form-control').removeClass('lock'); setTimeout(function() { $('.booking-item-details tr:not(.locked) div.i-check').removeClass('lock'); } , 300); } function updateOption(key, quantity, price, state) { if(price == 0 ) { price = ''; } //alert(key +" quantity = "+quantity + " price = "+price + " state = " + state); if( $('.booking-list tr.'+key+' .form-control').length > 0 ) { $('.booking-list tr.'+key+' .form-control').val(quantity); if( state == 'lock') { $('.booking-list tr.'+key+' .form-control').prop('disabled', 'disabled'); } } if( $('.booking-list tr.'+key+' div.i-check').length > 0 ) { if( state != null ) { $('.booking-list tr.'+key+' div.i-check').addClass(state); } if( quantity == 0 ) { $('.booking-list tr.'+key+' div.i-check').iCheck('uncheck'); } else { $('.booking-list tr.'+key+' div.i-check').iCheck('check'); } if( state != null ) { $('.booking-list tr.'+key+' div.i-check').iCheck('disable'); } $('.booking-list tr.'+key+'.locked div.i-check').iCheck('disable'); } $('.booking-list tr.'+key+' .pricetotal:not(.local)').html(price); if( quantity > 0 ) { $('.booking-list tr.'+key).removeClass('hidden'); } } function optionEvent(key, value) { if( value == 0 ) { if( $('.booking-list tr.'+key).hasClass('statehidden') ) { $('.booking-list tr.'+key).addClass('hidden'); } } } function hideOption(key) { $('.booking-list tr.'+key).addClass('hidden'); } function showOption(key) { $('.booking-list tr.'+key).removeClass('hidden'); } function updatePromo(key, quantity, price, state) { if(price == 0 ) { price = ''; } if( $('.promo-list tr.'+key+' .form-control').length > 0 ) { $('.promo-list tr.'+key+' .form-control').val(quantity); if( state == 'lock') { $('.promo-list tr.'+key+' .form-control').prop('disabled', 'disabled'); } } if( $('.promo-list tr.'+key+' div.i-check').length > 0 ) { if( state != null ) { $('.promo-list tr.'+key+' div.i-check').addClass(state); } if( quantity == 0 ) { $('.promo-list tr.'+key+' div.i-check').iCheck('uncheck'); } else { $('.promo-list tr.'+key+' div.i-check').iCheck('check'); } if( state != null ) { $('.promo-list tr.'+key+' div.i-check').iCheck('disable'); } } //$('.promo-list tr.'+key+' .pricetotal').html(price); } function upTime() { $.ajax({ url: "/ajax/Clients/up", cache: false }); } $('.booking-item .btn.fiche').click(function() { $(this).data('save', $(this).html()); $(this).html(translations['Chargement en cours...']); var _this = this; $.get('/ajax/Commande/fiche/' + $(this).attr('rel') + '?l='+currentLanguage, function(data) { $(_this).html($(_this).data('save')); $('#fiche').html(data); $('#fiche').modal('show'); $('#fiche .transferts select').change(function() { var parent = $(this).parents('.transferts:first'); parent.find('.vol,.hotel,.gare').hide(); if( $(this).val() != '' ) { parent.find('.'+ $(this).val()).show(); } }).trigger('change'); $('#fiche').on('change', 'input[type=file]', function() { $(this).parents('div:first').find('i,label').css('color', '#009966'); var filename = $(this).get(0).files[0].name; var file = $('
    '+filename+'
    '); file.css('color', '#009966'); $(this).parents('div:first').find('.file').remove(); $(this).parents('div:first').append(file); }); $('#fiche .addconducteur').click(function() { var clone = $('#fiche .conducteur:last').clone(); var nb = parseInt(clone.find('span.nb').html(), 10); clone.find('input').each(function() { $(this).val(''); $(this).attr('name', $(this).attr('name').replace('_'+nb, '_'+ (nb+1))); }); clone.find('.file').html(''); clone.find('span.nb').html(nb+1); $('#fiche .conducteurs').append(clone); }); var f = $('#ficheForm'); $( "#fiche .jdate" ).each(function() { var year = new Date().getFullYear(); if( $(this).val() == '' ) { $( this ).datepicker({ changeMonth: true, changeYear: true, yearRange : (year - 100) + ':' + (year - 2) }); } else{ $( this ).datepicker({ changeMonth: true, changeYear: true, yearRange : (year - 100) + ':' + (year - 2) }); } }); $('#fiche .modal-footer button').click(function() { $(this).data('save', $(this).html()); $(this).html(translations['Chargement en cours...']); var _button = this; var options = { url: '/ajax/Commande/fiche/' + $(_this).attr('rel') + '?lang='+currentLanguage, success: function(responseText, statusText, xhr, $form) { /* $(_button).html($(_button).data('save')); $('#fiche').modal('hide'); */ self.location.reload(); }, error : function() { $(_button).html($(_button).data('save')); alert('Une erreur est survenue, veuillez réessayer.'); } }; f.ajaxForm(options); f.submit(); }); }); });