-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·95 lines (81 loc) · 2.16 KB
/
main.js
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
jQuery(document).ready(function () {
/**
* Swiper
*/
var swiper = new Swiper('.swiper-container', {
direction: 'vertical',
slidesPerView: 1,
spaceBetween: 30,
mousewheel: false,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
autoplay: {
delay: 5000,
},
});
/**
* Nice select
*/
jQuery('select').niceSelect();
/**
* Nice select hasn't placeholder. Fix for this issue
*/
jQuery('select').on('change', function () {
var target = $(this);
if (target.find('option:first-child:selected').length > 0) {
target.next('.styled-select').find('.current').css('color', '#BEBEBE');
} else {
target.next('.styled-select').find('.current').css('color', '');
}
});
jQuery('select').trigger('change');
/**
* inputs type=date have height 2px more. Fix for this
*/
jQuery('input[type="date"]').each(function () {
var target = $(this);
target.attr('type', 'text');
var h = target.outerHeight();
target.attr('type', 'date');
target.css({ height: h });
});
/**
* jQuery datepicker if embeded datepicker is not supported
*/
if (jQuery('[type="date"]').prop('type') != 'date') {
jQuery('[type="date"]').datepicker();
}
/**
* Close all dropdown
*/
jQuery('html, body').on('click', function () {
$('.dropdown-content').height(0);
});
/**
* For height:auto transition does not work.
* We need to get this height before show dropdown to user.
*/
jQuery('.main-menu li').on('click', function () {
var target = jQuery(this);
var dropdownContent = target.children('.dropdown-content');
if (dropdownContent.height() > 0) {
dropdownContent.height(0);
return;
}
var parent = target.parent();
for (const e of parent.children()) {
if (e == this) {
continue;
}
jQuery(e).removeClass('show-drop');
jQuery(e).children('.dropdown-content').height(0);
}
var activeHeight = dropdownContent.css('height', 'auto').height();
dropdownContent.height(0);
target.toggleClass('show-drop');
dropdownContent.height(activeHeight);
return false;
});
});