-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmartgear2.js
More file actions
150 lines (136 loc) · 5.94 KB
/
Copy pathsmartgear2.js
File metadata and controls
150 lines (136 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
app.labels.errors.inputs.passwordMatch = {
fr: 'Les mots de passe ne correspondent pas',
en: 'Passwords do not match'
}
document.querySelectorAll('[class*=cssvar--]').forEach((el)=>{
let prop = el.classList.value.match(/cssvar\S+/gm)[0].replace('cssvar--','').split('--');
el.style.setProperty('--'+prop[0], prop[1]);
})
document.documentElement.style.setProperty('--scrollbar-width', (window.innerWidth - document.documentElement.clientWidth) + "px");
let viewportPaddingTop = 0;
if (document.querySelector('.headerFW '))
viewportPaddingTop += parseInt(window.getComputedStyle(document.querySelector('.headerFW ')).height );
if (document.querySelector('.mod_breadcrumb '))
viewportPaddingTop += parseInt(window.getComputedStyle(document.querySelector('.mod_breadcrumb ')).height );
viewportPaddingTop += 'px';
document.documentElement.style.setProperty('--viewport-padding-top',viewportPaddingTop );
$(function () {
// INIT
$(window).resize(function () {
// $('body.home .heroFW').css('height',viewport.height - $('#header').outerHeight());
if ($('.mod_faqpage .accordionFW').length) {
resizeFAQ();
}
if ($('table.calendar').length) {
toggleCalendarEventView();
}
});
$('.mod_wem_locations_map').attr('id','mapWrapper');
$('table.calendar').each(function (index,$calendar) {
$calendar = $($calendar);
// $calendar.find('tr').each(function(index,row){
// $(row).find('.event').each(function(index,event){
// if ($('.event[data-event='+event.getAttribute('data-event')+']').length>1) {
// $($('.event[data-event='+event.getAttribute('data-event')+']').slice(1)).addClass('hidden');
// // $($('.event[data-event='+event.getAttribute('data-event')+']').slice(0,-1)).addClass('hidden');
// $('.event[data-event='+event.getAttribute('data-event')+']').first().addClass('span-'+$('.event[data-event='+event.getAttribute('data-event')+']').length);
// }
// })
// });
$calendar.find('.event').not('.hidden').each(function (index,event) {
setTimeout(function () {
$(event).addClass('active');
},100*index);
});
$calendar.prev('.loader').remove();
});
$('.calendar__event').each(function () {
$(this).css('background-color',utils.stringToColor($(this).text()));
});
$('.password-checker').each(function(){
var $checker = $(this);
var $input = $checker.find('input[type=password][name]');
var $confirm = $checker.find('input[type=password].confirm');
var $helper = $checker.find('.helper');
$checker.find('input+button').on('click',function(){
$(this).find('i[class*=fa]').toggleClass('fa-eye fa-eye-slash');
$(this).prev('input').attr('type',($(this).prev('input').attr('type') == 'password' ? 'text':'password'));
});
$input.on('change keyup',function(){
$helper.find('[pattern]').each(function(){
$(this).removeClass('valid');
var reg = new RegExp(this.getAttribute('pattern'));
if ($input.val().search(reg) != -1)
$(this).addClass('valid');
});
});
$checker.find('input').on('change keyup',function(){
$confirm.get(0).setCustomValidity('');
if ($input.val() !== $confirm.val())
$confirm.get(0).setCustomValidity(app.labels.errors.inputs.passwordMatch[app.lang]);
})
})
var setupLightbox = function(el){
var item = $(el);
item.attr('data-lightbox',item.attr('data-lightbox')!=""?item.attr('data-lightbox'):utils.uniqid());
item.attr('data-modal',item.attr('data-lightbox'));
item.attr('data-autoload',false);
if ($('a[data-lightbox='+item.attr('data-lightbox')+']').length > 1) {
$('a[data-lightbox='+item.attr('data-lightbox')+']').each(function(i){
$(this).attr('data-gallery',$(this).attr('data-lightbox'));
$(this).attr('data-modal',$(this).attr('data-lightbox')+'__'+i);
});
} else {
item.attr('data-modal',$(this).attr('data-lightbox'));
}
}
$('a[data-lightbox]').each(function(){
setupLightbox(this);
})
$('a[data-lightbox]').each(function(){
app.ModalFW.createModalFromTrigger(this);
})
utils.addHtmlHook('a[data-lightbox]', function(item){
$(item).each(function(){
if(app.ModalFW.debug) app.log("Trigger added to dom for modal "+$(this).data('modal'));
setupLightbox(this);
})
$(item).each(function(){
app.ModalFW.createModalFromTrigger(this);
})
});
// encapsulate iframe in 16:9 box
$('.mod_article iframe').not('.custom').each(function(){
if (!$(this).parent().hasClass('img-container'))
$(this).wrapAll('<div class="img-container r_16-9"></div>');
});
$('#smartgearDisclaimer .close').on('click',function(){
$('#smartgearDisclaimer').fadeOut();
})
});
var toggleCalendarEventView = function toggleCalendarEventView()
{
$('table.calendar').find('.days.active').each(function (index,$day) {
$day = $($day);
var offseted = false;
$day.find('.event').not('.hidden').unwrap('.reduced').each(function () {
if ($(this).position().top <= 0) {
offseted = true;
}
});
if (offseted) {
$day.find('.event').not('.hidden').wrapAll('<div class="reduced"></div>');
}
});
};
var resizeFAQ = function resizeFAQ()
{
var $titles = $('.mod_faqpage .accordionFW__item .accordionFW__title').css('width','auto');
var maxWidth = 0;
$titles.each(function () {
if (this.scrollWidth+10 > maxWidth) {
maxWidth = this.scrollWidth+10;
}
});
$titles.outerWidth(maxWidth);
}