console.warn('Dependencies : Document is not available'); (function(){ let overlay; let img; let close; function selectImagesToZoom(){ if (!overlay) { createElements(); } document.querySelectorAll('.site-container .main div:not(.list) img:not(.news-thumbnail):not(.icon-print-checklist):not(.picture-cond)').forEach(function(pImg){ if (pImg.width < pImg.naturalWidth || window.innerHeight < pImg.height ) { if(!pImg.getAttribute("data-zoom")){ pImg.setAttribute("data-zoom", 1); pImg.style.cursor = 'zoom-in'; pImg.style.width = null; pImg.style.height = null; pImg.addEventListener('click', zoomInHandler); } } else { if(pImg.getAttribute("data-zoom")){ pImg.removeEventListener('click', zoomInHandler); pImg.removeAttribute('data-zoom'); pImg.style.cursor = 'default'; } } }); } function zoomInHandler(e){ img.style.display = 'block'; overlay.classList.remove('hidden'); img.style.opacity = 0; if (document.getElementById('QSIFeedbackButton-btn')) { document.getElementById('QSIFeedbackButton-btn').style.display = 'none'; } let w; let h; let target = e.currentTarget; img.src = target.src; img.onload = function(){ img.style.opacity = 1; w = img.naturalWidth; h = img.naturalHeight; img.dataset.w = img.style.width = target.offsetWidth + 'px'; img.dataset.h = img.style.height = target.offsetHeight + 'px'; if (window.innerWidth < w && window.innerHeight > h) { h = window.innerWidth / w * h; w = window.innerWidth; } if (window.innerWidth > w && window.innerHeight < h) { w = window.innerHeight / h * w; h = window.innerHeight; } if (w > window.innerWidth && h > window.innerHeight) { if (w - window.innerWidth > h - window.innerHeight) { h = window.innerWidth / w * h; w = window.innerWidth; } else { w = window.innerHeight / h * w; h = window.innerHeight; } } w = w + 'px'; h = h + 'px'; M4Tween.killTweensOf(img); M4Tween.to(img, .4, { width:w, height:h }).onComplete(function (){ img.style.cursor = 'zoom-out'; close.style.display = 'flex'; }); } } function zoomOutHandler(e){ overlay.classList.add('hidden'); close.style.display = 'none'; if (document.getElementById('QSIFeedbackButton-btn')) { document.getElementById('QSIFeedbackButton-btn').style.display = 'block'; } M4Tween.killTweensOf(img); M4Tween.to(img, .3, { opacity:0, width:img.dataset.w, height:img.dataset.h }).onComplete(function (){ img.style.display = 'none'; }); img.onload = function(){}; } function createElements(){ overlay = document.createElement('div'); overlay.classList.add('zoom-overlay'); overlay.classList.add('hidden'); overlay.addEventListener('click', zoomOutHandler); img = document.createElement('img'); img.classList.add('zoom-img'); img.addEventListener('click', zoomOutHandler); document.body.appendChild(overlay); document.body.appendChild(img); close = document.createElement('div'); close.classList.add('close_zoom'); close.innerHTML = '×'; document.body.appendChild(close); close.addEventListener('click', zoomOutHandler); document.addEventListener('keydown', function(event){ if(event.key === "Escape"){zoomOutHandler()} }); } window.addEventListener('DOMContentLoaded', selectImagesToZoom); window.addEventListener('resize', selectImagesToZoom); })(); class Facet { inputs; facetsContainer; documentContent;request; facetsLoader; FACETS_LOADER = '.facets-loader'; beforeCallback = function () { }; afterCallback = function () { }; constructor(pBefore, pAfter) { let instance = this; this.beforeCallback = function(pElement) { instance.eraseResults(pElement); pBefore(pElement); } this.afterCallback = function (pElement, pResults){ instance.replaceResults(pElement, pResults) pAfter(pElement, pResults); }; this.initElements(); if(this.inputs) this.inputs.forEach(function (pFacet){ pFacet.addEventListener('change',function(e){instance.onChangeFacet(e)}); }); } initElements() { this.facetsContainer = document.querySelector('.facets-container'); if(this.facetsContainer) { this.inputs = this.facetsContainer.querySelectorAll('.facets .facet > input'); this.documentContent = document.querySelector('.document > .content'); this.facetsLoader = document.querySelector(this.FACETS_LOADER); } } onChangeFacet(e){ let form = e.target.closest('.facets'); let baseUrl = form.dataset.dest ? atob(form.dataset.dest): window.location.origin + window.location.pathname; let checkedOptions = form.querySelectorAll(':checked'); let params = []; let target = document.querySelector(form.dataset.target); checkedOptions.forEach(function (pOption) { let name = pOption.getAttribute('name'); let value = pOption.getAttribute('value'); if(value != undefined) { if( params[name]) params[name] += '&'+name+'='+value; else params[name] = value; } }) let get = uriEncode(params); history.replaceState({}, '', baseUrl + get); params['render'] = '1'; this.request = makeRequest(baseUrl, params, target, this.beforeCallback, this.afterCallback, this.request); } eraseResults(pElement){ showLoader(this.facetsLoader, 'auto'); pElement.innerHTML = ''; } replaceResults(pElement, pResults) { hideLoader(this.facetsLoader); pElement.innerHTML = pResults; this.initElements(); } } class Pagination { baseUrl; refreshButton = null; beforeCallback = function () { }; afterCallback = function () { }; request; resultClass = ''; PAGINATION_CLASS = '.link-pagination'; PAGINATION_BTN_CLASS = '.link-see-more-action'; LOADER_CLASS = '.loader'; paginationBox; paginationLoader; resultLinksNumber; totalResultLinksNumber; progressionBar; constructor(pResultClass, pBaseUrl, pBefore, pAfter, pRequest) { let instance = this; this.beforeCallback = function(pElement) { instance.showPaginationLoader(); pBefore(pElement); } this.afterCallback = function (pElement, pResultLinks){ instance.hidePaginationLoader(); pAfter(pElement, pResultLinks); instance.refresh(true); }; this.request = pRequest; this.resultClass = pResultClass; this.baseUrl = pBaseUrl; this.initElements(); this.init(); } init() { this.initElements(); if(this.refreshButton) { let instance = this; this.refreshButton.addEventListener('click', function (){ instance.onClickSeeMore(); }); } } initElements() { this.refreshButton = document.querySelector(this.PAGINATION_BTN_CLASS); this.paginationBox = document.querySelector(this.PAGINATION_CLASS); this.paginationLoader = document.querySelector(this.LOADER_CLASS + '.pagination-loader'); this.resultLinksNumber = document.querySelector(this.PAGINATION_CLASS + ' .nb-links'); this.totalResultLinksNumber = document.querySelector(this.PAGINATION_CLASS + ' .total-results'); this.progressionBar = document.querySelector(this.PAGINATION_CLASS + ' .pagination-bar-progress'); this.baseUrl = window.location.origin + window.location.pathname; } onClickSeeMore() { let params = []; params['page'] = this.refreshButton.dataset.next_page ; params['render'] = '1'; params['listOnly'] = '1'; this.request = makeRequest(this.baseUrl, params, this.paginationBox, this.beforeCallback, this.afterCallback, this.request) } showPaginationLoader() { showLoader(this.paginationLoader, 'auto'); } hidePaginationLoader(){ hideLoader(this.paginationLoader); } refresh(pNextPage) { this.initElements(); let nbDisplayedResultLinks = document.querySelectorAll(this.resultClass).length; let nbTotalResultLinks = parseInt(this.totalResultLinksNumber.innerHTML); this.resultLinksNumber.innerHTML = nbDisplayedResultLinks; this.progressionBar.style.width = (nbDisplayedResultLinks / nbTotalResultLinks) * 100 + '%'; if (this.refreshButton) { let maxPage = this.refreshButton.dataset.nb_page; let nextPage = parseInt(this.refreshButton.dataset.next_page) + 1; if (nbDisplayedResultLinks >= nbTotalResultLinks || (pNextPage && nextPage > maxPage)) this.refreshButton.style.display = 'none'; else if (pNextPage) this.refreshButton.dataset.next_page = nextPage + ''; } } } (function () { const RESULT_LINK_CLASS = '.news-link'; const RESULT_LINKS_BOX_CLASS = '.news-list'; let resultLinksList; let baseUrl = window.location.origin + window.location.pathname; let retrieveAndShowRequest; let pagination, facet; function init() { initElements(); initPagination(); initFacet(); } function initElements() { resultLinksList = document.querySelector(RESULT_LINKS_BOX_CLASS); } function initPagination() { try { pagination = new Pagination(RESULT_LINK_CLASS+':not(.loading)', baseUrl, beforeLoading, appendToResultLinks, retrieveAndShowRequest); } catch (e){} } function initFacet(){ facet = new Facet(beforeLoading, function (){initElements(); initPagination()}); } function beforeLoading() { } function appendToResultLinks(pElement, pResultLinks) { let resultLinks = createHtml('ul', pResultLinks).childNodes; resultLinks.forEach(function (e) { resultLinksList.appendChild(e); }) } function createHtml(pHtml, pResultLinks) { let div = document.createElement(pHtml); div.innerHTML = pResultLinks.trim(); return div; } window.addEventListener('DOMContentLoaded', init, true); })(); class PAYoutubePlayer { constructor() { this.paCustomParams = {}; this.mediaInit = false; } set params(params) { this.paCustomParams = params; } set media(media) { this.videoMedia = media; } onPlayerReady = (event) => { this.instanciatedPlayer = event.target; }; onPlayerStateChange = (event) => { var videoData = this.instanciatedPlayer.getVideoData(); this.paCustomParams.av_content_id = videoData.video_id; this.paCustomParams.av_content = videoData.title; this.paCustomParams.av_content_duration = this.instanciatedPlayer.getDuration() * 1000; this.paCustomParams.av_broadcasting_type = videoData.isLive ? "Live" : "Clip"; this.videoMedia.setProps(this.paCustomParams); var cursorPosition = this.instanciatedPlayer.getCurrentTime() * 1000; if (event.data === 1 && (this.previousPlayerState == -1 || !this.mediaInit)) { this.videoMedia.play(cursorPosition); this.videoMedia.playbackStart(cursorPosition); this.mediaInit = true; } if (event.data === 1 && this.previousPlayerState == 5) { this.videoMedia.playbackStart(cursorPosition); } if (event.data === 1 && this.previousPlayerState > 1) { this.videoMedia.playbackResumed(cursorPosition); } if (event.data === 2) { this.videoMedia.playbackPaused(cursorPosition); } if (event.data === 0 || (this.previousPlayerState == -1 && this.mediaInit)) { this.videoMedia.playbackStopped(cursorPosition); this.mediaInit = false; } if (event.data === 3 && this.previousPlayerState != -1) { this.videoMedia.bufferStart(cursorPosition); this.mediaInit = true; } this.previousPlayerState = this.instanciatedPlayer.getPlayerState(); }; onError = (event) => { var errorCode; switch (event.data) { case 2: errorCode = "The request contains an invalid parameter value."; break; case 5: errorCode = "The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred."; break; case 100: errorCode = "The video requested was not found."; break; case 101: errorCode = "The owner of the requested video does not allow it to be played in embedded players."; break; case 150: errorCode = "This error is the same as 101. It's just a 101 error in disguise!"; break; } this.videoMedia.error(errorCode, function () { }, { av_player_error: errorCode, }); }; onPlaybackQualityChange = (event) => { if (this.mediaInit) { this.videoMedia.quality(function () { }, { av_quality: event.data }); } }; onPlaybackRateChange = (event) => { this.videoMedia.setPlaybackSpeed(event.data); }; } const paYoutubeConnector = new PAYoutubePlayer(); (function () { function init() { const iframes = document.querySelectorAll('iframe[src*="youtube"], iframe[src*="if-cdn"]'); if (iframes.length === 0 || !window.pa) return; if (typeof(YT) == 'undefined' || typeof(YT.Player) == 'undefined') { var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); } window.onYouTubeIframeAPIReady = function() { iframes.forEach((el) => { new YoutubeConnectorHandler(el, "VIDAL France"); }); }; } window.addEventListener('DOMContentLoaded', init, true); })(); class YoutubeConnectorHandler { constructor(iframe, author) { this.author = author; const id = this.extractVideoId(iframe.src); if (!iframe.src.includes('enablejsapi=1')) iframe.src += iframe.src.includes('?') ? '&enablejsapi=1' : '?enablejsapi=1'; var player = new YT.Player(iframe, { videoId: id, events: { onReady: paYoutubeConnector.onPlayerReady, onStateChange: paYoutubeConnector.onPlayerStateChange, onError: paYoutubeConnector.onError, onPlaybackQualityChange: paYoutubeConnector.onPlaybackQualityChange, onPlaybackRateChange: paYoutubeConnector.onPlaybackRateChange, }, }); paYoutubeConnector.media = new pa.avInsights.Media(5, 5); paYoutubeConnector.onPlayerReady(player); paYoutubeConnector.params = { 'av_author': this.author, 'av_content_type': 'Vidéo', }; } extractVideoId(src) { if (src.includes('embed/')) { let startIndex = src.indexOf('embed/') + 6; let endIndex = src.indexOf('?') > -1 ? src.indexOf('?') : src.length; return src.substring(startIndex, endIndex); } else { return null; } } } console.warn('Dependencies : Article is not available'); // requestAnim shim layer by Paul Irish window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(/* function */ callback){ window.setTimeout(callback, 1000 / 60); }; })(); /** * M4Tween - Javascript animation library * Copyright (C) 2009 - 2015 NICOLAS Arnaud * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ if(!window["M4"]) var M4 ={}; M4.browser = (function() { var ua = navigator.userAgent; return { IE:ua.indexOf("MSIE")>-1, FF:ua.indexOf("Firefox")>-1, CHROME:ua.indexOf("Chrome")>-1, SAFARI:ua.indexOf("AppleWebKit")>-1&&ua.indexOf("Chrome")===-1 }; })(); function M4Tween(){this.configure(null, null, 0, null, 0, null);} M4Tween.prototype = { configure:function (pTarget, pFirstInfos, pDuration, pEase, pDelay, pStyle) { this.startHandler = null; this.updateHandler = null; this.completeHandler = null; this.startTime = null; this.delay = pDelay; this.target = pTarget; this.context = pStyle?this.target.style:this.target; this.useStyle = pStyle; this.firstInfos = pFirstInfos; this.durationTime = pDuration; this.ease = pEase; }, start:function() { this.waiting = null; this.startTime = new Date().getTime(); var f = this.firstInfos, t = this.target; if(this.useStyle) { if(document&&document.defaultView&&document.defaultView.getComputedStyle) t = document.defaultView.getComputedStyle(this.target, null); else if (this.target.currentStyle) t = this.target.currentStyle; else t = this.target.style; } while(f) { f.extractStartValue(t, this.useStyle, this.context); f = f.next; } if(this.startHandler) { this.startHandler(); } }, update:function(pDt) { var timer, t, factor, i; timer = (pDt - this.startTime) * .001; t = (timer>16), null,null); this.g = new M4TweenInfos("g",((this.finalValue&parseInt("00FF00", 16))>>8), null,null); this.b = new M4TweenInfos("b",(this.finalValue&parseInt("0000FF", 16)), null,null); } M4TweenColorInfos.prototype = { update:function (pFactor) { var r = Math.round(this.r.startValue+ (pFactor * this.r.distanceValue)); var g = Math.round(this.g.startValue+ (pFactor * this.g.distanceValue)); var b = Math.round(this.b.startValue+ (pFactor * this.b.distanceValue)); return "rgb("+r+", "+g+", "+b+")"; }, setStartValue:function(pValue) { this.startValue = Number(pValue); this.r.setStartValue((this.startValue&parseInt("FF0000", 16))>>16); this.g.setStartValue((this.startValue&parseInt("00FF00", 16))>>8); this.b.setStartValue(this.startValue&parseInt("0000FF", 16)); } }; if(typeof(M4TweenPlugins)=="undefined") function M4TweenPlugins(){} M4TweenPlugins.color = { extractStartValue:function(pCtx) { var t; if(t = pCtx[this.property].match(/rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/i)) this.setStartValue(t[1]<<16|t[2]<<8|t[3]); else if(t = pCtx[this.property].match(/#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})/i)) this.setStartValue(parseInt(t[1],16)<<16|parseInt(t[2],16)<<8|parseInt(t[3],16)); }, newInfos:function(pProperty, pFinalValue) { return new M4TweenColorInfos(pProperty, parseInt(pFinalValue.replace("#", ""), 16)); } }; M4TweenPlugins.backgroundColor = {}; for(var i in M4TweenPlugins.color) { if(M4TweenPlugins.color.hasOwnProperty(i)) M4TweenPlugins.backgroundColor[i] = M4TweenPlugins.color[i]; } M4TweenPlugins.opacity = { extractStartValue:function(pCtx, pStyle) { var s = pCtx[this.property]; if(pStyle && M4.browser.IE && (!document["documentMode"] || document["documentMode"] < 9)) { try { s = s.replace(/alpha\(opacity=/,""); s = s.replace(/\)/,""); s = s!==""?s:100; } catch(ex){s = 100;} } this.setStartValue(s); }, newInfos:function(pProperty, pFinalValue, pStyle) { var prop = "opacity", template; if(pStyle && M4.browser.IE && (!document["documentMode"] || document["documentMode"] < 9)) { pFinalValue *= 100; prop = "filter"; template = "alpha(opacity=#value#)"; } return new M4TweenInfos(prop, pFinalValue, "", template); } }; M4TweenPlugins.defaultProp = { extractStartValue:function(pCtx, pUseStyle, pRealCtx) { var current = String(pCtx[this.property]); if(this.type === "%"&&String(current).replace(/(px|%)/,"")!=="0") { var setCtx = pCtx; if(pUseStyle) setCtx = pRealCtx; setCtx[this.property] = "auto"; var max = String(pCtx[this.property]).replace(/(px|%)/, ''); setCtx[this.property] = current; current = Math.round((current.replace(/(px|%)/, "") / max) * 1000)/10; } this.setStartValue(String(current).replace(/(px|%)/,"")); }, newInfos:function(pProperty, pFinalValue) { var s = String(pFinalValue), type = "", p = s.search(/(px|%)/); if(p>-1) type = s.substr(p); return new M4TweenInfos(pProperty, s.replace(/(px|%)/,""), type, null); } }; M4TweenPlugins.rotate = { extractStartValue:function(pCtx) { var v = M4TweenGenericInfos.transform.extractStartValue(pCtx, this.property, this.templateValue.split("#value#"), function(pT){ var c = Number(pT[0]); var s = Number(pT[1]); var value = Math.atan2(s, c) * (180 / Math.PI); if(value < 0) value = 360 - value; return value; }); this.setStartValue(v); }, newInfos:function(pProperty, pFinalValue) { return M4TweenGenericInfos.transform.newInfos(pFinalValue, "rotate(#value#)", "deg"); } }; M4TweenPlugins.translateX = { extractStartValue:function(pCtx) { var v = M4TweenGenericInfos.transform.extractStartValue(pCtx, this.property, this.templateValue.split("#value#"), function(pT){ return Number(pT[4])||0; }); this.setStartValue(v); }, newInfos:function(pProperty, pFinalValue) { return M4TweenGenericInfos.transform.newInfos(pFinalValue, "translateX(#value#)", "(px|%)"); } }; M4TweenPlugins.translateY = { extractStartValue:function(pCtx) { var v = M4TweenGenericInfos.transform.extractStartValue(pCtx, this.property, this.templateValue.split("#value#"), function(pT){ return Number(pT[5]); }); this.setStartValue(v); }, newInfos:function(pProperty, pFinalValue) { return M4TweenGenericInfos.transform.newInfos(pFinalValue, "translateY(#value#)", "(px|%)"); } }; M4TweenPlugins.translateZ = { extractStartValue:function(pCtx) { var v = M4TweenGenericInfos.transform.extractStartValue(pCtx, this.property, this.templateValue.split("#value#"), function(pT){ return Number(pT[14]||"0"); }); this.setStartValue(v); }, newInfos:function(pProperty, pFinalValue) { return M4TweenGenericInfos.transform.newInfos(pFinalValue, "translateZ(#value#)", "(px|%)"); } }; var M4TweenGenericInfos = { transform:{ newInfos:function(pFinalValue, pTemplate, pUnits) { var s = String(pFinalValue), p, tpl = pTemplate, t = pUnits, re = new RegExp(pUnits); if((p=s.search(re))>-1) { t = s.substr(p); s = s.replace(re, ""); } if(M4.browser.IE) p = "msTransform"; else if (M4.browser.CHROME||M4.browser.SAFARI) p = "WebkitTransform"; else if (M4.browser.FF) p = "MozTransform"; else p = "transform"; return new M4TweenInfos(p, s, t, tpl); }, extractStartValue:function(pCtx, pProperty, pTemplateParts, pCallback) { var v = pCtx[pProperty], t; if(v) { if(v.indexOf("matrix")>-1) { t = v.split('(')[1].replace(')', '').split(', '); return pCallback(t); } else { v = v.replace(pTemplateParts[0], ""); v = v.replace(pTemplateParts[1], ""); v = v=="none"?0:v; } } else v = 0; return v; } } }; M4Tween.from = function(pStartValue) { return new M4Tween.Dummy(pStartValue); }; M4Tween.Dummy = function(pStartValue) { this.target = {value:pStartValue}; }; M4Tween.Dummy.prototype = { to:function(pEndValue) { this.endValue = pEndValue; return this; }, start:function(pDuration, pOptions) { pDuration = pDuration||1; pOptions = pOptions || {}; pOptions.value = this.endValue; pOptions.useStyle = false; return M4Tween.to(this.target, pDuration, pOptions); } }; /**Easing Equations by Robert Penner (http://www.robertpenner.com/easing/ - BSD License)**/ function Linear(){} Linear.easeNone = function(t, b, c, d){return (c*t/d) + b;}; function Back(){} Back.easeIn = function (t, b, c, d, s){if(!s){s=1.70158;}return c*(t/=d)*t*((s+1)*t - s) + b;}; Back.easeOut = function (t, b, c, d, s){if(!s){s=1.70158;}return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;}; Back.easeInOut = function (t, b, c, d, s){if(!s){s=1.70158;}if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;}; function Bounce(){} Bounce.easeOut = function(t, b, c, d) {if ((t/=d) < (1/2.75)) {return c*(7.5625*t*t) + b;}else if (t < (2/2.75)) {return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;}else if (t < (2.5/2.75)) {return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;} else {return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;}}; Bounce.easeIn = function(t, b, c, d){return c - Bounce.easeOut(d-t, 0, c, d) + b;}; Bounce.easeInOut = function (t, b, c, d){if (t < d/2) return Bounce.easeIn (t*2, 0, c, d) * .5 + b;else return Bounce.easeOut (t*2-d, 0, c, d) * .5 + c*.5 + b;}; function Quad(){} Quad.easeIn = function (t, b, c, d) {return c*(t/=d)*t + b;}; Quad.easeOut = function (t, b, c, d){return -c *(t/=d)*(t-2) + b;}; Quad.easeInOut = function (t, b, c, d){if ((t/=d/2) < 1) return c/2*t*t + b;return -c/2 * ((--t)*(t-2) - 1) + b;}; function Circ(){} Circ.easeIn = function (t, b, c, d){return ((-c * (Math.sqrt(1 - (t/=d)*t) - 1)) + b);}; Circ.easeOut = function (t, b, c, d) {return ((c * Math.sqrt(1 - (t=t/d-1)*t)) + b);}; Circ.easeInOut = function (t, b, c, d){if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;}; function Elastic(){} Elastic.easeOut = function (t, b, c, d, a, p) {var s;if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;if (!a || a < Math.abs(c)) { a=c; s = p/4; }else s = p/(Math.PI*2) * Math.asin (c/a);return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(Math.PI*2)/p ) + c + b);}; Elastic.easeInOut = function (t, b, c, d, a, p){var s;if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); if (!a || a < Math.abs(c)) { a=c; s = p/4; }else s = p/(Math.PI*2) * Math.asin (c/a); if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(Math.PI*2)/p )) + b; return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(Math.PI*2)/p )*.5 + c + b;}; Elastic.easeIn = function (t, b, c, d, a, p){var s;if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;if (!a || a < Math.abs(c)) { a=c; s = p/4; }else s = p/(Math.PI*2) * Math.asin (c/a);return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(Math.PI*2)/p )) + b;}; /** * Utilities */ NodeList.prototype.forEach = Array.prototype.forEach; String.prototype.html_entity_decode = function() { var d = M4.createElement("div", {htmlText:this.toString()}); return d.firstChild.nodeValue; }; Function.prototype.proxy = function(pInstance) { var ref = this; return function(){ref.apply(pInstance, arguments);}; }; Object.clone = function(pData) { var obj = {}; for(var i in pData) { if(!pData.hasOwnProperty(i)) continue; obj[i] = pData[i]; } return obj; }; /** * Base Class * Overriding - toString - whatever */ function Class(){} Class.prototype = { super:function(pMethodName) { pMethodName = pMethodName||"constructor"; if(!this.__SUPER__||!this.__SUPER__[pMethodName]) throw new Error("Method '"+pMethodName+"' undefined"); var args = []; for(var i = 1, max = arguments.length;i0) { for(var i = 0, max=pExtends.length; i= 0; i--) a[i].dispatchEvent(e); if (typeof(this.__listeners[pEvent.type]) == "object" && this.__listeners[pEvent.type].length > 0) { for (i = 0, max = this.__listeners[pEvent.type].length; i < max; i++) { if (this.__listeners[pEvent.type] && this.__listeners[pEvent.type][i]) this.__listeners[pEvent.type][i](pEvent); } } if (pEvent.bubbles) { e = Object.clone(pEvent); e.eventPhase = CEvent.BUBBLING_PHASE; for (i = 0, max = a.length; i < max; i++) a[i].dispatchEvent(e); } break; case CEvent.BUBBLING_PHASE: if (typeof(this.__listeners[pEvent.type]) == "undefined") return; for (i = 0, max = this.__listeners[pEvent.type].length; i < max; i++) this.__listeners[pEvent.type][i](pEvent); break; } } }); function RequestVidal(pTarget, pParams, pMethod) { this.removeAllEventListener(); pMethod = (pMethod||"get").toUpperCase(); this.xhr_object = null; if (window.XMLHttpRequest) this.xhr_object = new XMLHttpRequest(); else if (window.ActiveXObject) { var t = ['Msxml2.XMLHTTP','Microsoft.XMLHTTP'],i = 0; while(!this.xhr_object&&t[i++]) try {this.xhr_object = new ActiveXObject(t[i]);}catch(e){} } if(!this.xhr_object) return; var ref = this, v = "", j = 0; for(i in pParams) v += (j++>0?"&":"")+i+"="+pParams[i]; this.xhr_object.open(pMethod, pTarget, true); this.xhr_object.onprogress = this.dispatchEvent.proxy(this); this.xhr_object.onreadystatechange=function() { if(ref.xhr_object.readyState===4) { var ct = ref.xhr_object.getResponseHeader("Content-type"); if(ct&&ct.indexOf("json")>-1) ref.xhr_object.responseJSON = JSON.parse(ref.xhr_object.responseText); switch(ref.xhr_object.status) { case 200: case 201: case 304: ref.dispatchEvent(new RequestEvent(CEvent.COMPLETE, ref.xhr_object.responseText, ref.xhr_object.responseJSON)); break; case 400: case 401: case 402: case 403: case 404: case 405: case 500: case 503: ref.dispatchEvent(new RequestEvent(RequestEvent.ERROR, ref.xhr_object.responseText, ref.xhr_object.responseJSON)); break; } } }; this.xhr_object.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset:'+RequestVidal.CHARSET); this.xhr_object.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); try { this.xhr_object.send(v); } catch(e) { console.log(e); } } Class.define(RequestVidal, [CEventDispatcher], { onComplete:function(pFunction) { this.addEventListener(CEvent.COMPLETE, pFunction, false); return this; }, onProgress:function(pFunction) { this.addEventListener(RequestEvent.PROGRESS, pFunction, false); return this; }, onError:function(pFunction) { this.addEventListener(RequestEvent.ERROR, pFunction, false); return this; }, cancel:function() { this.dispatchEvent(new RequestEvent(RequestEvent.CANCEL)); this.xhr_object.abort(); } }); RequestVidal.CHARSET = "UTF-8"; RequestVidal.load = function (pUrl, pParams, pMethod){return new RequestVidal(pUrl, pParams, pMethod);}; RequestVidal.update = function(pId, pUrl, pParams){return RequestVidal.load(pUrl, pParams).onComplete(function(pResponse){document.getElementById(pId).innerHTML = pResponse.responseText;});}; function RequestEvent(pType, pResponseText, pResponseJSON, pBubble) { this.super("constructor", pType, pBubble); this.responseText = pResponseText||""; this.responseJSON = pResponseJSON||{}; } Class.define(RequestEvent, [CEvent], {}); RequestEvent.ERROR = "error"; RequestEvent.CANCEL = "cancel"; RequestEvent.PROGRESS = "progress"; /** * @author Arnaud NICOLAS - arno06@gmail.com */ var Dabox = (function () { var ESCAPE_CODE = 27; var publicAPI = { display: function (pContent, pOptions) { if (!created) createDaBox(); pOptions = pOptions || {}; pOptions.opacities = pOptions.opacities || {}; pOptions.opacities.daboxHide = pOptions.opacities.daboxHide || 0.95; pOptions.opacities.dabox = pOptions.opacities.dabox || 1; var a = document.getElementById("DaboxHide"); var b = document.getElementById("Dabox"); M4Tween.killTweensOf(a); M4Tween.killTweensOf(b); b.innerHTML = ""; b.style.width = "auto"; b.style.overflow = "auto"; b.innerHTML = pContent; a.style.display = "block"; b.style.display = "block"; b.style.filter = "alpha(opacity=0)"; M4Tween.to(a, .2, {"opacity": pOptions.opacities.daboxHide}); M4Tween.to(b, .3, {"opacity": pOptions.opacities.dabox}); var close = document.createElement("div"); a = document.createElement("a"); a.className = "icon-close"; a.href = "#"; close.appendChild(a); b.appendChild(close); close.classList.add('close'); a.addEventListener('click', closeBoxHandler); document.addEventListener('keydown', keydownHandler); if (displayHandler.length) { for (var i = 0, max = displayHandler.length; i < max; i++) { displayHandler[i](); } } }, hide: function () { var a = document.getElementById("DaboxHide"); var b = document.getElementById("Dabox"); M4Tween.killTweensOf(a); M4Tween.killTweensOf(b); M4Tween.to(a, .3, {"opacity": 0}).onComplete(function () { a.style.display = "none"; b.style.display = "none"; if (hideHandler.length) for (var i = 0, max = hideHandler.length; i < max; i++) { hideHandler[i](); } }); M4Tween.to(b, .2, {"opacity": 0}); document.removeEventListener('keydown', keydownHandler); }, register: function (pElement, pIdContent) { if (content[pIdContent]) { pElement.setAttribute("rel", pIdContent); pElement.addEventListener('click', aClickDisplayBox); return; } var t = document.getElementById(pIdContent); if (!t) return; content[pIdContent] = t.innerHTML; t.parentNode.removeChild(t); pElement.setAttribute("rel", pIdContent); pElement.addEventListener('click', aClickDisplayBox); }, unregister: function (pIdContent) { if (content[pIdContent]) delete content[pIdContent]; }, onDisplay: function (pHandler, pReset) { pReset = pReset || false; if (pReset) { displayHandler = []; } displayHandler.push(pHandler); }, onHide: function (pHandler, pReset) { pReset = pReset || false; if (pReset) { hideHandler = []; } hideHandler.push(pHandler); }, isDisplayed: function () { var a = document.getElementById("DaboxHide"); var b = document.getElementById("Dabox"); return a && b && a.style.opacity > 0 && b.style.opacity > 0; }, getDaboxElement: function () { var elt = document.getElementById("Dabox"); return elt ? elt : null; }, registerAsync: function (pElement) { var r = pElement.getAttribute("rel"), t; if (t = r.match(/Dabox\[cbo\:([^\]]+)\]/)) { pElement.setAttribute('rel', t[1]); pElement.addEventListener('click', aClickCboBox); } else if (t = r.match(/Dabox\[async\:([^\]]+)\]/)) { pElement.setAttribute('rel', t[1]); pElement.addEventListener('click', aClickAsyncBox); } } }; var created = false; var content = {}; var displayHandler = []; var hideHandler = []; function keydownHandler(e) { if (e.keyCode === ESCAPE_CODE) { publicAPI.hide(); } } function aClickAsyncBox(e) { if (e) { e.stopImmediatePropagation(); e.stopPropagation(); e.preventDefault(); } var rel = e.currentTarget.getAttribute("rel"); RequestVidal.load(rel).onComplete(displayBoxAjax); } function aClickCboBox(e) { if (e) { e.stopImmediatePropagation(); e.stopPropagation(); e.preventDefault(); } var rel = decodeURIComponent(window.atob(e.currentTarget.getAttribute("rel"))); RequestVidal.load(rel).onComplete(displayBoxAjax); } function displayBoxAjax(pResponse) { var html = pResponse.responseJSON && pResponse.responseJSON.html ? pResponse.responseJSON.html : pResponse.responseText; publicAPI.display(html); } function createDaBox() { var hide = document.createElement("div"); hide.setAttribute("id", "DaboxHide"); document.body.appendChild(hide); var box = document.createElement("div"); box.setAttribute("id", "Dabox"); document.body.appendChild(box); created = true; hide.addEventListener('click', closeBoxHandler); } function closeBoxHandler(e) { if (e) { e.stopImmediatePropagation(); e.stopPropagation(); e.preventDefault(); } publicAPI.hide(); } function aClickDisplayBox(e) { if (e) { e.stopImmediatePropagation(); e.stopPropagation(); e.preventDefault(); } var rel = e.target.getAttribute("rel") ? e.target.getAttribute("rel") : e.target.parentNode.getAttribute('rel'); publicAPI.display(content[rel]); } function initDaBox() { document.querySelectorAll('*[rel^="Dabox"]').forEach(function (a) { if (a.rel == "") return; var r = a.getAttribute("rel"), t; t = r.match(/Dabox\[([a-z0-9\_\-]+)\]/); t = t ? t[1] : null; if (t) { publicAPI.register(a, t); } publicAPI.registerAsync(a); }); } NodeList.prototype.forEach = Array.prototype.forEach; window.addEventListener("load", initDaBox); return publicAPI; })(); var Scroll = { __offsets:[], __scrollHandler:function(e) { var o, currentHash; for(var i = 0, max = Scroll.__offsets.length-1;i= o.offset && window.scrollY b.offset) return 1; return 0; }); }, selectHash:function(pHash){ document.querySelectorAll('a.current') .forEach(function(a) { a.classList.remove("current"); }); document.querySelectorAll('a[href*="'+pHash+'"]') .forEach(function(a) { a.classList.add("current"); }); }, prepareAll:function(pSelector) { var els = document.querySelectorAll(pSelector); els.forEach(function(pEl){pEl.setAttribute("data-scrollTop", Scroll.offsetTop(pEl));}); }, to:function(pElement, pTime) { pTime = pTime||.5; var st = Number(pElement.getAttribute("data-scrollTop")||Scroll.offsetTop(pElement)); var t = document.documentElement.scrollTop ? document.documentElement:document.body; M4Tween.killTweensOf(t); return M4Tween.to(t, pTime, {useStyle:false, scrollTop:st}); }, offsetTop:function(pElement) { if(pElement==undefined) return 0; var v = pElement.offsetTop; var o = pElement.offsetParent; while(o) { v += o.offsetTop; o = o.offsetParent; } return v; } }; (function(){ function init() { Dabox.onDisplay(function () { var img=document.querySelector('#Dabox .img_url_ressource'); var DaboxElement=document.querySelector('#Dabox'); var checkVideo=document.querySelector('#Dabox div.box_popin video.video_player'); var checkVideoYoutube=document.querySelector('#Dabox div.box_popin iframe'); if (checkVideo||img||checkVideoYoutube){ DaboxElement.style.overflow="inherit"; if(checkVideo||img){ DaboxElement.style.width="800px"; DaboxElement.style.maxHeight="50%"; } } }); Dabox.onHide(function(){ document.querySelectorAll('#Dabox div.box_popin video.video_player').forEach(function(pEl) { pEl.pause(); }); document.querySelectorAll('#Dabox div.box_popin iframe').forEach(function(pEls) { pEls.src=''; }); }); } window.addEventListener('DOMContentLoaded', init); })(); (function() { let MAX_RATIO = 0.5; let shadow, container, imgDiv, title, close, viewer, mediaDiv, closeDiv, diapo = {}; let order = []; let index = 0; let numberOfMedia = 0; function init() { const productName = document.querySelector('.title h1').innerHTML; createViewer(); const containers = document.querySelectorAll('.pictures-cond'); containers.forEach(container => { const viewers = container.querySelectorAll('[data-role^="viewer:"]'); if (viewers.length >= 2) { container.classList.add('has-multiple-viewers'); } }); document.querySelectorAll('*[data-role^="viewer:"]').forEach(function (pEl) { if (pEl.nodeName.toLowerCase() === 'a') { pEl.setAttribute('src', pEl.getAttribute('data-src')); } const id_viewer = pEl.getAttribute('data-role').replace('viewer:', ''); if (!diapo[id_viewer]) { diapo[id_viewer] = []; } pEl.setAttribute("data-index", diapo[id_viewer].length); pEl.addEventListener("click", function (e) { const id_viewer = e.currentTarget.getAttribute('data-role').replace('viewer:', ''); display(id_viewer,Number(e.currentTarget.getAttribute('data-index'))); }); numberOfMedia ++; diapo[id_viewer].push({ name: pEl.getAttribute("name") ? pEl.getAttribute("name") : productName, width: null, height: null, img: null, loaded: false, title: pEl.getAttribute("data-title") || pEl.innerHTML, src: pEl.getAttribute('src'), video: pEl.getAttribute('data-video') }); }); order = Object.keys(diapo); document.querySelectorAll('h2.rubric').forEach(function(pEl) { const rubrics=pEl.innerText.toLowerCase(); let length_rubric =document.querySelectorAll('div#'+rubrics+' div.rubric ul li').length; if (length_rubric>2){ for(let i=2;i= order.length) { return order[0]; } else { return order[currentIndex + 1]; } } function prevViewer(currentViewer) { const currentIndex = order.indexOf(currentViewer); if (currentIndex === 0 ) { return order[order.length - 1]; } else { return order[currentIndex - 1]; } } function createThumbnail(pImages,pViewer) { let containerMiniature = document.getElementById('miniature'); if(containerMiniature) document.getElementById('miniature').innerHTML = ""; if (pImages && pImages.length > 1) { if (!containerMiniature) { containerMiniature = document.createElement("div"); containerMiniature.setAttribute('id', "miniature"); container.appendChild(containerMiniature); } for (let i = 0; i < pImages.length; i++) { let miniatureImage = document.createElement("img"); if (pImages[i].video === "1") { miniatureImage.setAttribute('src', './includes/components/2020/imgs/picto-vidalbox-video.png'); miniatureImage.classList.add('miniature-video'); } else { miniatureImage.setAttribute('src', pImages[i].src); } if (i === index) { miniatureImage.classList.add('miniature-current'); } miniatureImage.setAttribute('alt', pImages[i].title); miniatureImage.setAttribute('data-index', i.toString()); miniatureImage.addEventListener("click", function (e) { display(pViewer, Number(e.currentTarget.getAttribute('data-index'))); }) containerMiniature.appendChild(miniatureImage); } } } function triggerImgSwap(){ M4Tween.to(container.querySelector(".media"),.2, {opacity:1}); } function createViewer(){ shadow = document.createElement("div"); shadow.setAttribute("id", "box_viewer_shadow"); shadow.style.cssText = "opacity:0;display:none;"; shadow.addEventListener("click", hideBox, false); document.body.appendChild(shadow); container = document.createElement("div"); container.setAttribute("id", "box_viewer_container"); container.setAttribute("class", "loading"); imgDiv = document.createElement("div"); container.appendChild(imgDiv); title = document.createElement("span"); title.setAttribute('class', 'title box-title'); imgDiv.appendChild(title); closeDiv = document.createElement("div"); closeDiv.setAttribute('class', 'close'); imgDiv.appendChild(closeDiv); close = document.createElement("a"); close.setAttribute('class', 'icon-close'); let img = document.createElement('img'); img.setAttribute('src', 'includes/components/2020/imgs/icon-close-red.png'); img.classList.add('button-tertiary'); close.appendChild(img); closeDiv.appendChild(close); let arrowRight = document.createElement("div"); let arrowLeft = document.createElement("div"); arrowRight.setAttribute('class', 'arrow right') arrowLeft.setAttribute('class', 'arrow left') mediaDiv = document.createElement("div"); mediaDiv.setAttribute('class', 'media'); imgDiv.appendChild(mediaDiv); mediaDiv.appendChild(arrowRight); mediaDiv.appendChild(arrowLeft); close.addEventListener("click", hideBox, false); document.body.appendChild(container); } function hideBox(){ if(document.querySelector('video.current-media')){ document.querySelector('video.current-media').pause(); } M4Tween.killTweensOf(shadow); M4Tween.to(shadow,.3, {opacity:0, delay:.2}).onComplete(function(){shadow.style.display = "none";}); M4Tween.killTweensOf(container); M4Tween.to(container,.3, {opacity:0}).onComplete(function(){ container.style.display = "none"; document.querySelectorAll('.arrow').forEach(function (element) { element.remove(); }); if(document.getElementById('miniature')) document.getElementById('miniature').remove(); document.querySelectorAll('#box_viewer_container #miniature .media').forEach(function (element) { element.setAttribute('class', ''); }); }); } function initPianoAvVideo() { const videos = document.querySelectorAll('.doc_video'); if (!videos) return; videos.forEach((el) => { new PaBoxVideo(el); }); } window.addEventListener("DOMContentLoaded", init, false); })(); class PaBoxVideo { constructor(el) { if (!window.pa) return; this.el = el; this.player = el.querySelector('video'); this.isFirstPlay = true; this.previousPlayerStateSeeked = false; this.cache = 0; this.cache_prev = 0; this.initPianoAvVideo(); } initPianoAvVideo() { this.paMedia = new pa.avInsights.Media(5,5); const date = new Date(this.el.getAttribute('data-date')); const properties = { av_content_id: this.el.getAttribute('data-id'), av_content: this.el.getAttribute('data-title').replace(/<[^>]+>/g, ''), av_content_type: this.el.getAttribute('data-type'), av_author: '', av_publication_date: date.getTime(), }; this.paMedia.setProps(properties); const eventHandlers = { loadedmetadata: () => { this.paMedia.set('av_content_duration', getMs(this.player.duration)); }, playing: () => { if (!this.isFirstPlay && (this.previousPlayerStateSeeked || this.previousPlayerStatePaused) ) { this.paMedia.playbackResumed(getMs(this.player.currentTime)); } else if (this.isFirstPlay) { this.paMedia.play(getMs(this.player.currentTime)); this.paMedia.playbackStart(getMs(this.player.currentTime)); this.isFirstPlay = false; } }, seeked: () => { this.paMedia.seek(getMs(this.cache_prev), getMs(this.player.currentTime)); this.previousPlayerStateSeeked = true; }, pause: () => { this.paMedia.playbackPaused(getMs(this.player.currentTime)); this.previousPlayerStatePaused = true; }, ended: () => { this.paMedia.playbackStopped(getMs(this.player.currentTime)); }, timeupdate: () => { if (this.cache !== this.player.currentTime) { this.cache_prev = this.cache; this. cache = this.player.currentTime; } } }; for (var eventName in eventHandlers) { this.player.addEventListener(eventName, eventHandlers[eventName], false); } } } function getMs(time) { return Math.trunc(time*1000); } const Tab = { callbackOnSelect: () => { }, setup: function (pSelector) { document.querySelectorAll(pSelector).forEach(function (pLi) { pLi.addEventListener("click", tabSelectedHandler, false); }); }, setCallBackOnSelect: function (callBackOnSelect) { Tab.callBackOnSelect = callBackOnSelect; }, selectTab: function (pTabId) { if(!document.querySelector('[data-role="Tab:' + pTabId + '"]')){ return; } tabSelectedHandler({ preventDefault: function () { }, currentTarget: document.querySelector('[data-role="Tab:' + pTabId + '"]') }) }, }; function tabSelectedHandler(e) { e.preventDefault(); const t = e.currentTarget; const id = t.getAttribute("data-role").replace("Tab:", ""); const currentLi = t.parentNode.querySelector(".current"); if (!id) { return; } var content = document.getElementById(id); if (!content) { return; } currentLi.setAttribute("class", ""); t.setAttribute("class", "current"); const currentlyDisplay = document.getElementById(currentLi.getAttribute("data-role").replace("Tab:", "")); currentlyDisplay.style.display = "none"; content.style.display = "inherit"; const permalink = content.querySelector("input[type='hidden']"); if (permalink) { var selectedPermalink = document.getElementById("selected_tab_permalink"); if (selectedPermalink) selectedPermalink.value = permalink.value; } Tab.callBackOnSelect&&Tab.callBackOnSelect(id); } (function () { function init(){ Tab.setup('.tabs li'); } window.addEventListener("DOMContentLoaded", init, false); })(); console.warn('Dependencies : IconsLegend is not available'); /** * complete.ly 1.0.0 * MIT Licensing * Copyright (c) 2013 Lorenzo Puccetti * * This Software shall be used for doing good things, not bad things. * **/ function completely(container, config) { config = config || {}; config.fontSize = config.fontSize || '16px'; config.fontFamily = config.fontFamily || 'sans-serif'; config.promptInnerHTML = config.promptInnerHTML || ''; config.color = config.color || '#333'; config.hintColor = config.hintColor || '#aaa'; config.backgroundColor = config.backgroundColor || '#fff'; config.dropDownBorderColor = config.dropDownBorderColor || '#aaa'; config.dropDownZIndex = config.dropDownZIndex || '100'; // to ensure we are in front of everybody config.dropDownOnHoverBackgroundColor = config.dropDownOnHoverBackgroundColor || '#ddd'; config.placeHolder = config.placeHolder||"Recherche"; var txtInput = document.createElement('input'); txtInput.type ='text'; //txtInput.spellcheck = false; txtInput.style.width = '100%'; txtInput.style.outline = '0'; txtInput.style.border = '0'; txtInput.style.margin = '0'; txtInput.setAttribute('placeholder', config.placeHolder); txtInput.setAttribute('autocomplete', 'off'); var txtHint = txtInput.cloneNode(); txtHint.disabled=''; txtHint.style.position = 'absolute'; txtHint.style.top = '0'; txtHint.style.left = '0'; txtHint.style.borderColor = 'transparent'; txtHint.style.boxShadow = 'none'; txtHint.style.color = config.hintColor; txtHint.style.display = 'none'; txtInput.style.backgroundColor ='transparent'; var wrapper = document.createElement('div'); wrapper.style.position = 'relative'; wrapper.style.outline = '0'; wrapper.style.border = '0'; wrapper.style.margin = '0'; wrapper.style.padding = '0'; var prompt = document.createElement('div'); prompt.style.position = 'absolute'; prompt.style.outline = '0'; prompt.style.margin = '0'; prompt.style.padding = '0'; prompt.style.border = '0'; prompt.style.fontSize = config.fontSize; prompt.style.fontFamily = config.fontFamily; prompt.style.color = config.color; prompt.style.backgroundColor = config.backgroundColor; prompt.style.top = '0'; prompt.style.left = '0'; prompt.style.overflow = 'hidden'; prompt.innerHTML = config.promptInnerHTML; prompt.style.background = 'transparent'; if (document.body === undefined) { throw 'document.body is undefined. The library was wired up incorrectly.'; } document.body.appendChild(prompt); var w = prompt.getBoundingClientRect().right; // works out the width of the prompt. wrapper.appendChild(prompt); prompt.style.visibility = 'visible'; prompt.style.left = '-'+w+'px'; wrapper.style.marginLeft= w+'px'; wrapper.appendChild(txtHint); wrapper.appendChild(txtInput); //noura var dropDown = document.createElement('div'); dropDown.setAttribute('class', 'dropdown'); dropDown.style.position = 'absolute'; dropDown.style.visibility = 'hidden'; dropDown.style.outline = '0'; dropDown.style.padding = '10'; dropDown.style.textAlign = 'left'; dropDown.style.zIndex = config.dropDownZIndex; dropDown.style.cursor = 'default'; dropDown.style.overflowX= 'hidden'; dropDown.style.whiteSpace = 'pre'; var counterKeyPress=0; var createDropDownHistoryController = function(elem) { if (!elem) return { hide: () => {}, shown: () => {}, move : () => {}, click: () => {} } let oldIndex = -1; const histories = elem.querySelectorAll("div.dropdown_history_item_mobility"); const historiesLength = histories.length; histories.forEach(item => { item.addEventListener('mouseover', function() { histories.forEach(i => i.classList.remove('hover')); this.classList.add('hover'); }); item.addEventListener('mouseout', function() { this.classList.remove('hover'); }); }); var p = { hide: function () { elem.style.visibility = "hidden"; }, shown: function () { const vph = (window.innerHeight || document.documentElement.clientHeight); const rect = elem.parentElement.getBoundingClientRect(); const distanceToTop = rect.top - 20; const distanceToBottom = vph - rect.bottom - 20; if (distanceToTop > distanceToBottom*3) elem.style.maxHeight = distanceToTop+'px'; else elem.style.maxHeight = distanceToBottom+'px'; elem.style.visibility = "visible"; }, move : function(step) { const newIndex = oldIndex + step; if (newIndex >= 0 && newIndex < historiesLength) { histories.forEach(i => i.classList.remove('hover')); histories[newIndex].classList.add('hover'); oldIndex = newIndex; } }, click: function() { if (oldIndex >= 0 && oldIndex < historiesLength) histories[oldIndex].click(); } } return p; } var createDropDownController = function(elem) { var rows = []; var ix = -1; var oldIndex = -1; var onMouseDown = function() { p.hide(); p.onmouseselection(this); }; var onMouseOver = function(event){ var index = event.target.index; if (index !== undefined) { p.highlight(index); } } var p = { hide : function() { elem.style.visibility = 'hidden'; if(document.querySelector('.autocomplete-mssg')){ document.querySelector('.autocomplete-mssg').style.display = "none"; } setTimeout(dropDownHistory.hide, 250); }, refresh : function(token, array) { elem.style.visibility = 'hidden'; ix = 0; elem.innerHTML =''; var vph = (window.innerHeight || document.documentElement.clientHeight); var rect = elem.parentNode.getBoundingClientRect(); var distanceToTop = rect.top - 6; // heuristic give 6px var distanceToBottom = vph - rect.bottom -6; // distance from the browser border. var parts = token.trim().toLowerCase().split(' '); for(let i= 0; i'; } divRow.innerHTML += array[i].split(' ').reduce(function (pVal, pWord) { parts.forEach(function (pPart) { if (pWord.indexOf('') > -1) { return; } pWord = pWord.replace(new RegExp('(' + pPart + ')', 'gi'), '$1'); }); return pVal+ ' ' + pWord; }, '')+''; divRow.style.width = "100%"; rows.push(divRow); elem.appendChild(divRow); } if (rows.length===0) { return; // nothing to show. } if (rows.length===1 && token === rows[0].__hint) { return; // do not show the dropDown if it has only one element which matches what we have just displayed. } // if (rows.length<2) return; // p.highlight(0); if (distanceToTop > distanceToBottom*3) { // Heuristic (only when the distance to the to top is 4 times more than distance to the bottom elem.style.maxHeight = distanceToTop+'px'; // we display the dropDown on the top of the input text elem.style.top =''; elem.style.bottom ='100%'; } else { elem.style.bottom = ''; elem.style.maxHeight = distanceToBottom+'px'; } elem.style.visibility = 'visible'; dropDownHistory.hide(); }, highlight : function(index) { if(rows[index]!=undefined){ if (oldIndex !=-1 && rows[oldIndex]) { rows[oldIndex].removeAttribute('class'); } rows[index].setAttribute('class', 'selected'); oldIndex = index; } }, move : function(step) { // moves the selection either up or down (unless it's not possible) step is either +1 or -1. if (elem.style.visibility === 'hidden') return ''; // nothing to move if there is no dropDown. (this happens if the user hits escape and then down or up) if (ix+step === -1 || ix+step === rows.length) return rows[ix].__hint; // NO CIRCULAR SCROLLING. ix+=step; p.highlight(ix); return rows[ix].__hint; }, onmouseselection : function() {} // it will be overwritten. }; txtInput.onblur = p.hide; return p; }; var dropDownController = createDropDownController(dropDown); var dropDownHistory = createDropDownHistoryController(document.querySelector(".dropdown_history")); dropDownController.onmouseselection = function(pContext) { txtInput.value = txtHint.value = leftSide+pContext.__hint; //rs.onChange(txtInput.value, pContext.getAttribute('date-url')); registerOnTextChangeOldValue = txtInput.value; // <-- ensure that mouse down will not show the dropDown now. setTimeout(function() { txtInput.focus(); },0); // <-- I need to do this for IE rs.onSelect(pContext.dataset); }; var counter = 2; var PopupTimer = setInterval(function(){ if (txtInput === document.activeElement && txtInput.value.length>2 && txtInput.getAttribute('placeholder')=="Asthme, aspirine, amoxicilline...") { if(counter <= 0){ clearInterval(PopupTimer); var span_popup=document.createElement('span'); txtInput.after(span_popup); span_popup.innerHTML="Utiliser la flèche de droite pour autocompléter"; span_popup.className="autocomplete-mssg"; } counter -= 1; } }, 2000); if(txtInput.getAttribute('placeholder')=="Asthme, aspirine, amoxicilline..."){ var timeout; txtInput.addEventListener('keypress', function(){ if(counter <= 0){ clearTimeout(timeout); if(document.querySelector('.autocomplete-mssg') || txtInput.value.length<=3){ document.querySelector('.autocomplete-mssg').style.display="none"; } } timeout = setTimeout(function() {if(document.querySelector('.autocomplete-mssg') && txtInput.value.length>2 && dropDown.visibility=="visible"){ document.querySelector('.autocomplete-mssg').style.display="block"; }}, 2000 ) } );} if(txtInput.value.length<=3){ if(document.querySelector('.autocomplete-mssg')) { document.querySelector('.autocomplete-mssg').style.display = "none"; } } wrapper.appendChild(dropDown); container.appendChild(wrapper); var spacer; var leftSide; // <-- it will contain the leftSide part of the textfield (the bit that was already autocompleted) function calculateWidthForText(text) { if (spacer === undefined) { // on first call only. spacer = document.createElement('span'); spacer.style.visibility = 'hidden'; spacer.style.position = 'fixed'; spacer.style.outline = '0'; spacer.style.margin = '0'; spacer.style.padding = '0'; spacer.style.border = '0'; spacer.style.left = '0'; spacer.style.whiteSpace = 'pre'; spacer.style.fontSize = config.fontSize; spacer.style.fontFamily = config.fontFamily; spacer.style.fontWeight = 'normal'; document.body.appendChild(spacer); } // Used to encode an HTML string into a plain text. // taken from http://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding spacer.innerHTML = String(text).replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(//g, '>'); return spacer.getBoundingClientRect().right; } var rs = { onArrowDown : function() {dropDownHistory.move(+1);}, // defaults to no action. onArrowUp : function() {dropDownHistory.move(-1);}, // defaults to no action. onEnter : function() {dropDownHistory.click();}, // defaults to no action. onTab : function() {}, // defaults to no action. onSelectTab : function() {}, onSelectEnter : function() {}, onChange: function() { rs.repaint() }, // defaults to repainting. onSelect: function(){}, onClick: function(){ if (txtInput.value.length === 0) dropDownHistory.shown(); }, startFrom: 0, options: [], wrapper : wrapper, // Only to allow easy access to the HTML elements to the final user (possibly for minor customizations) input : txtInput, // Only to allow easy access to the HTML elements to the final user (possibly for minor customizations) hint : txtHint, // Only to allow easy access to the HTML elements to the final user (possibly for minor customizations) dropDown : dropDown, // Only to allow easy access to the HTML elements to the final user (possibly for minor customizations) prompt : prompt, setText : function(text) { txtHint.value = text; txtInput.value = text; }, getText : function() { return txtInput.value; }, hideDropDown : function() { dropDownController.hide(); }, repaint : function(pResults) { var text = txtInput.value; var startFrom = rs.startFrom; var options = rs.options; var optionsLength = options.length; if(pResults){ dropDownController.results = pResults; } // breaking text in leftSide and token. var token = text.substring(startFrom); leftSide = text.substring(0,startFrom); // updating the hint. txtHint.value =''; for (var i=0;i 0) dropDownHistory.hide(); if(txtInput.value.length<=3) { if (document.querySelector('.autocomplete-mssg')) { document.querySelector('.autocomplete-mssg').style.display = "none"; } } e = e || window.event; var keyCode = e.keyCode; if (keyCode == 33) { return; } // page up (do nothing) if (keyCode == 34) { return; } // page down (do nothing); if (keyCode == 27) { //escape dropDownController.hide(); dropDownHistory.hide(); txtHint.value = txtInput.value; // ensure that no hint is left. txtInput.focus(); return; } if (keyCode == 39 || keyCode == 35 || keyCode == 9) { // right, end, tab (autocomplete triggered) if (keyCode == 9) { // for tabs we need to ensure that we override the default behaviour: move to the next focusable HTML-element e.preventDefault(); e.stopPropagation(); if (txtHint.value.length == 0) { rs.onTab(); // tab was called with no action. // users might want to re-enable its default behaviour or handle the call somehow. } } if (txtHint.value.length > 0) { // if there is a hint dropDownController.hide(); txtInput.value = txtHint.value; var hasTextChanged = registerOnTextChangeOldValue != txtInput.value; registerOnTextChangeOldValue = txtInput.value; // <-- to avoid dropDown to appear again. // for example imagine the array contains the following words: bee, beef, beetroot // user has hit enter to get 'bee' it would be prompted with the dropDown again (as beef and beetroot also match) if (hasTextChanged) { if(document.querySelectorAll('.results')[0]!= txtInput.value && document.querySelectorAll('.selected')[0]==undefined){ var end=document.querySelectorAll('.results')[0].innerHTML.indexOf(''); var cut=document.querySelectorAll('.results')[0].innerHTML.substring(end); var clean=cut.replace(/<\s*[^>]*>/gi, ''); txtInput.value=clean; } } rs.onSelectTab(hasTextChanged,e); } if(document.querySelector('.dropdown').visibility=="hidden"){ document.querySelector('.autocomplete-mssg').style.display="none"; } return; } if (keyCode == 13) { // enter (autocomplete triggered) if (txtHint.value.length == 0 || !keyboardActions) { // if there is a hint rs.onEnter(); } else { var wasDropDownHidden = (dropDown.style.visibility == 'hidden'); dropDownController.hide(); if (wasDropDownHidden) { txtHint.value = txtInput.value; // ensure that no hint is left. txtInput.focus(); rs.onEnter(); return; } txtInput.value = txtHint.value; var hasTextChanged = registerOnTextChangeOldValue != txtInput.value ; registerOnTextChangeOldValue = txtInput.value; rs.onSelectTab(hasTextChanged,e); } return; } var size= document.querySelectorAll('.results').length; if (keyCode == 40) { counterKeyPress++; if(counterKeyPress==1){ var m = dropDownController.move(+0); }else{ if(counterKeyPress>1 && size==0||size!=0) { var m = dropDownController.move(+1); } } keyboardActions = true; if (m == '') { rs.onArrowDown(); } txtHint.value = leftSide+m; return; } if (keyCode == 38 ) { // up keyboardActions = true; var m = dropDownController.move(-1); if (m == '') { rs.onArrowUp(); } txtHint.value = leftSide+m; e.preventDefault(); e.stopPropagation(); return; } // it's important to reset the txtHint on key down. // think: user presses a letter (e.g. 'x') and never releases... you get (xxxxxxxxxxxxxxxxx) // and you would see still the hint txtHint.value =''; // resets the txtHint. (it might be updated onKeyUp) }; if (txtInput.addEventListener) { txtInput.addEventListener("keydown", keyDownHandler, false); } else { // is this a fair assumption: that attachEvent will exist ? txtInput.attachEvent('onkeydown', keyDownHandler); // IE<9 } const onClickHandler = (e) => { rs.onClick(); }; if (txtInput.addEventListener) { txtInput.addEventListener("click", onClickHandler, false); } else { // is this a fair assumption: that attachEvent will exist ? txtInput.attachEvent('click', onClickHandler); // IE<9 } var removeAccents = function (t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}; return rs; } class SearchHighlighter { constructor(rootNode = document.body) { this.rootNode = rootNode; this.results = []; this.currentResultIndex = 0; this.nbResults = 0; } highlightResult(result) { const regex = new RegExp("(" + this.escapeRegExp(result.term) + ")(?![^<]*>)", 'gi'); let html = result.originalHtml; html = html.replace(regex, '$&'); result.element.innerHTML = html; } escapeRegExp(str) { const substitutions = { ae: ['ae', 'æ', 'ǽ', 'ǣ'], a: ['a', 'á', 'ă', 'ắ', 'ặ', 'ằ', 'ẳ', 'ẵ', 'ǎ', 'â', 'ấ', 'ậ', 'ầ', 'ẩ', 'ẫ', 'ä', 'ǟ', 'ȧ', 'ǡ', 'ạ', 'ȁ', 'à', 'ả', 'ȃ', 'ā', 'ą', 'ᶏ', 'ẚ', 'å', 'ǻ', 'ḁ', 'ⱥ', 'ã'], c: ['c', 'ć', 'č', 'ç', 'ḉ', 'ĉ', 'ɕ', 'ċ', 'ƈ', 'ȼ'], e: ['e', 'é', 'ĕ', 'ě', 'ȩ', 'ḝ', 'ê', 'ế', 'ệ', 'ề', 'ể', 'ễ', 'ḙ', 'ë', 'ė', 'ẹ', 'ȅ', 'è', 'ẻ', 'ȇ', 'ē', 'ḗ', 'ḕ', 'ⱸ', 'ę', 'ᶒ', 'ɇ', 'ẽ', 'ḛ'], i: ['i', 'í', 'ĭ', 'ǐ', 'î', 'ï', 'ḯ', 'ị', 'ȉ', 'ì', 'ỉ', 'ȋ', 'ī', 'į', 'ᶖ', 'ɨ', 'ĩ', 'ḭ'], n: ['n', 'ń', 'ň', 'ņ', 'ṋ', 'ȵ', 'ṅ', 'ṇ', 'ǹ', 'ɲ', 'ṉ', 'ƞ', 'ᵰ', 'ᶇ', 'ɳ', 'ñ'], o: ['o', 'ó', 'ŏ', 'ǒ', 'ô', 'ố', 'ộ', 'ồ', 'ổ', 'ỗ', 'ö', 'ȫ', 'ȯ', 'ȱ', 'ọ', 'ő', 'ȍ', 'ò', 'ỏ', 'ơ', 'ớ', 'ợ', 'ờ', 'ở', 'ỡ', 'ȏ', 'ō', 'ṓ', 'ṑ', 'ǫ', 'ǭ', 'ø', 'ǿ', 'õ', 'ṍ', 'ṏ', 'ȭ'], u: ['u', 'ú', 'ŭ', 'ǔ', 'û', 'ṷ', 'ü', 'ǘ', 'ǚ', 'ǜ', 'ǖ', 'ṳ', 'ụ', 'ű', 'ȕ', 'ù', 'ủ', 'ư', 'ứ', 'ự', 'ừ', 'ử', 'ữ', 'ȗ', 'ū', 'ṻ', 'ų', 'ᶙ', 'ů', 'ũ', 'ṹ', 'ṵ'], }; return Array.from(this.removeAccents(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).map(c => substitutions[c] ? `[${substitutions[c].join("")}]` : c).join(""); } removeAccents(str) { return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); } searchInElement(element, terms) { terms.forEach(term => { if (this.hasAtLeastOneTerm(element, [term])) { this.results.push({ term: term, element: element, originalHtml: element.innerHTML, suggestions: [] }); } }); } traverseElements(node, terms) { if (node.nodeType === Node.ELEMENT_NODE && !this.isIgnoredElement(node)) { if (node != this.rootNode && this.hasAtLeastOneTerm(node, terms)) { this.searchInElement(node, terms); } node.childNodes.forEach(child => { this.traverseElements(child, terms); }); } } isIgnoredElement(element) { const ignoredTags = ['SCRIPT', 'STYLE', 'TEMPLATE']; return ignoredTags.includes(element.tagName); } hasAtLeastOneTerm(element, terms) { let text = this.getTextNode(element); for (const term of terms) { const regex = new RegExp(this.escapeRegExp(term), 'gi'); if (text.match(regex)) { return true; } } } setSuggestions(result) { const text = this.removeAccents(this.getTextNode(result.element).toLowerCase()); const regex = new RegExp("\\b" + this.escapeRegExp(result.term) + "\\w*", "gi"); const suggests = text.match(regex); if (suggests != null && suggests.length > 0) { result.suggestions.push(...suggests); } } getTextNode(element) { let text = ''; element.childNodes.forEach(node => { if (node.nodeType === Node.TEXT_NODE) { text += node.nodeValue; } else if (node.tagName === 'BR') { text += ' '; } }); return text; } reset() { this.results.forEach(result => { if (result.hasOwnProperty('element')) { result.element.innerHTML = result.originalHtml; } }); this.results = []; this.currentResultIndex = 0; this.nbResults = 0; } searchAndHighlight(terms) { terms = terms.filter((term) => { return term.trim() !== ""; }); this.reset(); this.terms = terms; this.traverseElements(this.rootNode, this.terms); this.results.forEach(result => { this.setSuggestions(result); this.highlightResult(result); }); this.nbResults = this.rootNode.querySelectorAll("mark.term").length; this.scrollToNextResult(); return this.results; } scrollToNextResult() { if (this.nbResults > this.currentResultIndex) { this.rootNode.querySelectorAll("mark.term.focused").forEach(mark => mark.classList.remove('focused')); this.rootNode.querySelectorAll("mark.term")[this.currentResultIndex].classList.add('focused'); this.rootNode.querySelectorAll("mark.term")[this.currentResultIndex].scrollIntoView(); } if (this.currentResultIndex == this.nbResults - 1) { this.currentResultIndex = 0; } else { this.currentResultIndex = this.currentResultIndex + 1; } } } class SearchHighlighterInput { constructor(input, rootNode = document.body) { this.input = input; this.searchHighlighter = new SearchHighlighter(rootNode); this.autocomplete = null; this.trackingTimeout = null; this.init(); } init() { this.autocomplete = completely(this.input, { fontSize: '13px', placeHolder: 'Chercher dans la page' }); this.autocomplete.onChange = this.searchInputHandler.bind(this); this.autocomplete.onInput = this.searchInputHandler.bind(this); this.autocomplete.onSelect = this.selectHandler.bind(this); this.autocomplete.onEnter = this.selectHandler.bind(this); this.autocomplete.onSelectTab = this.selectHandler.bind(this); this.autocomplete.onSelectEnter = this.selectHandler.bind(this); this.autocomplete.onClick = this.onClickHandler.bind(this); } updateCount() { if (this.searchHighlighter.results.length > 0) { const num = this.searchHighlighter.currentResultIndex + 1; this.input.parentNode.querySelector('.search-terms-count').innerHTML = num + "/" + this.searchHighlighter.nbResults; this.input.parentNode.querySelector('.search-terms-count').style.display = 'block'; } else { this.input.parentNode.querySelector('.search-terms-count').style.display = 'none'; } } selectHandler(textHasChanged) { if (textHasChanged) this.searchInputHandler(this.autocomplete.input.value); else this.searchHighlighter.scrollToNextResult(); this.updateCount(); } searchInputHandler(pValue) { if (pValue.length <= 3) { if (this.searchHighlighter != null) { this.searchHighlighter.reset(); this.updateCount(); } this.input.parentNode.querySelector(".dropdown").style.visibility = "hidden"; return; } else { let searchResults = []; if (this.searchHighlighter != null) { searchResults = this.searchHighlighter.searchAndHighlight([pValue]); if (window.pa) { if (this.trackingTimeout) { clearTimeout(this.trackingTimeout); } this.trackingTimeout = setTimeout(() => { pa.sendEvent('page.search', { 'keyword': pValue }); }, 2000); } this.updateCount(); } let suggestions = []; searchResults.forEach(result => { if (result.suggestions.length > 0) suggestions.push(...result.suggestions); }); suggestions = suggestions.filter((x, i) => suggestions.indexOf(x) === i); suggestions = suggestions.slice(0, 5); suggestions.sort((a, b) => { return a.localeCompare(b); }); if (suggestions.length > 0) { this.input.parentNode.querySelector(".dropdown").style.background = "white"; this.input.parentNode.querySelector(".dropdown").style.maxHeight = "200px"; this.input.parentNode.querySelector(".dropdown").style.border = "1px solid lightgray"; this.input.parentNode.querySelector(".dropdown").style.visibility = "visible"; let opt = []; for (let i = 0; i < suggestions.length; i++) { opt.push(suggestions[i]); } this.autocomplete.options = opt; this.autocomplete.repaint(); } } } onClickHandler() { if (window.pa) pa.sendEvent('click.action', { 'click': 'Rechercher dans la page', 'click_chapter1': 'Sommaire', }) } } const inputs = document.querySelectorAll('.search-terms'); inputs.forEach(input => { new SearchHighlighterInput(input, document.querySelector(input.dataset.root) ?? document.body); }); (function(){ function init(){ if(window.data_focus){ displayMessage(data_focus, '.messages-focus', 'vidal-focus'); } var copy = document.querySelector(".copy"); if (copy) { copy.addEventListener('click', function (pEvt) { document.querySelector(".success-mssg").style.display = "inline"; var copyText = document.querySelector(".dci"); var textArea = document.createElement("textarea"); textArea.value = copyText.textContent; document.body.appendChild(textArea); textArea.select(); document.execCommand("Copy"); textArea.remove() setTimeout(function () { document.querySelector(".success-mssg").style.display = "none"; }, 1000); }); } Tab.setCallBackOnSelect(toggleLab); initSeeOrdonnance(); const availabilityInfoIcon = document.querySelector('.product-status>.availability>.icon-info'); if(!availabilityInfoIcon){ return; } VIDALPiano.delayedOverOutEvent(availabilityInfoIcon, 1000); } function toggleLab(id) { let lab = document.querySelector(".extra .lab"); let labo = document.querySelector(".extra .labo"); let display = "block"; if (id == 'doc_dci') { display= "none"; } if (lab) lab.style.display = display; if (labo) labo.style.display = display; } function initSeeOrdonnance() { const url = window.location.pathname; const pattern =/medicaments\/[a-zA-Z0-9_-]+-(\d+)\.html/; const matches = url.match(pattern); const id = matches[1]; if (id) { document.querySelectorAll('#doc_mono .main .block #interactions,#doc_mono .main .block #effets-indesirables').forEach(function (el) { const type = el.id; el.querySelector('table.title').insertAdjacentHTML("afterend", `
`); }); } } window.addEventListener('DOMContentLoaded', init, false); })(); /* UAParser.js v0.7.18 Lightweight JavaScript-based User-Agent string parser https://github.com/faisalman/ua-parser-js Copyright ? 2012-2016 Faisal Salman Dual licensed under GPLv2 or MIT */ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,b){a!=Array.prototype&&a!=Object.prototype&&(a[d]=b.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this); $jscomp.polyfill=function(a,d,b,e){if(d){b=$jscomp.global;a=a.split(".");for(e=0;e
'+this.options.title+"
"+this.options.author+"
"+e+'
'+this.options.button+"";m.body?m.body.appendChild(t):m&&m.addEventListener("DOMContentLoaded",function(){m.body.appendChild(t)});c(".smartbanner-button",t).addEventListener("click",this.install.bind(this),!1);c(".smartbanner-close",t).addEventListener("click", this.close.bind(this),!1)},hide:function(){r.classList.remove("smartbanner-show");if("function"===typeof this.options.close)return this.options.close()},show:function(){r.classList.add("smartbanner-show");if("function"===typeof this.options.show)return this.options.show()},close:function(){this.hide();f.set(this.appId+"-smartbanner-closed","true",{path:"/",expires:new Date(Number(new Date)+864E5*this.options.daysHidden)});if("function"===typeof this.options.close)return this.options.close()},install:function(){this.hide(); f.set(this.appId+"-smartbanner-installed","true",{path:"/",expires:new Date(Number(new Date)+864E5*this.options.daysReminder)});if("function"===typeof this.options.close)return this.options.close()},parseAppId:function(){var a=c('meta[name="'+this.appMeta+'"]');if(a)return this.appId="windows"===this.type?a.getAttribute("content"):/app-id=([^\s,]+)/.exec(a.getAttribute("content"))[1]}};d.exports=a},{"component-query":2,"cookie-cutter":3,"get-doc":4,"object-assign":6,"ua-parser-js":7}],2:[function(a, d,b){function e(a,e){return e.querySelector(a)}b=d.exports=function(a,b){b=b||document;return e(a,b)};b.all=function(a,e){e=e||document;return e.querySelectorAll(a)};b.engine=function(a){if(!a.one)throw Error(".one callback required");if(!a.all)throw Error(".all callback required");e=a.one;b.all=a.all;return b}},{}],3:[function(a,d,b){b=d.exports=function(a){a||(a={});"string"===typeof a&&(a={cookie:a});void 0===a.cookie&&(a.cookie="");return{get:function(c){for(var b=a.cookie.split(/;\s*/),f=0;f< b.length;f++){var e=b[f].split("=");if(unescape(e[0])===c)return unescape(e[1])}},set:function(c,b,f){f||(f={});c=escape(c)+"="+escape(b);f.expires&&(c+="; expires="+f.expires);f.path&&(c+="; path="+escape(f.path));f.domain&&(c+="; domain="+escape(f.domain));f.secure&&(c+="; secure");return a.cookie=c}}};"undefined"!==typeof document&&(a=b(document),b.get=a.get,b.set=a.set)},{}],4:[function(a,d,b){a=a("has-dom");d.exports=a()?document:null},{"has-dom":5}],5:[function(a,d,b){d.exports=function(){return"undefined"!== typeof window&&"undefined"!==typeof document&&"function"===typeof document.createElement}},{}],6:[function(a,d,b){var e=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable;d.exports=function(){try{if(!Object.assign)return!1;var a=new String("abc");a[5]="de";if("5"===Object.getOwnPropertyNames(a)[0])return!1;var c={};for(a=0;10>a;a++)c["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(c).map(function(a){return c[a]}).join(""))return!1; var b={};"abcdefghijklmnopqrst".split("").forEach(function(a){b[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},b)).join("")?!1:!0}catch(r){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");var d=Object(a);for(var f,g=1;g>1); var top = (screen.height/2)-(h>>1); var connectWindow = window.open(decodeURIComponent(window.atob(e.currentTarget.getAttribute("data-cbo"))),'_blank','top='+top+',left='+left+',toolbar=0,location=0,directories=0,status=1,menubar=0,titlebar=0,scrollbars=1,resizable=1,width='+w+',height='+h); if(connectWindow) { e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); } } window.addEventListener("DOMContentLoaded", init, false); return { setup:setup, closedHandler:VIDALConnectClosedHandler }; })(); /** * @author Arno NICOLAS - arno06@gmail.com */ if (NodeList.prototype.forEach === undefined) NodeList.prototype.forEach = Array.prototype.forEach || function(pHandler){for(var i = 0, max = this.length; i-1) p = {x: e.touches[0].pageX, y: e.touches[0].pageY}; t.setAttribute("mouse-start", p.x+","+ p.y); t.setAttribute("mouse-end", p.x+","+ p.y); todo = "add"; break; case TouchBehavior.upEvent: if (t.getAttribute("mouse-start")) { var start = t.getAttribute("mouse-start").split(","); var last = t.getAttribute("mouse-end").split(","); var distanceX = (last[0] - start[0]); var distanceY = (last[1] - start[1]); var distance = Math.sqrt((distanceX*distanceX) + (distanceY*distanceY)); if(distance>pDistance) { e.stopImmediatePropagation(); e.stopPropagation(); } todo = "remove"; } break; case TouchBehavior.moveEvent: default: if(e.type.toLowerCase().indexOf("touch")>-1) p = {x: e.touches[0].pageX, y: e.touches[0].pageY}; t.setAttribute("mouse-end", p.x+","+ p.y); todo = "remove"; break; } if (todo) t.classList[todo](pClassName); }; pElement.addEventListener(TouchBehavior.downEvent, handler, {passive:true}); pElement.addEventListener(TouchBehavior.moveEvent, handler, {passive:true}); pElement.addEventListener(TouchBehavior.upEvent, handler, {passive:true}); }); } }; function isMobile() { let devc = 'bureau'; if (navigator.userAgent.match(/(android|iphone|ipad|blackberry|symbian|symbianos|symbos|netfront|model-orange|javaplatform|iemobile|windows phone|samsung|htc|opera mobile|opera mobi|opera mini|presto|huawei|blazer|bolt|doris|fennec|gobrowser|iris|maemo browser|mib|cldc|minimo|semc-browser|skyfire|teashark|teleca|uzard|uzardweb|meego|nokia|bb10|playbook)/gi)) { if (((screen.width >= 480) && (screen.height >= 800)) || ((screen.width >= 800) && (screen.height >= 480)) || navigator.userAgent.match(/ipad/gi)) { devc = 'tablette'; } else { devc = 'mobile'; } } return devc; } function isNarrowScreen() { return window.matchMedia("(max-width: 950px)").matches; } function isTouchable() { return ("ontouchend" in document); } function uriEncode(pParams) { let get = ''; let prefix = '?'; for (let i in pParams) { get += prefix + i + '=' + pParams[i]; prefix = '&'; } return get; } function makeRequest(pUrl, pParams, pElement, pCallbackBefore, pCallbackAfter, request) { pCallbackBefore(pElement); let get = uriEncode(pParams); if (request) { request.cancel(); } request = new RequestVidal(pUrl + get, null, 'GET'); request.onComplete(function (pResponse) { let response = '

Une erreur est survenue, veuillez réessayer

'; if (pResponse.responseJSON) { if (pResponse.responseJSON.hasOwnProperty('html')) response = pResponse.responseJSON.html; else if (pResponse.responseJSON.hasOwnProperty('status') && pResponse.responseJSON.status === 'ok' && pResponse.responseJSON.hasOwnProperty('responseText')) { response = pResponse.responseJSON.responseText; } } pCallbackAfter(pElement, response); }); return request; } function hideLoader(pLoader) { pLoader.style.display = 'none'; pLoader.style.height = 'auto'; } function showLoader(pLoader, pHeight) { pLoader.style.height = pHeight; pLoader.style.display = 'flex'; } (function () { function init() { const SUBSCRIBED = "subscribed"; const NO_CONDITIONS = "noconditions"; initTopArrow(); document.querySelectorAll("*[data-fontsize]").forEach(function(pEl){ const fontSizeCookie = Cookie.getCookie('fontsize'); if (fontSizeCookie) { document.body.style.fontSize = fontSizeCookie; } pEl.addEventListener('click', fontSizeHandler); }); ToggleHandler.register('body'); const iconHamb = document.querySelector('.header header .icon_hamb'); if (iconHamb) { iconHamb.addEventListener('click', function (e) { document.querySelector('.menu').style.display = e.target.classList.contains('close') ? 'none' : 'block'; e.target.classList.toggle('close'); }); } const subscribed = Cookie.getCookie(SUBSCRIBED); const noConditions = Cookie.getCookie(NO_CONDITIONS); if (!subscribed && !noConditions) { if (document.querySelector('.avatar') && window.location.href.indexOf('actualites') > 1 && document.querySelector('#box_subscription_login')) { document.querySelector('#DaboxHide').style.display = 'block'; document.querySelector('#Dabox').style.display = 'block'; document.querySelector('#box_subscription_login').style.display = 'block'; document.querySelector('.sub-btn').addEventListener("click", onUpdatePreference, false); document.querySelector('.icon-close').addEventListener("click", function (e) { e.preventDefault(); boxHide(); }); document.querySelector('.btn-cancel').addEventListener("click", function () { boxHide(); }); } } if (document.querySelector('.popin_already_subscribed')) { if (subscribed) { document.querySelector('#box_login').style.display = 'block'; document.querySelector('.popin_already_subscribe').style.display = 'block'; document.querySelector('.popin_already_subscribed').style.display = 'block'; } document.querySelector('.close-icon').addEventListener("click", function (e) { e.preventDefault(); document.querySelector('.popin_already_subscribe').style.display = 'none'; document.querySelector('.popin_already_subscribed').style.display = 'none'; Cookie.eraseCookie('subscribed'); Cookie.setCookie('noconditions', '1', 7); }); } function boxHide() { document.querySelector('#DaboxHide').style.display = 'none'; document.querySelector('#Dabox').style.display = 'none'; document.querySelector('#box_subscription_login').style.display = 'none'; } let menuEvent = "mouseover"; if (isTouchable()) { TouchBehavior.applyTo('.menu>menu>div'); menuEvent = TouchBehavior.clickEvent; } else { document.querySelectorAll('.menu>menu>div').forEach(function (pItem) { pItem.addEventListener('mouseout', function (e) { e.currentTarget.classList.remove("hover"); }); }); } document.querySelectorAll(".menu>menu>div").forEach(function (pItem) { pItem.addEventListener(menuEvent, function (e) { e.preventDefault(); const opened = document.querySelectorAll(".menu>menu>div.hover"); if (opened && opened.length) { opened.forEach(function (pEl) { pEl.classList.remove("hover"); }); } e.currentTarget.classList.add('hover'); }, false); }); if (document.querySelector(".account .avatar")) { document.querySelector(".account .avatar").addEventListener("click", toggleAvatarListHandler, false); } Scroll.setup(); initSummaries(); let main_form = document.querySelector('.searchbar form'); if (main_form) { main_form.addEventListener('submit', function (e) { document.querySelector('.form-search').action = 'recherche.html'; const val = document.querySelector('#query input[name="query"]').value; if (val.length < 3 || val.length > 255) { e.preventDefault(); const search = document.querySelector("#search_error"); search.innerHTML = val.length > 255 ? "Veuillez saisir moins de 255 caractères pour votre recherche." : "Veuillez saisir au moins 3 caractères pour votre recherche."; search.style.display = 'block'; setTimeout(function () { search.style.display = 'none'; }, 3000); } }); Autocomplete.init('#query').onSelect = function (pData) { if (window.pa) pa.sendEvent('internal_search_result.click', { 'ise_keyword': this.getText(), 'ise_page': 1, 'ise_type': 'Suggestions', 'ise_click_rank': parseInt(pData.rank), 'ise_click_product': pData.name, 'ise_click_product_type': pData.type }); window.location.href = pData.url; }; } CBO.init(document); //Permet l'insertion et/ou la duplication d'un node dans des parents différents let refs = document.querySelectorAll('*[data-insert-before]'); refs.forEach(function (pEl) { if (!pEl.getAttribute("data-keep-in-place")) { pEl.parentNode.removeChild(pEl); } let targets = document.querySelectorAll(pEl.getAttribute("data-insert-before")); targets.forEach(function (pTarget) { pTarget.parentNode.insertBefore(pEl.cloneNode(true), pTarget); }); }); // Add click on print buttons let print_buttons = document.querySelectorAll('.print-button'); if (print_buttons) { let base = document.querySelector('base').getAttribute('href'); print_buttons.forEach((pButton) => { if (pButton.getAttribute('href')) { return; } pButton.addEventListener('click', function () { let url = base + "imprimer/" + window.location.href.replace(base, ""); window.open(url, '_blank'); }); }); } const contactWebMasterLink = document.getElementById("contactWebMasterLink"); if ((contactWebMasterLink) && (window.innerWidth < 650)) { contactWebMasterLink.setAttribute("rel", ""); } const contactSection = document.getElementById("contactWebmaster"); if (contactSection) { const form = document.getElementById("contactForm"); displayFormFullSize(form); changeCaptchaStyle(document.querySelector("input[name='screenType']").value, 0); form.addEventListener('submit', contactSubmitHandler); } Dabox.onDisplay(daboxDisplayedHandler); Dabox.onHide(daboxHideHandler); // Prevent Post data when accessing iam page from drugs page and reload const iamContainer = document.querySelector(".iam-row"); if (iamContainer && (window.history.replaceState)) { window.history.replaceState(null, null, window.location.href); } document.querySelectorAll("caption p").forEach(function (pItem) { const table = pItem.parentNode.parentNode; for (let i = 0; i < table.rows.length; ++i) { if (table.rows[i].cells[0].innerHTML === "" && table.rows[i].cells[0].getAttribute('colspan') == null) { table.rows[i].cells[0].style.borderRightColor = "transparent"; } } }); document.querySelectorAll('table[width="95%"]').forEach(function (pEl) { let wrapper = document.createElement('div'); wrapper.className = "scrollable-table"; pEl.parentNode.insertBefore(wrapper, pEl); wrapper.appendChild(pEl); }); initCollapsible(); let searchbar = document.querySelector('.header .searchbar'); let narrowScreen = isNarrowScreen(); let iconSearch = document.querySelector('.header ul.secondary .search' + (narrowScreen ? '-mobile' : '')); let iconClose = document.querySelector('.header ul.secondary .close' + (narrowScreen ? '-mobile' : '')); if (iconSearch && iconClose) { iconSearch.addEventListener('click', function () { searchbar.classList.add('visible'); searchbar.classList.remove('hidden'); iconClose.style.display = 'block'; iconSearch.style.display = 'none'; document.querySelector('.header .searchbar form input[name="query"]').focus(); }) iconClose.addEventListener('click', function () { searchbar.classList.add('hidden'); searchbar.classList.remove('visible'); iconClose.style.display = 'none'; iconSearch.style.display = 'block'; }); } } function initSummaries() { const summaries = document.querySelectorAll('.summary'); summaries.forEach(function (summary) { new Summary(summary); }); } function initTopArrow() { const arrow = document.querySelector(".scroll-page"); if (arrow) { const c = function () { const scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; if (scroll && arrow.style.display === "none") { arrow.style.display = "block"; } if (!scroll && arrow.style.display === "block") { arrow.style.display = "none"; } }; c(); arrow.addEventListener("click", function () { const t = document.documentElement.scrollTop ? document.documentElement : document.body; M4Tween.killTweensOf(t); M4Tween.to(t, .5, {useStyle: false, scrollTop: 0}); }); window.addEventListener("scroll", c); } } function displayFormFullSize(form) { document.querySelector("input[name='screenType']").value = "fullWindow"; document.querySelector(".mandatory-text").style.fontSize = "0.8em"; const formChildren = form.querySelectorAll("input,select,textarea"); formChildren.forEach((pChild) => { if ((pChild.name !== "btnSubmit") && (pChild.id !== "inp_contact_captcha_captcha")) { pChild.classList.remove("form-input-popup"); pChild.classList.add("form-input-fullSize"); if (pChild.tagName === "INPUT") { pChild.style.lineHeight = "25px"; } } }); } function daboxDisplayedHandler() { const dabox = document.querySelector('#Dabox'); CBO.init(dabox); VIDALConnect.setup(dabox); //Style close Icon const closeIcon = document.querySelector(".icon-close"); const contactWebmasterSection = document.querySelector(".container-contact-section"); if (contactWebmasterSection) { dabox.style.overflow = 'auto'; let index = 0; // Form instance input is defined to check whether the form is rendered twice i.e form display in full window size + click on contact webmaster link to display form popup if (document.querySelector("input[name='screenType']").value === "fullWindow") { document.querySelector("input[name='formInstance']").value = "double"; document.querySelector("input[name='screenType']").value = 'popup'; index = 1; } const form = document.querySelectorAll(".contact-form-form")[index]; if (form) { changeCaptchaStyle(document.querySelector("input[name='screenType']").value, index); // Event Listeners document.querySelectorAll(".details_captcha")[index].querySelector("a").addEventListener("click", onreloadCaptcha); form.addEventListener('submit', contactSubmitHandler); } } if (typeof Subscribe != 'undefined') Subscribe.initDaboxButtons(); } function changeCaptchaStyle(screenType, i) { const captchaInputClass = screenType === "popup" ? "captcha-input-popup" : "captcha-input-fullSize"; const captchaImageClass = screenType === "popup" ? "captcha-image-popup" : "captcha-image-fullSize"; document.querySelector(".mandatory").remove(); document.querySelectorAll(".inp_contact_captcha_captcha")[i].classList.add("captcha-main-container"); document.querySelectorAll(".details_captcha")[i].querySelector("a").classList.add("captcha-reload-link"); document.querySelectorAll("input[name='contact_captcha[captcha]']")[i].classList.add("captcha-text-input"); document.querySelectorAll("input[name='contact_captcha[captcha]']")[i].classList.add(captchaInputClass); document.querySelectorAll("input[name='contact_captcha[captcha]']")[i].classList.add("form-input-text"); document.querySelectorAll(".details_captcha")[i].classList.add("captcha-text-reload"); document.querySelectorAll(".captcha")[i].querySelector("img").classList.add(captchaImageClass); } function onreloadCaptcha(pTarget) { if (pTarget) { pTarget.preventDefault(); } // i = O Form is rendred once let index = 0; // Form instance input is defined to check whether the form is rendered twice i.e form display in full window size + click on contact webmaster link to display form popup if (document.querySelector("input[name='formInstance']").value === "double") { index = 1; // Form rendered twice } document.querySelectorAll("input[name='contact_captcha[captcha]']")[index].value = ""; const i = document.querySelectorAll(".captcha")[index].querySelector("img"); if (typeof src_catpha === 'undefined') src_catpha = i.src; i.setAttribute("src", src_catpha + "" + Math.round(Math.random() * 9999) + "/"); return false; } function contactSubmitHandler(e) { e.preventDefault(); let index = 0; // Double variable is true when the contact webmaster section is rendered twice: i.e full size + click to open popup if (document.querySelector("input[name='formInstance']").value === "double") { index = 1; } const validationMessage = document.querySelectorAll(".validation-message")[index]; let data = {}; const formChildren = e.currentTarget.querySelectorAll("input,select,textarea"); formChildren.forEach((pChild) => { if (pChild.name !== 'btnSubmit') { data[pChild.name] = pChild.value; } }); toggleLoader(index, "show"); RequestVidal.load("contact.html", data, "POST").onComplete(function(response){ toggleLoader(index, "hide"); if (response.responseJSON.content.error) { displayErrorMessage(validationMessage, response.responseJSON.content.error) } else { toggleLoader(index, "show"); RequestVidal.load("submitContact.html", data, "POST").onComplete(function(response){ toggleLoader(index, "hide"); if (response.responseJSON.content.responseHTTPCode === "200") { displaySuccessMessage(validationMessage, index); } else { const errorMsg = "

Une erreur est apparue lors de l'envoi de vos données

"; displayErrorMessage(validationMessage, errorMsg); } }); } }); } function toggleLoader(index, message) { const submitBtn = document.querySelectorAll(".submit-form-btn")[index]; const loadImg = document.querySelectorAll(".contact-load-img")[index]; if (!submitBtn || !loadImg) { return; } if (message === "show") { submitBtn.disabled = true; loadImg.style.visibility = "visible"; } else { submitBtn.disabled = false; loadImg.style.visibility = "hidden"; } } function displaySuccessMessage(htmlMessage, index) { htmlMessage.style.opacity = "1"; htmlMessage.classList.remove("validation-error-message"); htmlMessage.classList.add("validation-success-message"); htmlMessage.innerHTML = "

Votre demande de contact a été prise en compte

"; setTimeout(function () { htmlMessage.style.opacity = "0"; }, 2500); document.querySelectorAll(".contact-form-form")[index].reset(); onreloadCaptcha(); } function displayErrorMessage(htmlMessage, content) { htmlMessage.style.opacity = "1"; htmlMessage.classList.add("validation-error-message"); htmlMessage.innerHTML = content; htmlMessage.querySelectorAll("p")[0].style.display = "inline"; htmlMessage.querySelectorAll("p")[0].style.padding = "0"; if (htmlMessage.querySelectorAll("p")[1]) { htmlMessage.querySelectorAll("p")[1].style.display = "inline"; htmlMessage.querySelectorAll("p")[1].style.padding = "0"; } onreloadCaptcha(); setTimeout(function () { htmlMessage.style.opacity = "0"; }, 5000); } function daboxHideHandler() { const formInstanceInput = document.querySelector("input[name='formInstance']"); const screenTypeInput = document.querySelector("input[name='screenType']"); if (formInstanceInput) { formInstanceInput.value = "single"; } if (screenTypeInput) { screenTypeInput.value = 'fullWindow'; } } function toggleAvatarListHandler(e) { if (e.target.nodeName.toLowerCase() !== "a") { e.preventDefault(); } const p = document.querySelector(".account"); const ul = p.querySelector("ul"); ul.style.display = ul.style.display && ul.style.display === "block" ? "none" : "block"; document[ul.style.display === "block" ? "addEventListener" : "removeEventListener"]("click", toggleAvatarListHandler, true); } NodeList.prototype.forEach = Array.prototype.forEach; const SIX_MONTHS = 180; function fontSizeHandler(e) { document.body.style.fontSize = e.currentTarget.getAttribute("data-fontsize"); Cookie.setCookie('fontsize', e.currentTarget.getAttribute("data-fontsize"), SIX_MONTHS); } document.addEventListener('DOMContentLoaded', init, false); })(); const ToggleHandler = { register: function (pSelector) { document.querySelector(pSelector).querySelectorAll("*[data-toggle]").forEach(function (pEl) { pEl.addEventListener('click', ToggleHandler.toggleElement); }); }, toggleElement: function (e) { e.currentTarget.classList.toggle('open'); if (e.currentTarget.getAttribute("data-toggle") && document.querySelector(e.currentTarget.getAttribute("data-toggle"))) { document.querySelector(e.currentTarget.getAttribute("data-toggle")).classList.toggle('open'); } } } const Autocomplete = (function () { function init(pSelector) { let t = document.querySelector(pSelector); t.removeEventListener('click', CBO.redirect); t.addEventListener('click', function (e) { e.stopImmediatePropagation(); }); let urlBuilder = function (pValue) { return CBO.decode(t.getAttribute("data-cbo")).replace('{value}', pValue); } let timer; let timerTracking; let req; let autocomplete = completely(t, { placeHolder: t.getAttribute('data-placeholder') }); autocomplete.setText(t.getAttribute("data-value")); autocomplete.input.setAttribute("name", t.getAttribute("id")); autocomplete.onSelectTab = function (pValue ,e ) { if(e){ e.preventDefault(); e.stopPropagation(); } window.location.href = t.querySelector('.dropdown .selected').getAttribute('data-url'); } autocomplete.onChange = function (pValue) { t.parentNode.classList.add("loading"); if (pValue.length < 3) { t.querySelector(".dropdown").style.visibility = "hidden"; if (req) { req.cancel(); } t.parentNode.classList.remove("loading"); return; } clearTimeout(timer); timer = setTimeout(function () { if (req) { req.cancel(); } req = RequestVidal.load(urlBuilder(pValue), "GET").onComplete(function (response) { t.parentNode.classList.remove("pls"); let opt = []; let results = []; const items = response.responseJSON.items; const hasResults = items && items.length; if (hasResults) { items.forEach((pItem, idx) => { const n = pItem.name.htmlEntities(); const type_search = pItem.type ? pItem.type.htmlEntities() : ''; const url = pItem.url ? pItem.url.htmlEntities() : ''; opt.push(n); results.push({id: pItem.id, name: n, url: url, type: type_search, rank: idx + 1}) }); } else if (response.responseJSON.error) { t.parentNode.classList.add("pls"); } t.parentNode.classList.remove("loading"); autocomplete.options = opt; autocomplete.repaint(results); clearTimeout(timerTracking); timerTracking = setTimeout(() => { if (window.pa) pa.sendEvent('internal_search_result.display', { 'ise_keyword': pValue, 'ise_page': hasResults ? 1 : 0, 'ise_type': 'Suggestions' }); }, 2000); }); }, 200); }; return autocomplete; } return {init: init}; })(); const CBO = { init: (pTarget) => { pTarget.querySelectorAll('*[data-cbo]').forEach(function (elt) { if (elt.nodeName.toLowerCase() === "a") { elt.setAttribute("href", CBO.decode(elt.getAttribute("data-cbo"))); return; } elt.addEventListener("click", CBO.redirect); }); }, decode: (string) =>{ return decodeURIComponent(window.atob(string));}, encode: (string) =>{ return window.btoa(string);}, redirect: (event) => { const attribute = event.currentTarget.getAttribute("data-cbo"); if (!attribute) { return; } if (event.ctrlKey) { const newWindow = window.open(CBO.decode(attribute)); newWindow.focus(); } else { document.location.href = CBO.decode(attribute); } } }; function displayMessage(pData, pSelector, pClass) { if (!pData || !pData.length) { return; } let html = ''; for (let i = 0, max = pData.length; i < max; i++) { let item = pData[i]; html += '

' + item.content + '

'; } if(document.querySelector(pSelector)) document.querySelector(pSelector).innerHTML = html; } function setContentConsent() { RequestVidal.load("utilisateur/preference/?alias_preference=consent.content_personalization_profiling&value_preference=1", "GET").onComplete(function(response){ if (response.responseJSON.content.success){ displaySuccessMessage(); } }); } function displaySuccessMessage() { const message = document.querySelector(".restricted .success"); if (message) { message.classList.remove("hide"); message.classList.add("show"); setTimeout(function () { message.classList.add("remove"); message.classList.add("hide"); }, 5000); } window.location.reload(); } String.prototype.htmlEntities = function () { return this.replace(/&#(\d+);/g, function (match, dec) { return String.fromCharCode(dec); }); }; function fadeIn(pElement, pDuration, pCompleteHandler) { M4Tween.killTweensOf(pElement); pElement.style.display = "block"; M4Tween.to(pElement, pDuration, {opacity: 1}).onComplete(pCompleteHandler); } function fadeOut(pElement, pTime, pComplete) { const c = function () { pElement.style.display = "none"; if (pComplete) { pComplete(); } }; if (pElement.style.opacity === 0) { c(); return; } M4Tween.to(pElement, pTime, {opacity: 0}).onComplete(c); } function initCollapsible() { document.querySelectorAll('.collapsible').forEach(function (pCollapsible) { pCollapsible.removeEventListener('click', collapseHandler, false); pCollapsible.addEventListener('click', collapseHandler); }); } function forceHeight(pElement) { let heightBefore = pElement.offsetHeight; pElement.style.height = 'auto'; let heightAfter = pElement.offsetHeight; pElement.style.height = heightBefore + "px"; return heightAfter; } function collapseHandler() { let collapse = !this.classList.contains('collapsed'); let toCollapseElement = document.getElementById(this.dataset.collapsible_element); let toCollapse = {}; let clamp = this.dataset.clamp || false; toCollapseElement.style.overflowY = 'hidden'; if (collapse) { this.classList.add('collapsed'); toCollapse.height = '0px'; } else { this.classList.remove('collapsed'); if (clamp) { forceHeight(toCollapseElement); toCollapseElement.classList.remove('clamped') } if (toCollapseElement) { let height = forceHeight(toCollapseElement); toCollapse.height = height + "px"; } } M4Tween.killTweensOf(toCollapseElement); M4Tween.to(toCollapseElement, .6, toCollapse); } VIDALPiano = { event: (pTarget) => { if (!window.pa) { return; } let eventName = pTarget.dataset.vp || 'click.action'; let options = {}; for (let i in pTarget.dataset) { if (i.indexOf('vp_') === -1) { continue; } let value = pTarget.dataset[i]; if (value.indexOf('this.') === 0) { value = pTarget[value.replace('this.', '')]; } options[i.replace('vp_', '')] = value; } pa.sendEvent(eventName, options); }, delayedOverOutEvent: (pTarget, pDelay = 1000, pOverCallback = null, pOutCallback = null) => { let out_timeout; let pa_timeout; let sent = false; pTarget.addEventListener('mouseover', (e) => { pOverCallback && pOverCallback(); if (out_timeout) { clearTimeout(out_timeout); } if (pa_timeout) { clearTimeout(pa_timeout); } if (sent) { return; } pa_timeout = setTimeout(() => { VIDALPiano.event(pTarget); sent = true; }, pDelay); }); pTarget.addEventListener('mouseout', (e) => { out_timeout = setTimeout(() => { sent = false; pOutCallback && pOutCallback(); if (pa_timeout) { clearTimeout(pa_timeout); } }, 100); }); } }; let retrieveAndShowRequest; let deleteRequest; let deleteAllRequest; let addOrDeleteRequest; (function(){ const ADD_BTN = '.add-bookmark-button'; const RMV_BTN = '.remove-bookmark-button'; let baseUrl; function init(){ baseUrl = document.querySelector('base').getAttribute('href'); initAddBookmark(ADD_BTN); initRemoveBookmark(RMV_BTN); } function initAddBookmark(pElement) { document.querySelectorAll(pElement).forEach(addClickHandler); } function initRemoveBookmark(pElement) { document.querySelectorAll(pElement).forEach(removeClickHandler); } function addClickHandler(pValue) { pValue.addEventListener('click', onClickAddBookmark); } function removeClickHandler(pValue) { pValue.addEventListener('click', onClickRemoveBookmark); } function onClickAddBookmark(){ let params = {'name' : encodeURIComponent(this.dataset.element_name), 'id':this.dataset.element_id, 'type':this.dataset.element_type, 'render': '1'}; makeRequest(baseUrl + 'mes-signets/add/', params, this.parentNode, eraseButton, showButton, addOrDeleteRequest) } function onClickRemoveBookmark(){ let params = {'name' : this.dataset.element_name, 'id':this.dataset.element_id, 'type':this.dataset.element_type, 'render': '1'}; makeRequest(baseUrl + 'mes-signets/delete/', params, this.parentNode, eraseButton, showButton, addOrDeleteRequest) } function eraseButton(pElement) { pElement.innerHTML = ''; pElement.classList.add('loading'); } function showButton(pElement, pResponse) { setTimeout( function (){ pElement.classList.remove('loading'); pElement.innerHTML = pResponse; init(); }, 200 ); } window.addEventListener('DOMContentLoaded', init, true); })();