// 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;};
class Slider {
constructor(pSliderContainer) {
this.container = pSliderContainer;
this.currentIndex = 0;
this.slider = this.container.querySelector(".slider");
this.cards = this.container.querySelectorAll(".card");
this.dotsContainer = this.container.querySelector(".dots");
this.timeout = null;
this.dotsContainer.innerHTML = "";
this.cards.forEach((c, index) => {
const dot = document.createElement("div");
dot.classList.add("dot");
dot.setAttribute('data-index', index);
if (index === 0){
dot.classList.add("active");
}
dot.addEventListener("click", this.clickDotHandler.bind(this));
this.dotsContainer.appendChild(dot);
});
if (this.slider){
this.slider.addEventListener("scroll", this.handleScroll.bind(this));
}
}
handleScroll() {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => this.snapCard(), 300);
}
snapCard() {
const scrollLeft = this.slider.scrollLeft;
let closestDistance = Infinity;
this.cards.forEach((card, index) => {
const cardLeft = card.offsetLeft;
const distance = Math.abs(cardLeft - scrollLeft);
if (distance < closestDistance) {
closestDistance = distance;
this.currentIndex = index;
}
});
this.scrollToCard(this.currentIndex);
}
scrollToCard(index) {
if (index >= 0 && index < this.cards.length) {
const targetCard = this.cards[index];
M4Tween.killTweensOf(this.slider);
let offset = targetCard.offsetLeft - Number(window.getComputedStyle(targetCard).marginRight.replace("px",""));
M4Tween.to(this.slider, .3, {useStyle:false, scrollLeft:offset});
this.updateActiveDot(index);
}
}
clickDotHandler(e){
this.moveToSlide(e.currentTarget.getAttribute("data-index"));
}
moveToSlide(index) {
this.currentIndex = Number(index);
let defaultCard = this.cards[0];
let offset = (defaultCard.offsetWidth+Number(window.getComputedStyle(defaultCard).marginRight.replace("px",""))) * this.currentIndex;
M4Tween.killTweensOf(this.slider);
M4Tween.to(this.slider, .3, {useStyle:false, scrollLeft:offset});
this.updateActiveDot();
}
updateActiveDot() {
this.dotsContainer.querySelectorAll(".dot").forEach((dot, index) => {
dot.classList.toggle("active", index === this.currentIndex);
});
}
}
(()=>{
function init(){
document.querySelectorAll(".slider-container").forEach((pSliderContainer)=>{
new Slider(pSliderContainer);
});
}
window.addEventListener('DOMContentLoaded', init);
})();
(() => {
let mobileDevice = 728;
function init() {
const dashboardClasses = ["started-formations", "favorite-formations", "completed-formations"];
dashboardClasses.forEach(classname => dashboardCourses(classname));
const tabGroups = [
{ selector: '.dashboard', context: 'dashboard' },
{ selector: '.listing-health', context: 'listing-health' }
];
tabGroups.forEach(({ selector, context }) => {
const tabs = document.querySelectorAll(selector+" .tabs [data-tab]");
if (tabs.length) {
tabsAction(tabs, context);
}
});
addMoreMenuToFirstVisibleTab("dashboard");
let button_bookmark_favorite = document.querySelectorAll('.actions .add-bookmark-button-favorite');
if(button_bookmark_favorite) {
button_bookmark_favorite.forEach((btn) => {
let id_formation = btn.parentNode.getAttribute('data-id_formation');
btn.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation()
if (btn.querySelector('span').classList.contains('favorite')) {
toFavorite(id_formation, btn, "remove");
} else {
toFavorite(id_formation, btn, "add");
}
})
})
}
let cards = document.querySelectorAll('.formations .card');
if(cards) {
cards.forEach(card => {
let url = card.querySelector('.course-card-content .course-card-title a');
url.addEventListener('click', (e) =>e.currentTarget.stopImmediatePropagation())
card.addEventListener('click', () => {
let main_form = document.querySelector('.searchbar-formation form');
if (main_form && window.pa && window.location.pathname.endsWith('recherche.html')) {
let keyword = document.querySelector(".result-search .search-term");
if(keyword) {
pa.sendEvent('internal_search_result.click', {
'ise_keyword': keyword.textContent,
'ise_page': 1,
'ise_type': 'VIDAL Campus',
'ise_click_rank': url.getAttribute('data-click_rank'),
});
}
}else{
VIDALPiano.event(url);
}
window.location.href = url.href
});
})
}
}
function toFavorite(pIdFormation, btn, pAction){
fetch((btn.getAttribute('data-baseurl')??'')+pAction+'-to-favorite', {
headers: {
"x-requested-with": "XMLHttpRequest"
},
method: 'POST',
body: new URLSearchParams({
id_formation: pIdFormation
})
})
.then(response => response.text())
.then(data => {
if(data === "Erreur lors de l'insertion en base de données.") {
console.error(data)
}else{
let removeText = "Retirer de ma liste";
let addText = "Ajouter à ma liste";
let span = btn.querySelector('span');
pAction === "add"
? !span.classList.contains('favorite') && span.classList.add('favorite')
: span.classList.remove('favorite');
let dashboard = document.querySelector('.dashboard');
if(!dashboard) {
if(btn.closest('.course-card').querySelector('.course-details')) {
if(btn.textContent.trim() === "Ajouter à ma liste") {
btn.innerHTML = 'Retirer de ma liste';
btn.title = removeText;
}else {
btn.innerHTML = 'Ajouter à ma liste';
btn.title = addText;
}
}
}else {
let favoriteTab = dashboard.querySelector('[data-tab="favorite-formations"] span');
let favoriteDashboardTab = dashboard.querySelector('[data-tab="favorite-formations"]');
let favoriteContainerList = dashboard.querySelectorAll('.favorite-formations .card');
let btnShawAll = dashboard.querySelector('.favorite-formations .showAll span');
let countFavorite = (pAction === "add") ? favoriteContainerList.length + 1 : favoriteContainerList.length - 1;
let countMore = (pAction === "add") ? favoriteContainerList.length - 3 : favoriteContainerList.length + 3;
if(btnShawAll) {
btnShawAll.innerHTML = countMore;
}
favoriteTab.innerHTML = countFavorite;
if (countFavorite > 0 && favoriteDashboardTab.classList.contains('disabled')) {
favoriteDashboardTab.classList.remove('disabled');
favoriteDashboardTab.style.pointerEvents = 'auto';
favoriteDashboardTab.style.opacity = 1;
} else if (countFavorite === 0 && !favoriteDashboardTab.classList.contains('disabled')) {
favoriteDashboardTab.classList.add('disabled');
favoriteDashboardTab.style.pointerEvents = 'none';
favoriteDashboardTab.style.opacity = 0.5;
}
if(pAction === "add") {
btn.title = removeText;
let element = btn.closest('.card');
let course = element.cloneNode(true);
let newButton = course.querySelector('.actions .add-bookmark-button-favorite');
newButton.title = removeText;
newButton.addEventListener('click', ()=>toFavorite(pIdFormation, btn, "remove"));
let startBtn = course.querySelector('.action.start');
if (startBtn) {
startBtn.addEventListener('click', () => {
window.location.href = course.querySelector('.course-card-title a').href;
});
}
if(favoriteContainerList.length === 0) {
dashboard.querySelector('.favorite-formations').appendChild(course);
}else{
favoriteContainerList[0].before(course);
}
updateFavoriteSection(dashboard);
const dashboardElement = document.querySelector('.dashboard');
if (dashboardElement && dashboardElement.style.display === 'none') {
dashboardElement.style.display = '';
}
if (screen.width <= mobileDevice) {
addMoreMenuToFirstVisibleTab("dashboard");
}
}else{
btn.title = addText;
let favoriteContainer = document.querySelector('.dashboard .favorite-formations');
let element = favoriteContainer.querySelector(`.actions[data-id_formation="${pIdFormation}"]`).closest('.card');
favoriteContainer.removeChild(element);
let courses = document.querySelectorAll(`.card .actions[data-id_formation="${pIdFormation}"]`);
courses.forEach(course => course.querySelector('.add-bookmark-button-favorite span').classList.remove('favorite'))
const hasStarted = dashboard.querySelectorAll('.started-formations .card').length > 0;
const hasFavorite = dashboard.querySelectorAll('.favorite-formations .card').length > 0;
const hasCompleted = dashboard.querySelectorAll('.completed-formations .card').length > 0;
updateFavoriteSection(dashboard);
if (!hasStarted && !hasFavorite && !hasCompleted) {
dashboard.style.display = 'none';
}else if (!hasFavorite) {
const tabs = dashboard.querySelectorAll('.tabs [data-tab]');
tabs.forEach(tab => tab.classList.remove('active'));
document.querySelectorAll(`.dashboard .tab-content`).forEach(content => content.classList.remove('active'));
const firstTabWithData = Array.from(tabs).find(tab => tab.getAttribute('data-has-formations') === 'true');
if (firstTabWithData) {
firstTabWithData.classList.add('active');
const tabName = firstTabWithData.getAttribute('data-tab');
dashboard.querySelector(`.tab-content.${tabName}`).classList.add('active');
if (screen.width <= mobileDevice) {
tabs.forEach(tab => {
tab.style.display = (tab === firstTabWithData) ? "flex" : "none";
});
addMoreMenuToFirstVisibleTab("dashboard");
}
}
}
}
}
}
})
.catch(error => {
console.error('Erreur:', error);
});
}
function dashboardCourses(pSelector) {
const maxCourseDisplay = (screen.width <= mobileDevice) ? 2 : 4;
let courses = document.querySelectorAll('.dashboard .'+pSelector+' .card');
if(courses) {
courses.forEach((course, index) => {
if (index >= maxCourseDisplay) {
course.classList.add('hidden');
}
});
let btnShowAll = document.querySelector('.dashboard .'+pSelector+' .showAll');
if (courses.length <= maxCourseDisplay) {
btnShowAll?.remove();
return;
}
if(courses.length >= maxCourseDisplay && btnShowAll) {
if (screen.width <= mobileDevice && courses.length >= maxCourseDisplay && !btnShowAll) {
btnShowAll = document.createElement("div");
btnShowAll.classList.add('showAll');
let container = document.querySelector('.dashboard .'+pSelector)
container.appendChild(btnShowAll)
}
if (screen.width <= mobileDevice) {
btnShowAll.innerHTML = `Tout voir (${courses.length - maxCourseDisplay})`;
}else{
btnShowAll.querySelector('span').textContent = `${courses.length - maxCourseDisplay}`;
}
const container = document.querySelector('.dashboard .' + pSelector);
btnShowAll?.addEventListener(
'click',
function () {
const hiddenCards = container.querySelectorAll('.card.hidden');
displayCard.call(this, hiddenCards);
}
);
}
}
}
function tabsAction(pTabs, pSelector) {
let foundTabWithData = false;
let firstTabWithData = null;
pTabs.forEach(button => {
const hasData = button.getAttribute('data-has-formations') === "true";
if (!hasData && pSelector === "dashboard") {
button.classList.add('disabled');
button.style.pointerEvents = 'none';
button.style.opacity = 0.5;
} else if (!foundTabWithData && hasData && button.offsetParent !== null) {
firstTabWithData = button;
foundTabWithData = true;
}
button.addEventListener('click', () => {
if (button.classList.contains('disabled')) return;
pTabs.forEach(btn => btn.classList.remove('active'));
document.querySelectorAll(`.${pSelector} .tab-content`).forEach(content => content.classList.remove('active'));
button.classList.add('active');
const tabName = button.getAttribute('data-tab');
document.querySelector(`.${pSelector} .tab-content.${tabName}`).classList.add('active');
});
});
const firstTabWithDataVisibleOrHidden = Array.from(pTabs).find(tab =>
tab.getAttribute('data-has-formations') === "true"
);
if (firstTabWithDataVisibleOrHidden) {
firstTabWithDataVisibleOrHidden.style.display = "flex";
if (window.innerWidth <= mobileDevice) {
Array.from(pTabs).forEach(tab => {
if (tab !== firstTabWithDataVisibleOrHidden) {
tab.style.display = "none";
}
});
}
pTabs.forEach(btn => btn.classList.remove('active'));
document.querySelectorAll(`.${pSelector} .tab-content`).forEach(content => content.classList.remove('active'));
firstTabWithDataVisibleOrHidden.classList.add('active');
const tabName = firstTabWithDataVisibleOrHidden.getAttribute('data-tab');
const content = document.querySelector(`.${pSelector} .tab-content.${tabName}`);
if (content) {
content.classList.add('active');
}
} else {
const tabsContainer = document.querySelector(pSelector + " .tabs");
if (tabsContainer) {
tabsContainer.style.display = 'none';
}
}
const btnDashboardMoreMenu = document.querySelector(`.${pSelector} .tabs .more-menu`);
if (btnDashboardMoreMenu && pSelector === "dashboard") {
btnDashboardMoreMenu.addEventListener('click', (e) => {
e.stopPropagation();
const tabsContainer = document.querySelector(`.${pSelector} .tabs`);
const tabs = Array.from(tabsContainer.children);
const activeTab = tabs.find(tab => tab.classList.contains('active'));
let isCollapsed = false;
tabs.forEach(tab => {
if (tab !== activeTab) {
const isHidden = window.getComputedStyle(tab).display === "none";
tab.style.display = isHidden ? "flex" : "none";
if (!isHidden) isCollapsed = true;
}
});
if (isCollapsed) {
const currentlyVisible = tabs.find(tab => window.getComputedStyle(tab).display !== "none");
if (currentlyVisible) {
setTimeout(() => {
tabs.forEach(tab => tab.classList.remove('active'));
currentlyVisible.classList.add('active');
const tabName = currentlyVisible.getAttribute('data-tab');
const contentToShow = document.querySelector(`.${pSelector} .tab-content.${tabName}`);
if (contentToShow) {
document.querySelectorAll(`.${pSelector} .tab-content`).forEach(c => c.classList.remove('active'));
contentToShow.classList.add('active');
}
tabs.forEach(tab => {
const existingMoreMenu = tab.querySelector('.more-menu');
if (existingMoreMenu) existingMoreMenu.remove();
});
}, 0);
}
}
});
}
}
function displayCard(pSelector) {
pSelector.forEach(el => el.style.display = 'list-item');
this.style.display = 'none';
}
function addMoreMenuToFirstVisibleTab(pSelector) {
const tabsContainer = document.querySelector(`.${pSelector} .tabs`);
if (!tabsContainer) return;
const tabs = Array.from(tabsContainer.children);
tabs.forEach(tab => {
const existingMoreMenu = tab.querySelector('.more-menu');
if (existingMoreMenu) existingMoreMenu.remove();
});
const firstVisibleTabWithData = tabs.find(tab =>
window.getComputedStyle(tab).display !== "none" &&
tab.getAttribute('data-has-formations') === "true"
);
if (firstVisibleTabWithData) {
const moreMenuDiv = document.createElement('div');
moreMenuDiv.classList.add('more-menu');
moreMenuDiv.textContent = '...';
firstVisibleTabWithData.appendChild(moreMenuDiv);
moreMenuDiv.addEventListener('click', (e) => {
e.stopPropagation();
const activeTab = tabs.find(tab => tab.classList.contains('active'));
tabs.forEach(tab => {
if (tab !== activeTab) {
const isHidden = window.getComputedStyle(tab).display === "none";
tab.style.display = isHidden ? "flex" : "none";
}
});
addMoreMenuToFirstVisibleTab(pSelector);
});
}
}
function updateFavoriteSection(dashboard) {
const favoriteContainer = dashboard.querySelector('.favorite-formations');
const favoriteCards = favoriteContainer.querySelectorAll('.card');
const visibleCount = (screen.width <= mobileDevice) ? 2 : 4;
const hiddenCount = favoriteCards.length - visibleCount;
const favoriteTab = dashboard.querySelector('[data-tab="favorite-formations"] span');
if (favoriteTab) {
favoriteTab.textContent = favoriteCards.length;
}
favoriteCards.forEach((card, i) => {
card.classList.toggle('hidden', i >= visibleCount);
});
let btnShowAll = favoriteContainer.querySelector('.showAll');
if (btnShowAll && hiddenCount <= 0) {
btnShowAll.remove();
} else if (hiddenCount > 0) {
const showAllText = (screen.width <= mobileDevice)
? `Tout voir ${hiddenCount}`
: `Afficher les ${hiddenCount} autres formations enregistrées`;
if (!btnShowAll) {
btnShowAll = document.createElement('div');
btnShowAll.classList.add('showAll');
btnShowAll.innerHTML = showAllText;
btnShowAll.addEventListener('click', function () {
displayCard.call(this, favoriteContainer.querySelectorAll('.card.hidden'));
});
favoriteContainer.appendChild(btnShowAll);
} else {
btnShowAll.innerHTML = showAllText;
}
}
favoriteCards.forEach((card, i) => {
card.classList.toggle('hidden', i >= visibleCount);
});
}
document.addEventListener("DOMContentLoaded", init);
})();
(function(){
function init(){
initCloseBanner();
initTagFiltersNews();
}
function initCloseBanner()
{
let banner = document.querySelector('.banner');
let closeBanner = document.querySelector('.close-banner');
if(closeBanner)
closeBanner.addEventListener('click', function (e){
if(banner) {
banner.classList.toggle('closed');
}
Cookie.setCookie('banner', 'closed', 30);
});
}
function initTagFiltersNews() {
let rubriques = document.getElementsByClassName('news-types');
for (let i = 0; i < rubriques.length; i++) {
rubriques[i].addEventListener('click', applyFilter);
}
}
function applyFilter(event) {
event.stopImmediatePropagation();
event.stopPropagation();
let baseUrl = document.querySelector('base').getAttribute("href");
window.location.href = baseUrl +'actualites.html?'+event.currentTarget.getAttribute("data-name")+'='+event.currentTarget.getAttribute("data-value");
}
window.addEventListener('DOMContentLoaded', init);
})();
(()=>{
let mobileDevice = 728;
function init() {
const listingTabContents = document.querySelectorAll('.listing-health .tab-content');
if(listingTabContents) {
displayListingHealth(listingTabContents);
}
getAPIColleaguesCourses();
mobileMenuDefaultCourse();
mobileMenuListing();
formationSearchValidation();
initMobileFilterSidebar();
initFilterForm();
handleResizeResetFilter();
handleSearchComponent();
}
function getAPIColleaguesCourses() {
let colleagueCoursesContainer = document.querySelector(".colleague-formations-container");
if(!colleagueCoursesContainer) {
return;
}
fetch('get-colleagues-courses/')
.then((response) => {
return response.text().then((text) => {
if (!response.ok) {
throw new Error(`Erreur serveur: ${response.status}\n${text}`);
}
return text;
});
})
.then((html) => {
colleagueCoursesContainer.innerHTML = html;
})
.catch((error) => {
console.error('Erreur lors de la requête :', error.message);
colleagueCoursesContainer.innerHTML = 'Erreur lors du chargement des formations.
';
});
}
function displayListingHealth(pTabContents) {
if (screen.width <= mobileDevice) {
const maxVisible = 10;
pTabContents.forEach(tab => {
const items = tab.querySelector('.side-bar-menu').querySelectorAll('li');
if (items.length > maxVisible) {
items.forEach((item, i) => {
if (i >= maxVisible) {
item.style.display = 'none';
}
});
const hiddenCount = items.length - maxVisible;
const btn = document.createElement('div');
btn.textContent = `Tout voir (${hiddenCount})`;
btn.className = 'showAll';
btn.addEventListener('click', () => {
items.forEach(item => item.style.display = 'list-item');
btn.remove();
});
tab.appendChild(btn);
}
});
}
}
function mobileMenuDefaultCourse() {
let contentCourseDefault = document.querySelector('[data-type_formation = "default"]');
if(contentCourseDefault) {
let courseMenu = contentCourseDefault.querySelector('.course-menu');
if (courseMenu){
let liCurrent = courseMenu.querySelector('.main.current');
let cloneLi = liCurrent.cloneNode(true);
const courseMenuMobile = document.querySelector(".course-menu-mobile");
courseMenuMobile.appendChild(cloneLi);
courseMenuMobile.addEventListener('click', () => {
courseMenuMobile.classList.toggle('active');
courseMenu.classList.toggle('open');
});
courseMenuMobile.addEventListener('click', () => {
document.querySelectorAll('.course-menu').forEach(pLi => {
if (pLi.style.display === "block") {
pLi.style.display = "none";
} else {
courseMenu.style.top = courseMenuMobile.offsetHeight+"px";
pLi.style.display = "block";
}
});
if(courseMenu.classList.contains("open")) {
contentCourseDefault.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
contentCourseDefault.querySelector('.course-body').style.opacity = 0.6;
}else{
contentCourseDefault.style.backgroundColor = "white";
contentCourseDefault.querySelector('.course-body').style.opacity = "unset";
}
});
const allMenuItems = courseMenu.querySelectorAll('.main');
if (allMenuItems.length > 0 && allMenuItems[0] !== liCurrent) {
const header = document.querySelector('.header .nav');
const headerHeight = header.offsetHeight;
const rect = courseMenuMobile.getBoundingClientRect();
window.scrollTo({
top: rect.top - headerHeight,
behavior: 'instant',
});
}
}
}
}
function mobileMenuListing() {
let contentListing = document.querySelector('.formations.list .side-bar:not(.search-container .side-bar)');
if(contentListing) {
let linstingMenu = contentListing.querySelector('.side-bar-menu');
let liCurrent = linstingMenu.querySelector('.selected');
let cloneLi = liCurrent.cloneNode(true);
const content = document.querySelector(".list-formations");
const listingMenuMobile = document.querySelector(".listing-menu-mobile");
listingMenuMobile.appendChild(cloneLi);
listingMenuMobile.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
listingMenuMobile.classList.toggle('active');
linstingMenu.classList.toggle('open');
if(linstingMenu.classList.contains("open")) {
content.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
content.style.opacity = 0.4;
}else{
content.style.backgroundColor = "unset";
content.style.opacity = "unset";
}
});
}
}
function formationSearchValidation() {
const form = document.getElementById("formation-search");
if (!form) {
console.warn("Formulaire non trouvé lors du chargement du script.");
return;
}
const input = form.querySelector("input[name='search']");
const error = document.getElementById("search-error-formation");
if (!input || !error) return;
error.style.display = "none";
form.addEventListener("submit", function (e) {
const searchTerm = input.value.trim();
if (searchTerm.length < 3) {
e.preventDefault();
error.style.display = "block";
} else {
error.style.display = "none";
}
});
}
function initFilterForm() {
const formFilter = document.getElementById("filter-form");
if (!formFilter) return;
const checkboxes = formFilter.querySelectorAll("input[type='checkbox']");
checkboxes.forEach(checkbox => {
checkbox.addEventListener("change", () => {
const currentUrl = new URL(window.location.href);
const searchParams = new URLSearchParams(currentUrl.search);
const searchValue = searchParams.get("search") || "";
searchParams.set("search", searchValue);
searchParams.delete("domaines[]");
searchParams.delete("professions[]");
const selectedDomains = Array.from(formFilter.querySelectorAll("input[name='domaines[]']:checked"))
.map(cb => cb.value);
selectedDomains.forEach(val => {
searchParams.append("domaines[]", val);
});
const selectedProfessions = Array.from(formFilter.querySelectorAll("input[name='professions[]']:checked"))
.map(cb => cb.value);
selectedProfessions.forEach(val => {
searchParams.append("professions[]", val);
});
const newUrl = `recherche.html?${searchParams.toString()}`;
window.history.pushState({}, '', newUrl);
fetch(newUrl)
.then(response => response.text())
.then(html => {
const tempDiv = document.createElement("div");
tempDiv.innerHTML = html;
const newContent = tempDiv.querySelector("#ajax-result-wrapper");
const currentWrapper = document.getElementById("ajax-result-wrapper");
if (newContent && currentWrapper) {
currentWrapper.replaceWith(newContent);
}
const newForm = tempDiv.querySelector("#filter-form");
const currentForm = document.querySelector("#filter-form");
if (newForm && currentForm) {
const openToggles = Array.from(currentForm.querySelectorAll('.toggle-list'))
.map((toggle, index) => ({
index,
isActive: toggle.classList.contains('active'),
listOpen: toggle.nextElementSibling?.classList.contains('open') || false
}));
currentForm.replaceWith(newForm);
const toggles = newForm.querySelectorAll('.toggle-list');
toggles.forEach((toggle, index) => {
const saved = openToggles.find(t => t.index === index);
if (saved?.isActive) toggle.classList.add('active');
if (saved?.listOpen) {
const list = toggle.nextElementSibling;
if (list?.classList.contains('side-bar-menu')) {
list.classList.add('open');
}
}
});
initMobileFilterSidebar();
initFilterForm();
}
})
.catch(error => {
console.error("Erreur AJAX :", error);
});
});
});
}
function initMobileFilterSidebar() {
const filterBtn = document.querySelector('.filter-toggle');
const closeBtn = document.querySelector('.close-filter');
const filterOverlay = document.querySelector('#filter-overlay');
const filterPanel = document.getElementById('mobile-filter');
const filterList = document.querySelector('.filter.list .list-container .side-bar');
filterBtn?.addEventListener('click', () => {
if (getComputedStyle(filterPanel).display === "none") {
filterPanel.style.display = "block";
}
filterPanel.style.opacity = 1;
filterPanel.style.pointerEvents = 'auto';
filterPanel.classList.remove('closing');
filterPanel.classList.add('open');
filterList.style.display = "block";
filterBtn.setAttribute('aria-expanded', 'true');
filterOverlay.classList.add('active');
document.body.style.overflow = 'hidden';
});
closeBtn?.addEventListener('click', () => {
filterPanel.classList.remove('open');
filterPanel.classList.add('closing');
filterBtn.setAttribute('aria-expanded', 'false');
filterList.style.display = "none";
filterOverlay.classList.remove('active');
document.body.style.overflow = '';
const openToggles = filterPanel.querySelectorAll('.toggle-list.active');
openToggles.forEach(toggle => toggle.classList.remove('active'));
const openMenus = filterPanel.querySelectorAll('.side-bar-menu.open');
openMenus.forEach(menu => menu.classList.remove('open'));
});
filterOverlay?.addEventListener('click', () => {
filterPanel.classList.remove('open');
filterPanel.classList.add('closing');
filterOverlay.classList.remove('active');
document.body.style.overflow = '';
const openToggles = filterPanel.querySelectorAll('.toggle-list.active');
openToggles.forEach(toggle => toggle.classList.remove('active'));
const openMenus = filterPanel.querySelectorAll('.side-bar-menu.open');
openMenus.forEach(menu => menu.classList.remove('open'));
});
filterPanel?.addEventListener('animationend', (e) => {
if (e.animationName === 'slideDown') {
filterPanel.classList.remove('closing');
filterPanel.style.opacity = 0;
filterPanel.style.pointerEvents = 'none';
}
});
const containerToggleListe = document.querySelector('#mobile-filter .side-bar-form');
if (containerToggleListe) {
attachToggleEvents(containerToggleListe);
}
}
function attachToggleEvents(container) {
container.addEventListener('click', function (e) {
const toggle = e.target.closest('.toggle-list');
if (toggle && container.contains(toggle)) {
toggle.classList.toggle('active');
const list = toggle.nextElementSibling;
if (list?.classList.contains('side-bar-menu')) {
list.classList.toggle('open');
}
}
});
}
function handleResizeResetFilter() {
const searchInput = document.querySelector('#formation-search input.input-search');
if(searchInput){
searchInput.setAttribute("data-defaultplaceholder", searchInput.getAttribute("placeholder"));
if(window.innerWidth <= mobileDevice){
searchInput.setAttribute("placeholder", searchInput.getAttribute("data-mobileplaceholder"));
}
}
window.addEventListener("resize", () => {
const isDesktop = window.innerWidth > mobileDevice;
const filterPanel = document.getElementById('mobile-filter');
const filterOverlay = document.getElementById('filter-overlay');
const filterBtn = document.querySelector('.filter-toggle');
const filterList = document.querySelector('.filter.list .list-container .side-bar');
if (isDesktop && filterPanel?.classList.contains('open')) {
filterPanel.classList.remove('open', 'closing');
filterPanel.style.display = "none";
filterPanel.style.opacity = 0;
filterPanel.style.pointerEvents = 'none';
filterOverlay?.classList.remove('active');
document.body.style.overflow = '';
filterBtn?.setAttribute('aria-expanded', 'false');
filterList && (filterList.style.display = "");
const openToggles = filterPanel.querySelectorAll('.toggle-list.active');
openToggles.forEach(toggle => toggle.classList.remove('active'));
const openMenus = filterPanel.querySelectorAll('.side-bar-menu.open');
openMenus.forEach(menu => menu.classList.remove('open'));
}
if(searchInput){
if(!isDesktop){
searchInput.setAttribute("placeholder", searchInput.getAttribute("data-mobileplaceholder"));
}else{
searchInput.setAttribute("placeholder", searchInput.getAttribute("data-defaultplaceholder"));
}
}
});
}
function handleSearchComponent(){
let sc = document.querySelector('input[data-rel="SearchComponent"]');
if(!sc){
return;
}
let close = document.createElement('span');
close.classList.add("cross");
sc.parentNode.appendChild(close);
close.addEventListener('click', ()=>{
sc.value = "";
sc.setAttribute("value", "");
sc.dispatchEvent(new Event('input'));
});
sc.addEventListener('input', ()=>{
close.style.display = sc.value.length>0?"":"none";
});
}
document.addEventListener("DOMContentLoaded", init);
})();
console.warn('Dependencies : Formations is not available');
/**
* 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";
var Scroll =
{
__offsets:[],
__scrollHandler:function(e)
{
var o, currentHash;
for(var i = 0, max = Scroll.__offsets.length-1;i= o.offset && window.scrollY=next.offset && i+1 === max)
currentHash = next.href;
}
if(currentHash){
Scroll.selectHash(currentHash);
}
},
setup:function(pShiftOffset = 0)
{
window.addEventListener("scroll", Scroll.__scrollHandler, false);
document.querySelectorAll('a[href*="#"]').forEach(function(a)
{
if(a.getAttribute("href")==="#"){
return;
}
var parts = a.getAttribute("href").split("#");
if(document.location.href.indexOf(parts[0]) === -1){
return;
}
var hash = "#"+parts[1];
var target = document.getElementById(parts[1]);
if(!target){
target = document.querySelector('*[name="'+parts[1].replace("#", "")+'"]');
if(!target){
console.log("Scroll.js - hash not found "+parts[1]);
return;
}
target.setAttribute("id", parts[1]);
}
if (!Scroll.__offsets.some(item => item.href === hash)) Scroll.__offsets.push({href:hash, offset:Scroll.offsetTop(target) + pShiftOffset});
a.addEventListener("click", function(e){
e.preventDefault();
e.stopPropagation();
var t = e.currentTarget;
Scroll.to(document.getElementById(hash.replace("#", "")), .5, pShiftOffset).onComplete(function(){
Scroll.selectHash(hash);
if (pShiftOffset > 0) {
const currentUrl = window.location.href.split('#')[0];
history.replaceState(null, null, currentUrl+hash);
} else {
window.location.hash = hash.replace("#", "");
}
});
this.dispatchEvent(
new CustomEvent("scrollTo", {
bubbles: true,
}));
}, false);
});
Scroll.__offsets.sort(function(a, b)
{
if(a.offset < b.offset)
return -1;
else if(a.offset > 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, pShiftOffset = 0)
{
pTime = pTime||.5;
var st = Number(pElement.getAttribute("data-scrollTop")||Scroll.offsetTop(pElement));
st = st + pShiftOffset;
var t = document.documentElement.scrollHeight > document.documentElement.clientHeight ? 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;
},
reset: function (pShiftOffset = 0)
{
Scroll.__offsets = [];
Scroll.setup(pShiftOffset);
}
};
/**
* @author Arnaud NICOLAS - arno06@gmail.com
*/
var Dabox = (function () {
var ESCAPE_CODE = 27;
var publicAPI = {
display: function (pContent, pOptions) {
if (!created)
createDaBox();
const defaultOptions = {
dabox: {opacity: 1, class: "", width: "auto"},
daboxHide: {opacity: 0.95, display: "block"}
};
pOptions = {
...defaultOptions,
dabox: {...defaultOptions.dabox, ...pOptions?.dabox},
daboxHide: {...defaultOptions.daboxHide, ...pOptions?.daboxHide}
};
var a = document.getElementById("DaboxHide");
var b = document.getElementById("Dabox");
M4Tween.killTweensOf(a);
M4Tween.killTweensOf(b);
b.innerHTML = "";
b.style.width = pOptions.dabox.width;
b.style.overflow = "auto";
b.innerHTML = pContent;
a.style.display = pOptions.daboxHide.display;
b.style.display = "block";
b.style.filter = "alpha(opacity=0)";
b.className = pOptions.dabox.class;
M4Tween.to(a, .2, {"opacity": pOptions.daboxHide.opacity});
M4Tween.to(b, .3, {"opacity": pOptions.dabox.opacity});
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";
a.innerHTML = b.innerHTML = "";
if (hideHandler.length)
for (var i = 0, max = hideHandler.length; i < max; i++) {
hideHandler[i]();
}
if(closeHandler){
closeHandler();
}
});
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);
},
onClose:function(pHandler)
{
closeHandler = 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 = [];
var closeHandler;
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;
})();
/**
* 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";
config.removeOffset = config.removeOffset || false;
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';
if(!config.removeOffset) {
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
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.
} else {
e.preventDefault();
e.stopPropagation();
}
}
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;
}
/*
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;gSommaire
`;
document.querySelector('.site-container.content').classList.replace('full', 'with-summary');
document.querySelector('.site-container.content > div').insertBefore(summarySection, document.querySelector('.site-container.content .main'));
new Summary(summarySection);
}
}
function needDynamicSummary() {
let needDynamicSummary = false;
if (document.querySelector('.site-container.content .summary')) {
return needDynamicSummary;
}
CLASS_DYNAMIC_SUMMARY.forEach((className) => {
if (document.querySelector('.'+ className + ' .site-container.content')) {
needDynamicSummary = true;
}
})
return needDynamicSummary;
}
document.addEventListener('DOMContentLoaded', initDynamicSummary, false);
})();
var VIDALConnect = (function(){
var connectWindow;
function init(){
setup(document);
}
function setup(pTarget){
pTarget.querySelectorAll(".private").forEach(function(pEl){
let redirect = document.location.href;
if (pEl.getAttribute("href") && pEl.getAttribute("href") !== "") {
redirect = pEl.getAttribute("href");
} else if (pEl.getAttribute("data-cbo")) {
redirect = CBO.decode(pEl.getAttribute("data-cbo"));
}
let link = "acces-restreint.html?render=true";
if(pEl.classList.contains('content_profile'))
link = link+"&profile=true";
if(pEl.classList.contains('gpr_profile'))
link = link+"&gpr_profile=true";
link = link + "&redirect="+redirect+"";
pEl.rel = "Dabox[cbo:"+CBO.encode(link)+"]";
});
pTarget.querySelectorAll('[data-connect="true"]').forEach(function(pConnectionLink){
pConnectionLink.addEventListener('click', openVIDALConnectWindow, true);
});
}
function VIDALConnectClosedHandler(e){
connectWindow.close();
window.location.href = window.location.href+"";
}
function openVIDALConnectWindow(e){
if(window.pa)
pa.sendEvent('click.action',{'click':'Se connecter'});
if(connectWindow){
e.preventDefault();
e.stopImmediatePropagation();
e.stopPropagation();
return;
}
var w = 600;
var h = 600;
var left = (screen.width/2)-(w>>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 () {
const EVAL_AND_GO = "eval_and_go";
const EVAL_AND_GO_DELAY = 8000;
const EVAL_AND_GO_DAYS = 180;
function init() {
const SUBSCRIBED = "subscribed";
const NO_CONDITIONS = "noconditions";
initTopArrowAndTopNav();
initGAMScript();
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) {
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);
autoInsertContent();
// Add click on print buttons
let print_buttons = document.querySelectorAll('.print-button');
if (print_buttons) {
print_buttons.forEach((pButton) => {
pButton.addEventListener('click', function () {
window.print();
});
});
}
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';
});
}
const adsContainers = document.querySelectorAll(".ads-gam");
function addAdBanner(container) {
const iframe = container.querySelector("iframe");
if (
iframe &&
!iframe.previousElementSibling?.classList.contains("ad-banner-info") &&
!(container.previousElementSibling?.classList.contains("pub"))
) {
if (!container.parentElement.closest('.no-margin-top-add')) {
container.parentElement.style.marginTop = "20px";
}
container.parentElement.style.marginBottom = "2em";
if (container.querySelector('.optidigital-ad-center-sticky')) {
container.querySelector('.optidigital-ad-center-sticky').style.minHeight = "10em";
}
const banner = document.createElement("div");
banner.className = "ad-banner-info";
banner.textContent = "Publicité";
iframe.insertAdjacentElement("beforebegin", banner);
}
}
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.type === "childList") {
mutation.addedNodes.forEach(function (node) {
if (node.tagName === "IFRAME") {
const parentAdContainer = node.closest(".ads-gam");
if (parentAdContainer) {
addAdBanner(parentAdContainer);
}
}
});
}
});
});
adsContainers.forEach(function (container) {
observer.observe(container, { childList: true, subtree: true });
});
initEvalAndGo();
}
function initSummaries() {
const summaries = document.querySelectorAll('.summary');
summaries.forEach(function (summary) {
new Summary(summary);
});
}
function initGAMScript(){
let d = document.querySelector("head #optidigital-ad-init[src]");
if(!d){
return;
}
let consentPersonalization = d.getAttribute("data-cp")||false;
window.didomiOnReady = window.didomiOnReady || [];
const recreate = (pCopy)=>{
let sc = document.createElement("script");
["type", "id", "async", "data-config"].forEach((pAttr)=>{
sc.setAttribute(pAttr, pCopy.getAttribute(pAttr));
});
sc.setAttribute("src", pCopy.getAttribute("src"));
pCopy.parentNode.appendChild(sc);
pCopy.remove();
};
window.didomiOnReady.push(()=>{
const consentStatus = Didomi.getUserConsentStatusForAll();
const partners = {
"c:ad4health-Ma7r7943":'A',//Ad4Health
"50":'C',//CMS
};
let m3p = [];
const consentKeys = Object.keys(partners);
const hasConsent = consentKeys.reduce((pConsent, pKey)=>{
const val = isNaN(Number(pKey)) ? pKey : Number(pKey);
const c = consentStatus.vendors.enabled.indexOf(val)!==-1;
if(c){
m3p.push(partners[pKey]);
}
return pConsent || c;
}, false);
if(document.querySelector(".disconnected-nav") || consentStatus.purposes.disabled.length !== 0 || !consentStatus || !consentPersonalization){
recreate(d);
return;
}
let cfg = JSON.parse(d.getAttribute("data-config"));
cfg.pageTargeting.m3p = m3p.sort().join("");
d.setAttribute("data-config", JSON.stringify(cfg));
recreate(d);
});
}
function initTopArrowAndTopNav() {
const header = document.querySelector(".header .nav");
const arrow = document.querySelector(".scroll-page");
let lastScrollTop = window.scrollY || document.documentElement.scrollTop;
const c = function () {
if (header) {
const scrollTop = window.scrollY || document.documentElement.scrollTop;
if (window.innerWidth > 950 && scrollTop < lastScrollTop && scrollTop > 10) {
header.classList.add("scroll-up");
} else {
header.classList.remove("scroll-up");
if (window.innerWidth > 950 && scrollTop > 10) {
header.classList.add("hidden-nav");
} else {
header.classList.remove("hidden-nav");
}
}
lastScrollTop = scrollTop;
}
if (arrow) {
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();
if (arrow) {
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 initEvalAndGo() {
const evalAndGo = document.getElementById('eval-and-go');
if (evalAndGo && !Cookie.getCookie(EVAL_AND_GO)) {
setTimeout(()=> {
Cookie.setCookie(EVAL_AND_GO, 1, 1);
Dabox.display(evalAndGo.innerHTML, {
dabox: {class: "eval-and-go-dabox", width: "revert-layer"},
daboxHide: {display: "none"},
});
if (window.pa) {
pa.sendEvent('pop_in.display', {
'pop_in': 'Enquête de satisfaction'
});
}
const button = document.querySelector('.eval-and-go-dabox button');
const doNotShow = document.querySelector('.eval-and-go-dabox .do-not-show');
button.addEventListener('click', () => {
Cookie.setCookie(EVAL_AND_GO, 1, EVAL_AND_GO_DAYS);
});
doNotShow.addEventListener('click', () => {
Dabox.hide();
Cookie.setCookie(EVAL_AND_GO, 1, EVAL_AND_GO_DAYS);
});
Dabox.register(button, 'questionnaire-web');
},EVAL_AND_GO_DELAY);
}
}
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 = {
beforeRedirect: null,
init: (pTarget) => {
pTarget.querySelectorAll('*[data-cbo]').forEach(function (elt) {
if (elt.nodeName.toLowerCase() === "a" && !elt.classList.contains('private')) {
elt.setAttribute("href", CBO.decode(elt.getAttribute("data-cbo")));
return;
}
if (elt.classList.contains('private')) 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 (typeof CBO.beforeRedirect === 'function') {
const continueRedirect = CBO.beforeRedirect(event);
if (continueRedirect === false) {
event.preventDefault();
return;
}
}
if (event.ctrlKey) {
const newWindow = window.open(CBO.decode(attribute));
newWindow.focus();
} else {
document.location.href = CBO.decode(attribute);
}
}
};
function autoInsertContent(){
//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);
});
});
}
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 += '';
}
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;
}
if (window.pa.token) {
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;
const BookmarkBtn = (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, 'bookmarkAction': this.dataset.action_type, 'onlyIcon': this.dataset.only_icon, 'bookmarkIcon': this.dataset.icon, '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, 'bookmarkAction': this.dataset.action_type, 'onlyIcon': this.dataset.only_icon, 'bookmarkIcon': this.dataset.icon, 'render': '1'};
makeRequest(baseUrl + 'mes-signets/delete/', params, this.parentNode, eraseButton, showButton, addOrDeleteRequest)
}
function eraseButton(pElement) {
setTimeout(function () {
pElement.innerHTML = '';
pElement.classList.add('loading');
}, 200);
}
function showButton(pElement, pResponse) {
setTimeout(
function (){
pElement.classList.remove('loading');
pElement.innerHTML = pResponse;
init();
}, 200
);
}
window.addEventListener('DOMContentLoaded', init.bind(this), true);
return {init: init};
})();