$(function() { var slider = $('.slide_container').bxSlider({ mode: 'horizontal', pager: false, controls: true, slideWidth: 320, minSlides: 2, maxSlides: 7, controls: false, moveSlides: 1, touchEnabled: false, slideMargin: 1 }); $('img.next').on('click', function(){ slider.goToNextSlide(); reinitSlides(); }) $('img.prev').on('click', function(){ slider.goToPrevSlide(); reinitSlides(); }) // function myCustomSubmit(form) { //console.log('TODO: myCustomSubmit'); var jqxhr = $.ajax({ type: "POST", url: "scripts/submit_references.php", data: $(form).serialize() }) .done(function(data, textStatus, jqXHR) { //console.log('data.success: ' + data.success); $('#result').html(''); if (data.success) { $('#result').html('

Your mail has been send.

'); } else { $('#result').html('

Due to a technical problem, your email could not be send.

'); } }) .fail(function(jqXHR, textStatus, errorThrown) { $('#result').html(''); $('#result').html('

Due to a technical problem, your email could not be send.

'); //console.log(errorThrown); }) .always(function() { // }); } // validate signup form on keyup and submit $(".contactform").each(function(index){ var self = $(this); self.validate({ submitHandler: function(form) { myCustomSubmit(form); }, rules: { name: { required: true }, company: { required: true }, email: { required: true, email: true }, phone: { required: true } }, errorPlacement: function(error, element) {} }); }); /** * */ function collapseAll() { $('.slide') .each(function(){ var slide = $(this); var frm = slide.find('form'); $(this) .find('.slide_hover') .css({ display: 'none' }); $(this) .find('.fld') .each(function( index ) { $(this) .val('') .removeClass('error'); }); frm.hide(); slide.attr('data-collapsed', true); }); } //console.log( $( window ).width() ); /** * Re-initialise (reset) all slide elements. */ function reinitSlides() { $('.slide') .each(function(){ var slide = $(this); var frm = slide.find('form'); var frmHandle = slide.find('.ref_overview'); var slideHover = slide.find('.slide_hover'); slide.attr('data-collapsed', true); frm .hide() .parent() .find('.ref_overview') .off('click') .on('click', function (evt) { evt.preventDefault(); evt.stopPropagation(); //console.log('CLICK'); frm.toggle(); }); if ( $( window ).width() > 1024 ) { slide .off('mouseleave') .on('mouseleave', function (evt) { frm .find('.fld') .each(function( index ) { $(this) .val('') .removeClass('error'); }) frm.hide(); }); } if ( $( window ).width() <= 1024 ) { slide .off('mouseleave') .on('click', function (evt) { if (slide.attr('data-collapsed') === 'true') { //console.log('COLLAPSED TRUE'); collapseAll(); slideHover.css({ display: 'block' }); //collapsed = false; slide.attr('data-collapsed', false); } else { //console.log('COLLAPSED FALSE'); slideHover.css({ display: 'none' }); //collapsed = true slide.attr('data-collapsed', true); } }); frm.off('click'); frm.on('click', function(evt) { //evt.preventDefault(); evt.stopPropagation(); evt.stopImmediatePropagation(); }); } }); } $('.slide') .each(function(){ var slide = $(this); var frm = slide.find('form'); var frmHandle = slide.find('.ref_overview'); var slideHover = slide.find('.slide_hover'); slide.attr('data-collapsed', true); frm .hide() .parent() .find('.ref_overview') .on('click', function (evt) { evt.preventDefault(); evt.stopPropagation(); //console.log('CLICK'); frm.toggle(); }); if ( $( window ).width() > 1024 ) { slide .on('mouseleave', function (evt) { frm .find('.fld') .each(function( index ) { $(this) .val('') .removeClass('error'); }) frm.hide(); }); } if ( $( window ).width() <= 1024 ) { slide .on('click', function (evt) { if (slide.attr('data-collapsed') === 'true') { //console.log('COLLAPSED TRUE'); collapseAll(); slideHover.css({ display: 'block' }); //collapsed = false; slide.attr('data-collapsed', false); } else { //console.log('COLLAPSED FALSE'); slideHover.css({ display: 'none' }); //collapsed = true slide.attr('data-collapsed', true); } }); frm.on('click', function(evt) { //evt.preventDefault(); evt.stopPropagation(); evt.stopImmediatePropagation(); }); } }); });