-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
642 lines (536 loc) · 41.9 KB
/
index.html
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<!doctype html><html lang="ru"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Landing Page</title><link href="main.css" rel="stylesheet"></head><body><div class="header-container"><div class="header_contaner"><div class="header"><div class="header__content"><img class="header__logo" src="assets/images/logo.svg" alt="logo"> <input class="header__menu-check" type="checkbox" name="header" id="header"><ul class="navbar navbar_horizontal"><li class="navbar__item navbar__item_horizontal">О нас</li><li class="navbar__item navbar__item_horizontal"><div class="navbar__dropdown-title"><span>Услуги </span><i class="material-icons">expand_more</i></div><ul class="navbar__hidden-list navbar__hidden-list_horizontal"><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Обслуживание номеров</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Парковка</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Персональный сейф</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Интернет</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Кабельное телевидние</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Питание</li></ul></li><li class="navbar__item navbar__item_horizontal">Вакансии</li><li class="navbar__item navbar__item_horizontal">Новости</li><li class="navbar__item navbar__item_horizontal"><div class="navbar__dropdown-title"><span>Соглашения</span><i class="material-icons">expand_more</i></div><ul class="navbar__hidden-list navbar__hidden-list_horizontal"><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Правила проживание</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Бонусная программа</li><li class="navbar__hidden-list-item navbar__hidden-list-item_horizontal">Политика конфиденциальности</li></ul></li><li class="navbar__item navbar__separator-item navbar__item navbar__item_horizontal"><div class="navbar__separator"></div></li><li class="navbar__account-name navbar__item navbar__item_horizontal">Виталий Бакалов</li><li class="navbar__button-entry-container navbar__item navbar__item_horizontal"><div class="button"><input class="button__button-shape button__border-button navbar__button-entry" type="button" value="Войти"></div></li><li class="navbar__button-registration-container navbar__item navbar__item_horizontal"><div class="button"><input class="button__button-shape button__regular-button navbar__button-registration" type="button" value="Зарегистрироваться"></div></li></ul><label class="header__burger" for="header"><div class="header__burger-image"></div></label></div></div><ul class="navbar navbar_vertical"><li class="navbar__item navbar__item_vertical">О нас</li><li class="navbar__item navbar__item_vertical"><div class="navbar__dropdown-title navbar__dropdown-title_vertical"><span>Услуги </span><i class="material-icons">expand_more</i></div><ul class="navbar__hidden-list navbar__hidden-list_vertical"><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Обслуживание номеров</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Парковка</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Персональный сейф</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Интернет</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Кабельное телевидние</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Питание</li></ul></li><li class="navbar__item navbar__item_vertical">Вакансии</li><li class="navbar__item navbar__item_vertical">Новости</li><li class="navbar__item navbar__item_vertical"><div class="navbar__dropdown-title navbar__dropdown-title_vertical"><span>Соглашения</span><i class="material-icons">expand_more</i></div><ul class="navbar__hidden-list navbar__hidden-list_vertical"><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Правила проживание</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Бонусная программа</li><li class="navbar__hidden-list-item navbar__hidden-list-item_vertical">Политика конфиденциальности</li></ul></li><li class="navbar__item navbar__separator-item navbar__item navbar__item_vertical"><div class="navbar__separator navbar__separator_vertical"></div></li><li class="navbar__account-name navbar__item navbar__item_vertical">Виталий Бакалов</li><li class="navbar__button-entry-container navbar__item navbar__item_vertical"><div class="button"><input class="button__button-shape button__border-button navbar__button-entry" type="button" value="Войти"></div></li><li class="navbar__button-registration-container navbar__item navbar__item_vertical"><div class="button"><input class="button__button-shape button__regular-button navbar__button-registration" type="button" value="Зарегистрироваться"></div></li></ul></div></div><div class="landing-page__landing-body"><div class="landing-page__background background1"></div><div class="landing-page__background background2"></div><div class="landing-page__background background3"></div><div class="landing-page__body-content-container"><div class="landing-page__search-card-container"><div class="search-room-card"><h1 class="search-room-card__title search-room-card__title_margins">Найдём номера под ваши пожелания</h1><div class="search-room-card__dropdown"><div class="dropdown dropdown_date"><input class="dropdown__check" type="checkbox" id="searchRoomDateDrop"><div class="dropdown__date-block"><div class="dropdown__arrival dropdown_dateElement dropdown_date-element_right-padding"><h3 class="dropdown__title">прибытие</h3><label class="dropdown__header dropdown__start-date-header dropdown__header_all-angles-are-round" for="searchRoomDateDrop"><div class="dropdown__header-element dropdown__header-text dropdown__startDate">ДД.ММ.ГГГГ</div><i class="material-icons dropdown__header-element dropdown__expand-more dropdown__expand-more_absolute">keyboard_arrow_down</i></label></div><div class="dropdown__departure dropdown_dateElement dropdown_date-element_left-padding"><h3 class="dropdown__title">выезд</h3><label class="dropdown__header dropdown__end-date-header dropdown__header_all-angles-are-round" for="searchRoomDateDrop"><div class="dropdown__header-element dropdown__header-text dropdown__endDate">ДД.ММ.ГГГГ</div><i class="material-icons dropdown__header-element dropdown__expand-more dropdown__expand-more_absolute">keyboard_arrow_down</i></label></div></div><div class="calendar dropdown__calendar_padding-6 dropdown__drop-menu"><div class="calendar__month-selection-section"><i class="material-icons calendar__month-button calendar__prev-month">arrow_back</i><span class="calendar__month">Сентябрь 1989</span><i class="material-icons calendar__month-button calendar__next-month">arrow_forward</i></div><div class="calendar__days"><div class="calendar__names-of-week-days"><span class="calendar__calendar-element calendar__week-day-name">Пн</span><span class="calendar__calendar-element calendar__week-day-name">Вт</span><span class="calendar__calendar-element calendar__week-day-name">Ср</span><span class="calendar__calendar-element calendar__week-day-name">Чт</span><span class="calendar__calendar-element calendar__week-day-name">Пт</span><span class="calendar__calendar-element calendar__week-day-name">Сб</span><span class="calendar__calendar-element calendar__week-day-name">Вс</span></div><div class="calendar__week"><span class="calendar__day calendar__day-number_other-month">28</span><span class="calendar__day calendar__day-number_other-month">29</span><span class="calendar__day calendar__day-number_other-month">30</span><span class="calendar__day calendar__day-number_other-month">31</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">1</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">2</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">3</span></div><div class="calendar__week"><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">4</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">5</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month calendar__current-day">6</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">7</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">8</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">9</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">10</span></div><div class="calendar__week"><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">11</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">12</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">13</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">14</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">15</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">16</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">17</span></div><div class="calendar__week"><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">18</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">19</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">20</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">21</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">22</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">23</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">24</span></div><div class="calendar__week"><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">25</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">26</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">27</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">28</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">29</span><span class="calendar__calendar-element calendar__day calendar__day-number_current-month">30</span><span class="calendar__calendar-element calendar__day calendar__day-number_other-month">1</span></div></div><div class="calendar__buttons-panel"><div class="calendar__button-clear"><div class="button"><input class="button__button-shape button__only-text-button button__only-text-button_gray_teme calendar__button_clear" type="button" value="очистить"></div></div><div class="calendar__button-apply"><div class="button"><input class="button__button-shape button__only-text-button calendar__button_apply" type="button" value="применить"></div></div></div></div></div></div><div class="search-room-card__dropdown"><div class="dropdown dropdown_guests"><input class="dropdown__check" type="checkbox" id="searchRoomGuestsDrop"><h3 class="dropdown__title">гости</h3><label class="dropdown__header dropdown__header_all-angles-are-round" for="searchRoomGuestsDrop"><div class="dropdown__header-element dropdown__header-text">Сколько гостей</div><i class="material-icons dropdown__header-element dropdown__expand-more">keyboard_arrow_down</i></label><div class="dropdown__drop-menu"><div class="dropdown__option dropdown__drop-element"><div class="dropdown__option-title">взрослые</div><div class="dropdown__quantity-selection"><button class="dropdown__subtract-button dropdown__quantity-button" disabled="disabled">-</button><div class="dropdown__quantity-number">0</div><button class="dropdown__add-button dropdown__quantity-button">+</button></div></div><div class="dropdown__option dropdown__drop-element"><div class="dropdown__option-title">дети</div><div class="dropdown__quantity-selection"><button class="dropdown__subtract-button dropdown__quantity-button" disabled="disabled">-</button><div class="dropdown__quantity-number">0</div><button class="dropdown__add-button dropdown__quantity-button">+</button></div></div><div class="dropdown__option dropdown__drop-element"><div class="dropdown__option-title">младенцы</div><div class="dropdown__quantity-selection"><button class="dropdown__subtract-button dropdown__quantity-button" disabled="disabled">-</button><div class="dropdown__quantity-number">0</div><button class="dropdown__add-button dropdown__quantity-button">+</button></div></div><div class="dropdown__bottom-buttons-panel dropdown__drop-element"><div class="dropdown__button-clear"><div class="button"><input class="button__button-shape button__only-text-button button__only-text-button_gray_teme dropdown__button_clear" type="button" value="очистить"></div></div><div class="dropdown__button-apply"><div class="button"><input class="button__button-shape button__only-text-button dropdown__button_apply" type="button" value="применить"></div></div></div></div></div></div><div class="search-room-card__button"><div class="button button_position-relative"><input class="button__button-shape button__arrow-button undefined" type="button" value="подобрать номер"><span class="material-icons button__arrow">arrow_forward</span></div></div></div></div><div class="landing-page__body-text">Лучшие номера для вашей работы, отдыха и просто вдохновения</div></div></div><footer><div class="footer__info_container"><div class="footer__info"><ul class="footer__info-column footer__info-column_width260 footer__info-column_margin-left"><li class="footer__info-column-item"><img class="footer__logo" src="assets/images/logo.svg" alt="logo"></li><li class="footer__info-column-item"><span>Бронирование номеров в лучшем отеле 2019 года по версии ассоциации «Отельные взгляды»</span></li></ul><ul class="footer__info-column"><li class="footer__info-column-item footer__info-column-title">Навигация</li><li class="footer__info-column-item">О нас</li><li class="footer__info-column-item">Новости</li><li class="footer__info-column-item">Служба поддержки</li><li class="footer__info-column-item">Услуги</li></ul><ul class="footer__info-column"><li class="footer__info-column-item footer__info-column-title">О нас</li><li class="footer__info-column-item">О сервисе</li><li class="footer__info-column-item">Наша команда</li><li class="footer__info-column-item">Вакансии</li><li class="footer__info-column-item">Инвесторы</li></ul><ul class="footer__info-column"><li class="footer__info-column-item footer__info-column-title">Служба поддержки</li><li class="footer__info-column-item">Соглашения</li><li class="footer__info-column-item">Сообщества</li><li class="footer__info-column-item">Связь с нами</li></ul><ul class="footer__info-column footer__info-column_width260 footer__info-column_margin-right"><li class="footer__info-column-item footer__info-column-title">Подписка</li><li class="footer__info-column-item">Получайте специальные предложения и новости сервиса</li><li class="footer__info-column-item"><div class="text-field"><input class="text-field__field text-field__field-subscription" placeholder="Email"> <button class="text-field__subscription-btn"><span class="material-icons text-field__arrow-forward">arrow_forward</span></button></div></li></ul></div></div><div class="footer__copyright-container"><div class="footer__copyright"><img class="footer__logo footer__logo-in-copyright-zone" src="assets/images/logo.svg" alt="logo"><div class="footer__copyright-text">Copyright © 2018 Toxin отель. Все права зачищены.</div><div class="footer__socials-icons"><a class="footer__social-link" href="https://twitter.com/"><i class="fab fa-twitter"></i></a><a class="footer__social-link" href="https://www.facebook.com/"><i class="fab fa-facebook-square"></i></a><a class="footer__social-link" href="https://www.instagram.com/"><i class="fab fa-instagram"></i></a></div></div></div></footer><script>'use strict'
let entryCheck = false;
const entryButtons = document.querySelectorAll('.navbar__button-entry-container');
const registrationButtons = document.querySelectorAll('.navbar__button-registration-container');
const accountNames = document.querySelectorAll('.navbar__account-name');
const separators = document.querySelectorAll('.navbar__separator-item');
const dropdownItems = document.querySelectorAll('.navbar__dropdown-title_vertical');
for (let button of entryButtons) {
button.onclick = signIn;
}
for (let name of accountNames) {
name.onclick = signIn;
}
function signIn() {
if (entryCheck) {
for (let button of entryButtons) {
button.removeAttribute('style');
}
for (let button of registrationButtons) {
button.removeAttribute('style');
}
for (let name of accountNames) {
name.removeAttribute('style');
}
for (let separator of separators) {
separator.removeAttribute('style');
}
entryCheck = false;
} else {
for (let button of entryButtons) {
button.style.display = 'none';
}
for (let button of registrationButtons) {
button.style.display = 'none';
}
for (let name of accountNames) {
name.style.display = 'flex'
name.style.paddingRight = 0;
}
for (let separator of separators) {
separator.style.display = 'flex'
}
entryCheck = true;
}
}
for (let item of dropdownItems) {
item.onclick = function() {
item.nextElementSibling.classList.toggle('navbar__hidden-list_vertical-opened')
}
}'use strict'
const burger = document.querySelector('.header__burger');
const hideMenu = document.querySelector('.navbar_vertical');
const hideMenuItems = hideMenu.querySelectorAll('.navbar__item_vertical');
burger.onclick = function() {
if (hideMenu) {
hideMenu.classList.toggle('navbar_vertical-opened');
for (let item of hideMenuItems) {
item.classList.toggle('navbar__item_vertical-opened');
}
}
}
'use strict'
const header = document.querySelector('.header-container');
const landingBody = document.querySelector('.landing-page__landing-body');
const body = document.querySelector('body');
const landingSlider = document.querySelector('.landing-page__landing-body');
const backgrounds = ["url('../assets/images/landing_image_1.png')", "url('../assets/images/landing_image_2.png')", "url('../assets/images/landing_image_3.png')"];
let i = 0;
console.log(document.querySelector('.landing-page__search-card-container').clientHeight);
window.onload = function() {
const visiblePageHeight = document.documentElement.clientHeight;
if (visiblePageHeight >= 600) {
landingBody.style.height = `${document.documentElement.clientHeight - header.offsetHeight}px`;
} else if (visiblePageHeight < 600) {
landingBody.style.height = '600px';
}
}
// setTimeout(function foo() {
// landingSlider.style.background = backgrounds[++i % backgrounds.length];
// setTimeout(foo, 5000);
// }, 5000)'use strict'
class Dropdown {
constructor(dropdown) {
this.dropdown = dropdown;
this.quantitySum = 0;
this.dropdownType = this.getDropdownType(this.dropdown);
this.clearButton = this.dropdown.querySelector('.dropdown__button_clear');
this.dropdownHeaderText = this.dropdown.querySelector('.dropdown__header-text');
this.dropdownHeader = this.dropdown.querySelector('.dropdown__header');
this.dropdownStartDayHeader = this.dropdown.querySelector('.dropdown__start-date-header');
this.dropdownEndDayHeader = this.dropdown.querySelector('.dropdown__end-date-header');
this.dropMenu = this.dropdown.querySelector('.dropdown__drop-menu');
this.dropCheck = this.dropdown.querySelector('.dropdown__check');
this.closeTimer = null;
this.DROPDOWN_CLOSE_TIME = 7000;
}
getDropdownType(dropdown) {
if (dropdown.classList.contains('dropdown_guests')) {
return 'guests';
} else if (dropdown.classList.contains('dropdown_comfort')) {
return 'comfort';
} else if (dropdown.classList.contains('dropdown_date')) {
return 'date';
}
else if (dropdown.classList.contains('dropdown_filter-date')) {
return 'filterDate';
}
}
}
const dropdowns = document.querySelectorAll('.dropdown');
for (let dropdown of dropdowns) {
const dropdownObject = new Dropdown(dropdown);
if (dropdownObject.dropdownType == 'guests') {
dropdownObject.clearButton.onclick = resetOptionsValues.bind(dropdownObject)
}
if (dropdownObject.dropdownType == 'guests' || dropdownObject.dropdownType == 'comfort') {
const dropdownQuantityButtons = dropdownObject.dropdown.querySelectorAll('.dropdown__quantity-button');
for (let button of dropdownQuantityButtons) {
button.addEventListener('click', changeQuantity.bind(button, dropdownObject));
}
}
dropdownObject.dropdownHeader.onmouseout = autoCloseDropdown.bind(dropdownObject);
dropdownObject.dropMenu.onmouseout = autoCloseDropdown.bind(dropdownObject);
dropdownObject.dropdownHeader.onmouseover = resetCloseTimer.bind(dropdownObject);
dropdownObject.dropMenu.onmouseover = resetCloseTimer.bind(dropdownObject);
dropdownObject.dropdownHeader.onclick = closeOpenDropdowns.bind(dropdownObject);
if (dropdownObject.dropdownType == 'date') {
dropdownObject.dropdownStartDayHeader.onclick = closeOpenDropdowns.bind(dropdownObject);
dropdownObject.dropdownEndDayHeader.onclick = closeOpenDropdowns.bind(dropdownObject);
}
}
function closeOpenDropdowns() {
if (!this.dropCheck.checked) {
for (let dropdown of dropdowns) {
if (dropdown !== this && dropdown.querySelector('.dropdown__check').checked) {
dropdown.querySelector('.dropdown__check').checked = false;
}
}
}
}
function autoCloseDropdown() {
if (this.dropCheck.checked) {
if (this.closeTimer == null) {
startCloseTimer.bind(this)();
}
}
// if (this.dropCheck.checked &&
// !event.relatedTarget.classList.contains('dropdown__header') &&
// !event.relatedTarget.classList.contains('dropdown__drop-menu') &&
// !event.relatedTarget.offsetParent.classList.contains('dropdown__drop-menu')) {
// if (this.closeTimer == null) {
// startCloseTimer.bind(this)();
// }
// }
}
function resetCloseTimer() {
clearTimeout(this.closeTimer);
this.closeTimer = null;
// if (this.dropCheck.checked &&
// (event.relatedTarget.classList.contains('dropdown__header') ||
// event.relatedTarget.classList.contains('dropdown__drop-menu') ||
// event.relatedTarget.offsetParent.classList.contains('dropdown__drop-menu'))) {
// // event.relatedTarget.classList.contains('.calendar__buttons-panel') ||
// if (this.closeTimer != null) {
// clearTimeout(this.closeTimer);
// startCloseTimer.bind(this)();
// }
// }
}
function startCloseTimer() {
this.closeTimer = setTimeout(closeDropMenu.bind(this), this.DROPDOWN_CLOSE_TIME);
}
function closeDropMenu() {
this.dropCheck.checked = false;
this.closeTimer = null;
}
function changeQuantity(dropdown) {
let quantityElement = null;
if (this.classList.contains('dropdown__add-button')) {
quantityElement = this.previousElementSibling;
quantityElement.innerText = parseInt(quantityElement.innerText) + 1;
dropdown.quantitySum++;
} else {
quantityElement = this.nextElementSibling;
quantityElement.innerText = parseInt(quantityElement.innerText) - 1;
dropdown.quantitySum--;
}
onOffQuantityButton.bind(quantityElement)();
if (dropdown.dropdownType == 'guests') {
onOffClearButton(dropdown);
}
changeDropdownHeaderText(dropdown);
}
function onOffQuantityButton(){
if (parseInt(this.innerText) > 0) {
this.previousElementSibling.disabled = false;
} else {
this.previousElementSibling.disabled = true;
}
}
function onOffClearButton(dropdown){
if (dropdown.quantitySum > 0) {
dropdown.clearButton.style.display = 'inline-block';
} else {
dropdown.clearButton.removeAttribute('style');
}
}
function resetOptionsValues() {
/**
* Сбрасывет все значения dropdown на дефолтные
*/
const quantityElements = this.dropdown.querySelectorAll('.dropdown__quantity-number');
this.clearButton.removeAttribute('style');
for (let quantity of quantityElements) {
quantity.innerText = '0'
quantity.previousElementSibling.disabled = true;
}
changeDropdownHeaderText(this);
}
function changeDropdownHeaderText(dropdown) {
/**
* Изеняет текст хедера dropdown элемента
*/
const quantityNumbers = dropdown.dropdown.querySelectorAll('.dropdown__quantity-number');
let headerText = '';
if (dropdown.dropdownType == 'guests') {
const guests = {
'guests': parseInt(quantityNumbers[0].innerText) + parseInt(quantityNumbers[1].innerText),
'babies': parseInt(quantityNumbers[2].innerText)
};
for (let key in guests) {
if (guests[key] > 0) {
if (headerText != '')
headerText += ', ';
headerText += `${guests[key]} ${dropdownWordGenerator(key, guests[key])}`;
}
}
if (headerText == '')
headerText = 'Сколько гостей'
} else if (dropdown.dropdownType == 'comfort') {
let comfort = {
'bedroomsCount': parseInt(quantityNumbers[0].innerText),
'bedsCount': parseInt(quantityNumbers[1].innerText),
'bathroomsCount': parseInt(quantityNumbers[2].innerText)
};
for (let key in comfort) {
if (comfort[key] > 0) {
if (headerText != '')
headerText += ', ';
headerText += `${comfort[key]} ${dropdownWordGenerator(key, comfort[key])}`;
}
}
if (headerText == '')
headerText = 'Выберите удобства'
}
dropdown.dropdownHeaderText.innerText = headerText;
}
function dropdownWordGenerator(word, number) {
/**
* Склоняет слова
*/
let number10 = number % 10;
let number100 = number % 100;
if (number10 == 1 && number100 != 11) {
if (word == 'guests')
return 'гость';
else if (word == 'babies')
return 'младенец';
else if (word == 'bedroomsCount')
return 'спальня';
else if (word == 'bedsCount')
return 'кровать';
else if (word == 'bathroomsCount')
return 'ванная комната';
}
else if ((number10 >= 2 && number10 <= 4) && !(number100 >= 12 && number100 <= 14)) {
if (word == 'guests')
return 'гостя';
else if (word == 'babies')
return 'младенца';
else if (word == 'bedroomsCount')
return 'спальни';
else if (word == 'bedsCount')
return 'кровати';
else if (word == 'bathroomsCount')
return 'ванные комнаты';
}
else {
if (word == 'guests')
return 'гостей';
else if (word == 'babies')
return 'младенцев';
else if (word == 'bedroomsCount')
return 'спален';
else if (word == 'bedsCount')
return 'кроватей';
else if (word == 'bathroomsCount')
return 'ванных комнат';
}
}'use strict'
class Calendar {
constructor(calendar) {
this.MONTHS = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
this.currentDate = new Date();
this.currentDate.setHours(0, 0, 0, 0);
this.calendar = calendar;
this.calendarTitle = calendar.querySelector('.calendar__month');
this.year = this.currentDate.getFullYear();
this.month = this.currentDate.getMonth();
this.dateRange = [];
this.choiceMode = false;
this.calendarDays = this.calendar.querySelectorAll('.calendar__day');
this.prevMonthButton = calendar.querySelector('.calendar__prev-month');
this.nextMonthButton = calendar.querySelector('.calendar__next-month');
this.clearButton = calendar.querySelector('.calendar__button_clear');
this.applyButton = calendar.querySelector('.calendar__button_apply');
this.prevMonthButton.onclick = () => this.switchMonth(this.prevMonthButton);
this.nextMonthButton.onclick = () => this.switchMonth(this.nextMonthButton);
this.clearButton.onclick = () => this.clearRange();
this.applyButton.onclick = () => this.applyRange();
}
switchMonth(button) {
const date = button.classList.contains('calendar__prev-month') ? new Date(this.year, this.month - 1) : new Date(this.year, this.month + 1)
this.refreshCalendar(date);
if (this.dateRange.length > 0) {
let selectableDays = this.calendar.querySelectorAll('.calendar__day_selectable');
for (let day of selectableDays) {
if (this.dateRange.indexOf(this.getDateFromСalendar(day).getTime()) != -1) {
day.classList.add('calendar__day_selected');
}
}
this.dateRange.sort(this.compareNumbers);
this.showRange(this.dateRange);
}
}
selectDay(day) {
if (this.dateRange.length == 0 && day.classList.contains('calendar__day_selectable')) {
this.dateRange.push(this.getDateFromСalendar(day).getTime());
this.choiceMode = true;
day.classList.add('calendar__day_selected');
} else if (this.dateRange.length == 1 && day.classList.contains('calendar__day_selectable')
&& this.getDateFromСalendar(day).getTime() != this.dateRange[0]) {
this.dateRange.push(this.getDateFromСalendar(day).getTime());
this.choiceMode = false;
day.classList.add('calendar__day_selected');
} else if (this.dateRange.length == 1 && this.getDateFromСalendar(day).getTime() == this.dateRange[0]) {
this.dateRange.pop();
this.choiceMode = false;
day.classList.remove('calendar__day_selected');
day.parentNode.classList.remove('calendar__range-highlight_light-and-left-round');
day.parentNode.classList.remove('calendar__range-highlight_light-and-right-round');
} else if (this.dateRange.length == 2
&& (this.getDateFromСalendar(day).getTime() == this.dateRange[0] || this.getDateFromСalendar(day).getTime() == this.dateRange[1])) {
this.dateRange.splice(this.dateRange.indexOf(this.getDateFromСalendar(day).getTime()), 1);
this.choiceMode = true;
day.classList.remove('calendar__day_selected');
} else if (this.dateRange.length == 2 && day.classList.contains('calendar__day_selectable') &&
this.getDateFromСalendar(day).getTime() < this.dateRange.sort(this.compareNumbers)[0]) {
const selectedDays = this.calendar.querySelectorAll('.calendar__day_selected');
if (selectedDays[0]) {
selectedDays[0].classList.remove('calendar__day_selected');
}
day.classList.add('calendar__day_selected');
this.dateRange[0] = this.getDateFromСalendar(day).getTime();
this.showRange(this.dateRange);
} else if (this.dateRange.length == 2 && day.classList.contains('calendar__day_selectable') &&
this.getDateFromСalendar(day).getTime() > this.dateRange.sort(this.compareNumbers)[0]) {
const selectedDays = this.calendar.querySelectorAll('.calendar__day_selected');
if (selectedDays.length == 2) {
selectedDays[1].classList.remove('calendar__day_selected');
} else if (selectedDays.length == 1 && this.getDateFromСalendar(selectedDays[0]).getTime() != this.dateRange.sort(this.compareNumbers)[0]){
selectedDays[0].classList.remove('calendar__day_selected');
}
day.classList.add('calendar__day_selected');
this.dateRange[1] = this.getDateFromСalendar(day).getTime();
this.showRange(this.dateRange);
}
if (this.dateRange.length > 0) {
this.clearButton.style.display = 'block';
} else {
this.clearButton.removeAttribute('style');
}
}
setRangeHighlight(day) {
if (this.choiceMode && day.classList.contains('calendar__day_selectable')) {
// let selectableDays = this.calendar.querySelectorAll('.calendar__day_selectable');
let range = [this.dateRange[0], this.getDateFromСalendar(day).getTime()];
range.sort(this.compareNumbers);
this.showRange(range);
}
}
showRange(range) {
const selectableDays = this.calendar.querySelectorAll('.calendar__day_selectable');
for (let selectableDay of selectableDays) {
selectableDay.parentNode.classList.remove('calendar__range-highlight_light-and-left-round');
selectableDay.parentNode.classList.remove('calendar__range-highlight_light-and-right-round');
selectableDay.parentNode.classList.remove('calendar__range-highlight_light');
}
if (range[0] == range[1]) {
return;
}
for (let day of selectableDays) {
let dayToTime = this.getDateFromСalendar(day).getTime();
if (dayToTime == range[0]) {
day.parentNode.classList.add('calendar__range-highlight_light-and-left-round');
} else if (dayToTime == range[1]) {
day.parentNode.classList.add('calendar__range-highlight_light-and-right-round');
} else if (dayToTime >= range[0] && dayToTime <= range[1]) {
day.parentNode.classList.add('calendar__range-highlight_light');
}
}
}
compareNumbers(a, b) {
return a - b;
}
getDateFromСalendar(day) {
if (!day.classList.contains('calendar__day-number_other-month')) {
return new Date(this.year, this.month, day.innerText)
} else {
if (parseInt(day.innerText) > 20) {
return new Date(this.year, this.month - 1, day.innerText)
} else {
return new Date(this.year, this.month + 1, day.innerText)
}
}
}
clearRange() {
const selectableDays = this.calendar.querySelectorAll('.calendar__day_selectable');
for (let day of selectableDays) {
day.classList.remove('calendar__day_selected');
day.parentNode.classList.remove('calendar__range-highlight_light-and-left-round');
day.parentNode.classList.remove('calendar__range-highlight_light-and-right-round');
day.parentNode.classList.remove('calendar__range-highlight_light');
}
this.dateRange = [];
this.choiceMode = false;
this.clearButton.removeAttribute('style');
const parent = this.calendar.offsetParent;
if (parent.classList.contains('dropdown_date')) {
parent.querySelector('.dropdown__startDate').innerText = 'ДД.ММ.ГГГГ';
parent.querySelector('.dropdown__endDate').innerText = 'ДД.ММ.ГГГГ';
} else if (parent.classList.contains('dropdown_filter-date')) {
parent.querySelector('.dropdown__header-text').innerText = 'Выберите период';
}
}
applyRange() {
this.dateRange.sort(this.compareNumbers);
parent = this.calendar.offsetParent;
if (this.dateRange.length == 2) {
const startDate = new Date(this.dateRange[0]);
const endDate = new Date(this.dateRange[1]);
if (parent.classList.contains('dropdown_date')) {
parent.querySelector('.dropdown__startDate').innerText = startDate.toLocaleString("ru", {day: 'numeric', month: 'numeric', year: 'numeric'});
parent.querySelector('.dropdown__endDate').innerText = endDate.toLocaleString("ru", {day: 'numeric', month: 'numeric', year: 'numeric'})
} else if (parent.classList.contains('dropdown_filter-date')) {
parent.querySelector('.dropdown__header-text').innerText = `${startDate.getDate()} `
+ `${this.MONTHS[startDate.getMonth()].toLowerCase().slice(0, 3)} - `
+ `${endDate.getDate()} ${this.MONTHS[endDate.getMonth()].toLowerCase().slice(0, 3)} `;
}
} else {
if (parent.classList.contains('dropdown_date')) {
parent.querySelector('.dropdown__startDate').innerText = 'ДД.ММ.ГГГГ';
parent.querySelector('.dropdown__endDate').innerText = 'ДД.ММ.ГГГГ';
} else if (parent.classList.contains('dropdown_filter-date')) {
parent.querySelector('.dropdown__header-text').innerText = 'Выберите период';
}
}
}
refreshCalendar(date=new Date(this.year, this.month)) {
/**
* Обновляет информацию на календаре
*/
this.removeCalendar();
this.createNewCalendar(date);
}
removeCalendar() {
/**
* Удаляет текущий календарь
*/
const weekBloks = this.calendar.querySelectorAll('.calendar__week');
for (let weekNode of weekBloks) {
weekNode.remove();
}
}
createNewCalendar(date) {
/**
* Создает новый календарь
*/
this.year = date.getFullYear();
this.month = date.getMonth();
const daysInCurrentMonth = 32 - new Date(this.year, this.month, 32).getDate();
const daysInPrevMonths = 32 - new Date(this.year, this.month - 1, 32).getDate();
const firstDayMonth = date.getDay() == 0 ? 7 : date.getDay();
const calendarBody = this.calendar.querySelector('.calendar__days');
const weeksInCalendar = Math.ceil((daysInCurrentMonth + firstDayMonth - 1) / 7);
this.calendarTitle.innerText = `${this.MONTHS[this.month]} ${this.year}`;
let calendarDate = date;
if (firstDayMonth != 1) {
calendarDate = new Date(date.getFullYear(), date.getMonth() - 1, daysInPrevMonths - firstDayMonth + 2);
}
for (let week = 0; week < weeksInCalendar; week++) {
const weekDiv = document.createElement('div');
weekDiv.className = 'calendar__week';
for (let weekDayNumber = 0; weekDayNumber < 7; weekDayNumber++) {
let classList = 'calendar__calendar-element calendar__day';
if (calendarDate.getMonth() != date.getMonth()) {
classList = 'calendar__calendar-element calendar__day calendar__day-number_other-month';
}
const calendarDay = document.createElement('span');
calendarDay.onclick = () => this.selectDay(calendarDay);
calendarDay.classList = classList;
calendarDay.innerText = calendarDate.getDate();
const rangeHighlight = document.createElement('div');
rangeHighlight.onmouseover = () => this.setRangeHighlight(calendarDay);
rangeHighlight.classList = 'calendar__range-highlight calendar__calendar-element';
rangeHighlight.append(calendarDay);
weekDiv.append(rangeHighlight);
if(calendarDate.getFullYear() == this.currentDate.getFullYear()
&& calendarDate.getMonth() == this.currentDate.getMonth()
&& calendarDate.getDate() == this.currentDate.getDate()) {
calendarDay.classList.add('calendar__current-day');
}
if(calendarDate >= this.currentDate) {
calendarDay.classList.add('calendar__day_selectable');
}
calendarDate.setDate(calendarDate.getDate() + 1);
}
calendarBody.append(weekDiv);
}
}
}
const calendars = document.querySelectorAll('.calendar');
for (let calendarInThePage of calendars) {
const calendar = new Calendar(calendarInThePage);
calendar.refreshCalendar();
}</script><script src="main.eba72a9eda82ad14459a.js"></script></body></html>