//é jQuery(document).ready(function () { base.is_touch_device(); base.getAvailWidth(); base.handleBasicBehaviours(); base.handleAjax(); base.forms.placeHolder(); base.forms.autoSize(); base.emailDeObfuscator(['emails']); }); jQuery(window) .load(function () { base.contentReplacement(); base.handleIE6(); // base.splitLst(idElt, classElt, classLi, nbLst); }).resize(function () { // base.getAvailWidth(); }); var touchDevice = false ,de1281aPlus = true ,de1025a1280 = false ,de641a1024 = false ,de0a640 = false ,base = function () { /* Modernizr 2.6.2 (Custom Build) | MIT & BSD * Build: http://modernizr.com/download/#-csscolumns-input-cssclasses-testprop-testallprops-domprefixes */ // window.Modernizr=function(a,b,c){function x(a){j.cssText=a}function y(a,b){return x(prefixes.join(a+";")+(b||""))}function z(a,b){return typeof a===b}function A(a,b){return!!~(""+a).indexOf(b)}function B(a,b){for(var d in a){var e=a[d];if(!A(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function C(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:z(f,"function")?f.bind(d||b):f}return!1}function D(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+n.join(d+" ")+d).split(" ");return z(b,"string")||z(b,"undefined")?B(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),C(e,b,c))}function E(){e.input=function(c){for(var d=0,e=c.length;d to open a pop-up window code: HTML: Clic !! If a parameter is not supplied, the browser uses its default parameter. ---------> to get out of the frames code: HTML: Up ---------> to close a window code: HTML: Close ---------> to open a confirm dialog box code: HTML: Ask a question ---------> to go back in history code: HTML: Rewind */ ,handleBasicBehaviours = function () { jQuery("a.popUp").off('click').on('click', function (e) { var monElt = jQuery(this) ,eltU = monElt.attr('href') ,eltW = findData(monElt, 'width', null) ,eltH = findData(monElt, 'height', null) ,eltT = findData(monElt, 'target', null) ,eltO = findData(monElt, 'other', null) ,params = eltW ? ',width=' + eltW : null; params += eltH ? ',height=' + eltH : null; params += eltO ? ',' + eltO : null; window.open(eltU, eltT, params); e.preventDefault(); }); // target="_top" simulator jQuery("a.winTop").off('click').on('click', function (e) { var monElt = jQuery(this) ,eltU = monElt.attr('href'); top.location.href = lien; e.preventDefault(); }); // closeBtn jQuery('a.closeLnk').off('click').on('click', function (e) { window.close(); e.preventDefault(); }); // Confirm alerts jQuery('a.confirm').off('click').on('click', function (e) { var monElt = jQuery(this) ,eltU = monElt.attr('href') ,eltM = findData(monElt, 'message', trads[jQuery('html').attr('lang')]['confirm']); if (confirm(eltM)) { location.href = jQuery(this).attr('href'); } e.preventDefault(); }); // Page précédente jQuery('a.goBack').on('click', function (e) { window.history.back(); e.preventDefault(); }); // Imprimer jQuery('a.print').on('click', function (e) { window.print(); e.preventDefault(); }); } /* Élargir la "clickabilité à un élément au-dessus d'un lien Si "true" est passé en second argument, les classes sont transmises */ ,enlargeClick = function ($selector, mode) { jQuery($selector).each(function () { var $this = jQuery(this) ,lnk = $this.find('a').attr('href') ,title = $this.find('a').attr('title') ,classes = typeof mode != 'undefined' && mode ? $this.find('a').attr('class') : null; $this .attr('title', title) .attr('class', classes) .on('click', function () { location.href = lnk; }); }); } /* This function handles ajax' type form calls */ ,handleAjax = function (ajaxClassNames) { var selectorString = '' ,separator = '' ,i = 0; ajaxClassNames = typeof ajaxClassNames != 'undefined' ? ajaxClassNames : ['discreet']; for (i; i < ajaxClassNames.length; i++) { selectorString += separator + 'form.' + ajaxClassNames[i]; separator = ', '; } jQuery(selectorString).each(function () { jQuery(this).on('submit', function () { sablier(); var monForm = jQuery(this).attr('id') ,actionFile = jQuery(this).attr('action') ,fields = jQuery(this).serialize(); jQuery('#' + monForm).find('.infoMsg').fadeTo(1, 1).hide(); jQuery.ajax({ type: "POST" ,url: actionFile ,data: fields + '&ajax=1' ,dataType: "json" ,success: function (data) { sablier(); var errNull, errHS, errErr, errCAPTCHA; if (data.etat == 'null') { errNull = jQuery('#' + monForm).find('.errNull'); errNull .show('fast', function () { setTimeout(function () { jQuery('.line').removeClass('missing'); for (var i in data.url) { if (data.url[i] == 0) { jQuery('#' + i).parent('.line').addClass('missing'); jQuery('#'+i).val('').focus(); } } setTimeout(function () { if (errNull.css('opacity') == 1) { errNull.fadeTo(800, .05).slideUp(1000); } }, 2000); }, 1000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else if (data.etat == 'HS') { jQuery('#' + monForm + ' .hs').show('fast', function () { setTimeout(function () { jQuery('#' + monForm + ' .hs').fadeOut('slow'); }, 3000); }); errHS = jQuery('#' + monForm).find('.errHS'); errHS .show('fast', function () { setTimeout(function () { jQuery('.line').removeClass('missing'); for (var i in data.url) { if (data.url[i] == 0) { jQuery('#' + i).parent('.line').addClass('missing'); jQuery('#'+i).val('').focus(); } } setTimeout(function () { if (errHS.css('opacity') == 1) { errHS.fadeTo(800, .05).slideUp(1000); } }, 2000); }, 1000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else if (data.etat == 'err') { jQuery('#' + monForm + ' .err').show('fast', function () { setTimeout(function () { jQuery('#' + monForm + ' .err').fadeOut('slow'); }, 3000); }); errErr = jQuery('#' + monForm).find('.errErr'); errErr .show('fast', function () { setTimeout(function () { if (errErr.css('opacity') == 1) { errErr.fadeTo(800, .05).slideUp(1000); } }, 3000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else if (data.etat == 're') { jQuery('#' + monForm + ' .errCAPTCHA').show('fast', function () { setTimeout(function () { jQuery('#' + monForm + ' .errCAPTCHA').fadeOut('slow'); }, 3000); }); errCAPTCHA = jQuery('#' + monForm).find('.errCAPTCHA'); errCAPTCHA .show('fast', function () { setTimeout(function () { if (errCAPTCHA.css('opacity') == 1) { errCAPTCHA.fadeTo(800, .05).slideUp(1000); } }, 3000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else if (data.etat == 'ok') { // Sortie positive if (data.url == 31) { location.href = data.infoAdmin; } else if (data.url == 47) { Object.size = function (obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) { size++; } } return size; }; nbElts = Object.size(data) - 2; mesData = data; var maListe = ''; jQuery('#distributeurs').append(maListe); } else { // Pour intercepter le formulaire s'il est recopié dans un pop-in var dansPopIn = jQuery('.pp_pic_holder').length > 0 ? '.pp_pic_holder ' : ''; jQuery(dansPopIn + '#' + monForm).last().find('.ok').show('fast', function () { jQuery(this).siblings('fieldset, .legende').hide(); // Fermeture automatique de pop-in if (data.url == 22) { setTimeout(function () {jQuery('.pp_close').click();}, 3000); } // Redirection automatique if (typeof redirect != 'undefined') { leLnk = jQuery(this).find('[data-rel="redirectURL"]').attr('href'); setTimeout(function () {location.href = leLnk;}, redirect); } }) } } } ,error: function (data) { sablier(); var err404, errMail, errAjax; if (data.status == '404') { err404 = jQuery('#' + monForm).find('.err404'); err404 .show('fast', function () { setTimeout(function () { if (err404.css('opacity') == 1) { err404.fadeTo(800, .05).slideUp(1000); } }, 5000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else if (data.responseText.indexOf('function.mail') > 0) { errMail = jQuery('#' + monForm).find('.errMail'); errMail .slideDown('slow', function () { setTimeout(function () { if (errMail.css('opacity') == 1) { errMail.fadeTo(800, .05).slideUp(1000); } }, 3000); }) .on('click', function () { clearTimeout(); jQuery(this).fadeTo(800, .05).slideUp(1000); }); } else{ errAjax = jQuery('#' + monForm).find('.errAjax'); errAjax .show('fast', function () { setTimeout(function () { if (errAjax.css('opacity') == 1) { errAjax.fadeTo(800, .05).slideUp(1000); } }, 5000); }) .on('click', function () { jQuery(this).fadeTo(800, .05).slideUp(1000); }); } } }); return false; }); }); } /* This function handles iframe and flash replacements ---------> iframes code: JS: base.contentReplacement(); HTML:
get the content
If URL is not supplied, not replacement is done. If width and height are not supplied, their values are set to "100%" "iframeCtnr" is the default called class but you can customize it. Several class names can be used at the same time. code: JS: base.contentReplacement({iframe:['myIframe']}); JS: base.contentReplacement({iframe:['myIframe', 'myOtherIframeClass']}); HTML:
... ---------> flash code: JS: base.contentReplacement(); HTML:
path/to/the/file.swf
If URL is not supplied, not replacement is done. If wmode is not supplied, its value is set to "transparent" If width and height are not supplied, their values are set to "100%" "flashCtnr" is the default called class but you can customize it. Several class names can be used at the same time. code: JS: base.contentReplacement({flash:['myFlash']}); JS: base.contentReplacement({flash:['myFlash', 'myOtherFlashClass']}); HTML:
... */ ,contentReplacement = function (params) { var iframeClassNames = typeof params == 'object' && typeof params['iframe'] != 'undefined' ? params['iframe'] : ['iframeCtnr'] ,flashClassNames = typeof params == 'object' && typeof params['flash'] != 'undefined' ? params['flash'] : ['flashCtnr'] ,selectorStringBuilder = function (lesClasses) { var selectorString = '' ,separator = '' ,i = 0; for (i; i < lesClasses.length; i++) { selectorString += separator + '.' + lesClasses[i]; separator = ', '; } return selectorString; } ,iframeSelectorString = selectorStringBuilder(iframeClassNames) ,flashSelectorString = selectorStringBuilder(flashClassNames); jQuery(iframeSelectorString).each(function () { var myElt = jQuery(this).find('.eltData') ,eltU = findData(myElt, 'url', false) ,eltW = findData(myElt, 'width', '100%') ,eltH = findData(myElt, 'height', '100%'); if (eltU) { jQuery('*', this).remove(); jQuery(this) .width(eltW) .height(eltH) .html(''); } }); jQuery(flashSelectorString).each(function () { var myElt = jQuery(this).find('.eltData') ,eltU = findData(myElt, 'url', false) ,eltM = findData(myElt, 'wmode', 'transparent') ,eltW = findData(myElt, 'width', '100%') ,eltH = findData(myElt, 'height', '100%'); if (eltU) { jQuery('*', this).remove(); jQuery(this).media({ src: eltU ,width: eltW ,height: eltH ,bgColor: '' ,params: {wmode: eltM} ,attrs: {wmode: eltM} } , { update: false }); } }); } /* This function handles the IE6 alert message */ ,handleIE6 = function () { var hideClass = 'closed'; if (jQuery.cookie('ie6AlertMsg') != 'off') { jQuery('.ie6, .ie7').find('#ie6').each(function () { var ctnr = this; jQuery(ctnr).on('mouseenter', function () { jQuery(this).toggleClass('hover'); }).on('mouseleave', function () { jQuery(this).toggleClass('hover'); }); jQuery('') .attr('class', 'close') .text(trads[jQuery('html').attr('lang')]['fermer']) .on('click', function () { jQuery(ctnr).addClass(hideClass); jQuery.cookie('ie6AlertMsg', 'off'); }) .appendTo('.ctnt', ctnr); }); } else { jQuery('.ie6, .ie7').find('#ie6').addClass(hideClass); } } /* This function handles a placeholder behaviour for browser that don't support in natively */ ,placeHolder = function () { if (!Modernizr.input.placeholder) { jQuery('[placeholder]').each(function () { var monChamp = jQuery(this); monChamp .addClass('placeholder') // IE .on('focus', function () { if (monChamp.val() == monChamp.attr('placeholder') || '') { monChamp.val(''); } }) .on('blur', function () { if (monChamp.val() == '') { monChamp.val(monChamp.attr('placeholder')); } }) .blur() .parents('form') .on('submit', function () { if (monChamp.val() == monChamp.attr('placeholder')) { monChamp.val(''); } }); }); } else { return true; } } /* This function handles autosizing of textareas during typing */ ,autoSize = function (autosizeClassNames) { var selectorString = '' ,separator = '' ,i = 0; autosizeClassNames = typeof autosizeClassNames != 'undefined' ? autosizeClassNames : ['autoSize']; for (i; i < autosizeClassNames.length; i++) { selectorString += separator + 'textarea.' + autosizeClassNames[i]; separator = ', '; } jQuery(selectorString).each(function () { var tArea = jQuery(this); jQuery(tArea) .data({ 'default': jQuery(this).val() ,'w': jQuery(this).width() ,'ttransform': jQuery(this).css('text-transform') ,'lheight': jQuery(this).css('line-height') ,'wspacing': jQuery(this).css('word-spacing') ,'ffamily': jQuery(this).css('font-family') ,'fsize': jQuery(this).css('font-size') ,'fweight': jQuery(this).css('font-weight') ,'lspacing': jQuery(this).css('letter-spacing') ,'wrap': jQuery(this).css('word-wrap') }) .after('
') .next() .css({ position: 'absolute' ,left: '-9999em' ,width: jQuery(tArea).data('w') ,'text-transform': jQuery(tArea).data('ttransform') ,'line-height': jQuery(tArea).data('lheight') ,'word-spacing': jQuery(tArea).data('wspacing') ,'font-family': jQuery(tArea).data('ffamily') ,'font-size': jQuery(tArea).data('fsize') ,'font-weight': jQuery(tArea).data('fweight') ,'letter-spacing': jQuery(tArea).data('lspacing') ,'word-wrap': jQuery(tArea).data('wrap') }) .text(jQuery(tArea).data('default')) .data('newH', jQuery(tArea).next().height()); jQuery(tArea) .css('min-height', jQuery(tArea).next().data('newH')) .on('keyup blur', function () { var content = jQuery(tArea).val().replace(/\n/g, '
').replace(/(\s) /g, '$1 '); jQuery(tArea).next() .html(content + "
  ") .data('newH', jQuery(tArea).next().height()) .end() .css('min-height', jQuery(tArea).next().data('newH')); }); }); } /* Gestion d'une navigation "flottante" */ ,floatingElt = jQuery('#floatingBar') ,floatingEltStart = floatingElt.length == 1 ? floatingElt.offset().top : 0 ,floatDecalage = jQuery('header').height() ,floatingEltFixed = false ,floatElt = function () { floatingElt.parent().height(floatingElt.outerHeight(true)); var scrollTop = jQuery(window).scrollTop() + floatDecalage ,toFix = scrollTop > floatingEltStart; if (toFix && !floatingEltFixed) { floatingElt.css({ position: 'fixed' ,top: floatDecalage }); floatingEltFixed = true; } else if (!toFix && floatingEltFixed) { floatingElt.css({ position: 'relative' ,top: 'auto' }); floatingEltFixed = false; } } /* Gestion d'une navigation "fantôme" */ ,ghostStart = jQuery('header').outerHeight() ,ghostNav = jQuery('#ghostNav') ,ghostNavHeight = 75 ,ghostNav = function () { var scrollTop = jQuery(window).scrollTop(); if (scrollTop > ghostStart) { if (scrollTop < ghostStart + ghostNavHeight) { ghostNav.height(scrollTop - ghostStart); } else { ghostNav.height(ghostNavHeight); } } else { ghostNav.height(0); } } /* This function splits lists */ ,splitLst = function (nomElt, classElt, classLi, nbLst) { if (!window.Modernizr.csscolumns) { var newLsts = '' ,nbElts = 0 ,i = 1 ,mesLis = jQuery('#' + nomElt + '0 li.' + classLi); for (i; i <= nbLst; i++) { classElt = i == nbLst ? classElt + ' last-child' : classElt; newLsts += '
    <\/ul>'; } jQuery(newLsts).insertAfter('#' + nomElt + '0'); nbElts = Math.ceil(mesLis.length / nbLst) - 1; mesLis.clone().appendTo('#' + nomElt + '1'); for (i = 1; i < nbLst; i++) { jQuery('#' + nomElt + i + ' li.' + classLi + ':gt(' + nbElts + ')').clone().appendTo('#' + nomElt + (i + 1)); jQuery('#' + nomElt + i + ' li.' + classLi + ':gt(' + nbElts + ')').remove(); } jQuery('#' + nomElt + '0').remove(); } } /* This function translates obfuscated e-mail addresses into fully functional mailtos Class to listen : functionName(['class1', 'class2']); Default class to listen : 'courriel' To provide a default subject, type it into the rel attribute and add the subject classname as a second parameter : functionName(['class1', 'class2'], 'subjectClass'); Default class to listen for subject : 'subject' */ ,emailBuilder = function (mailtoClassNames, subjectClass) { var selectorString = '' ,separator = '' ,i = 0 ,pattern = /^http:\/\/www\.([^\/]+)\/(.*?)(\.(html|htm|php|asp))?$/ ,humanDetected = false ,human = function () {}; subjectClass = typeof subjectClass != 'undefined' ? subjectClass : 'subject'; mailtoClassNames = typeof mailtoClassNames != 'undefined' ? mailtoClassNames : ['courriel']; for (i; i < mailtoClassNames.length; i++) { selectorString += separator + 'a.' + mailtoClassNames[i]; separator = ', '; }; human = function () { humanDetected = true; jQuery(selectorString).each(function () { if (pattern.test(jQuery(this).html())) { jQuery(this).html(jQuery(this).html().replace(pattern, '$2@$1')); } else { var monSpan = jQuery('span.accessibility', this); if (monSpan.html() != null) { if (monSpan.html().match(pattern)) { monSpan.html(monSpan.html().replace(pattern, '$2@$1')); } } } }); }; if (!humanDetected) { jQuery(document).mousemove(human).keypress(human); } if (touchDevice) { human(); humanDetected = true; } jQuery(selectorString).on('click', function () { if (!humanDetected) { return false; } if (pattern.test(this.href)) { var subject = jQuery(this).attr('data-rel'); this.href = jQuery(this).hasClass(subjectClass) ? this.href.replace(pattern, 'mailto:$2@$1' + '?Subject=' + subject) : this.href=this.href.replace(pattern, 'mailto:$2@$1'); } }); return false; }; // Public elements : return { trads: trads ,is_touch_device: is_touch_device ,getAvailWidth: getAvailWidth ,extractUrl: extractUrl ,sablier: sablier ,columnizer: columnizer ,handleBasicBehaviours: handleBasicBehaviours ,enlargeClick: enlargeClick ,handleAjax: handleAjax ,contentReplacement: contentReplacement ,handleIE6: handleIE6 ,floatElt: floatElt // ,ghostNav: ghostNav ,forms: { placeHolder: placeHolder ,autoSize: autoSize } ,splitLst: splitLst ,emailDeObfuscator: emailBuilder } }(); /* This extension of jQuery provides $.getUrlVars() method to get a url variable value. // Get object of URL parameters : var allVars = $.getUrlVars(); // Getting URL var by its name : var byName = $.getUrlVar('name'); ref : http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html date : 2011-03-22 */ jQuery.extend({ getUrlVars: function () { var vars = [] ,hash ,hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&') ,i = 0; for (i; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } ,getUrlVar: function (name) { return jQuery.getUrlVars()[name]; } }); /* This small plug-in provides a preloading of images. Usage: jQuery(['img1.jpg', 'img2.jpg', ...]).preload(); Source: http://stackoverflow.com/questions/476679/preloading-images-with-jquery */ jQuery.fn.preload = function() { this.each(function(){ jQuery('').attr('src', this); }); } /** * @desc Enhancing of the trim trimLeft and trimRight functions: possibility to pass one or more characters or a POSIX class * @param string charList the list of characters or the POSIX character class to trim * @return string returns the initial string trimmed demanded * @author Benoit ADAM benoit.adam@gustibus.fr * @thanks Aurelio De Rosa (JSPro) http://jspro.com/raw-javascript/trimming-strings-in-javascript/ */ String.prototype.enhancedTrimLeft = function (charList) { if (charList === undefined) { charList = "\\s"; } return this.replace(new RegExp("^[" + charList + "]+"), ''); } String.prototype.enhancedTrimRight = function (charList) { if (charList === undefined) { charList = "\\s"; } return this.replace(new RegExp("[" + charList + "]+$"), ''); } String.prototype.enhancedTrim = function (charList) { if (charList === undefined) { charList = "\\s"; } return this.enhancedTrimLeft(charList).enhancedTrimRight(charList); } if(jQuery('.product').length > 0){ /*console.log('ok'); jQuery(document).on('found_variation', 'form.variations_form', function(event, variation_data) { console.log('ok2'); //this is called when a valid productis found jQuery('select').chosen({ disable_search: true ,inherit_select_classes: true }); });*/ jQuery(window).load(function() { jQuery('#visuels') .find('ul') .before('
    ') .cycle( { pager: '#pager' ,prev: '#prev' ,next: '#next' ,fx: 'fade' ,speed: 0 ,timeout: 0 ,pause: false /* ,pagerAnchorBuilder: function(index, DOMelement){ return ''+ jQuery('img', DOMelement).attr('alt') + ''; } */ } ); customFunctions.unMask(); }); } jQuery("#pa_format option").each(function(){ if(jQuery(this).val() == ''){ return; } var value = jQuery(this).val(); var text = jQuery(this).text(); jQuery("", { type: "radio", name: "pa_format", id: "pa_format_" + value, value: value }).prop({ checked: jQuery(this).is(":checked") }).appendTo(jQuery(this).closest(".variations")).on("click", function(){ jQuery(this).closest(".variations").find("#pa_format").val(jQuery(this).val()).trigger("change"); }); jQuery("", { for: "pa_format_" + value }).text(text).appendTo(jQuery(this).closest(".variations")); }); jQuery("#pa_format").hide(); jQuery(document).ready(function(){ jQuery("select.gift:visible").chosen({ disable_search: true, inherit_select_classes: true }); jQuery("#top").on("click", ".add-gift", function(){ jQuery(".gift-wrapper").addClass("loading"); jQuery.post(wc_add_to_cart_params.ajax_url, { action: "add_gift", gift: jQuery(this).closest("p").find("select").val() }, function(){ jQuery("input.qte").trigger("change"); var d = jQuery("header").height() + jQuery('#floatingBar').height() - 1; jQuery("html, body").animate({ scrollTop: jQuery(".woocommerce-cart-form").offset().top - d }); }); }); jQuery(document.body).on("wc_fragments_refreshed", function(){ jQuery(".gift-wrapper").parent().load(" .gift-wrapper", function(){ jQuery("select.gift:visible").chosen({ disable_search: true, inherit_select_classes: true }); }); }); jQuery(".single-product #visuels li a").on("click", function(e){ e.preventDefault(); }); });