40e4f314
Mihail
rewrite js skript...
|
1
|
$(document).ready(function () {
|
b13c67c3
Mihail
output price in g...
|
2
3
4
5
6
|
// для таблицы кроссов, классы обозначаются через cross_
var cross_prefix = '';
// по умолчанию - цены в долларах, остальные скрываем
var show_currency = ['usd'];
|
40e4f314
Mihail
rewrite js skript...
|
7
|
var hidden_currency = ['uah', 'eur'];
|
b13c67c3
Mihail
output price in g...
|
8
|
|
40e4f314
Mihail
rewrite js skript...
|
9
|
$(document).on("click", ".currency", changeCurrency);
|
b13c67c3
Mihail
output price in g...
|
10
|
|
40e4f314
Mihail
rewrite js skript...
|
11
|
function changeCurrency() {
|
b13c67c3
Mihail
output price in g...
|
12
|
|
40e4f314
Mihail
rewrite js skript...
|
13
|
if ($(this).attr('id') === 'grivna') {
|
36a8dd60
Mihail
add pjax to goods...
|
14
|
show_currency = ['uah'];
|
40e4f314
Mihail
rewrite js skript...
|
15
16
|
hidden_currency = ['eur', 'usd'];
} else if ($(this).attr('id') === 'euro') {
|
36a8dd60
Mihail
add pjax to goods...
|
17
|
show_currency = ['eur'];
|
40e4f314
Mihail
rewrite js skript...
|
18
19
|
hidden_currency = ['uah', 'usd'];
} else if ($(this).attr('id') === 'dollars') {
|
36a8dd60
Mihail
add pjax to goods...
|
20
|
show_currency = ['usd'];
|
40e4f314
Mihail
rewrite js skript...
|
21
|
hidden_currency = ['uah', 'eur'];
|
36a8dd60
Mihail
add pjax to goods...
|
22
23
24
|
}
$('.currency').removeClass('active_button_purple1');
$(this).addClass('active_button_purple1');
|
b13c67c3
Mihail
output price in g...
|
25
|
|
b13c67c3
Mihail
output price in g...
|
26
27
28
|
setVisiblePrice();
}
|
40e4f314
Mihail
rewrite js skript...
|
29
|
function setVisiblePrice() {
|
b13c67c3
Mihail
output price in g...
|
30
|
// элементы с классами из show_currency отобразим
|
40e4f314
Mihail
rewrite js skript...
|
31
|
for (var i = 0; i < show_currency.length; i++) {
|
b13c67c3
Mihail
output price in g...
|
32
|
var arr_elements = document.getElementsByClassName(show_currency[i] + cross_prefix);
|
b13c67c3
Mihail
output price in g...
|
33
|
|
40e4f314
Mihail
rewrite js skript...
|
34
35
|
for (var j = 0; j < arr_elements.length; j++) {
if (arr_elements[j].classList.contains('hidden'))
|
b13c67c3
Mihail
output price in g...
|
36
37
38
|
arr_elements[j].classList.remove('hidden');
}
}
|
b13c67c3
Mihail
output price in g...
|
39
|
// элементы с классами из hidden_currency спрячем
|
40e4f314
Mihail
rewrite js skript...
|
40
|
for (var i = 0; i < hidden_currency.length; i++) {
|
b13c67c3
Mihail
output price in g...
|
41
|
var arr_elements = document.getElementsByClassName(hidden_currency[i] + cross_prefix);
|
40e4f314
Mihail
rewrite js skript...
|
42
43
|
for (var j = 0; j < arr_elements.length; j++) {
if (!arr_elements[j].classList.contains('hidden'))
|
b13c67c3
Mihail
output price in g...
|
44
45
46
47
48
|
arr_elements[j].classList.add('hidden');
}
}
}
|
e0e82549
OlenaKl
table
|
49
|
//модальное окно для фото
|
40e4f314
Mihail
rewrite js skript...
|
50
51
|
// ловим клик по ссылки с id="go"
$(document).on("click", 'a#go_photo', function (event) {
|
e0e82549
OlenaKl
table
|
52
53
54
|
event.preventDefault(); // выключаем стандартную роль элемента
var scrollTop = window.pageYOffset ? window.pageYOffset : (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
viewportHeight = $(window).height();
|
40e4f314
Mihail
rewrite js skript...
|
55
56
|
var modalWidth = $('#modal_form_photo').width() / 2;
var modalHeight = $('#modal_form_photo').outerHeight() / 2;
|
e0e82549
OlenaKl
table
|
57
|
$('#overlay').fadeIn(400, // сначала плавно показываем темную подложку
|
40e4f314
Mihail
rewrite js skript...
|
58
|
function () { // после выполнения предъидущей анимации
|
e0e82549
OlenaKl
table
|
59
|
$('#modal_form_photo')
|
40e4f314
Mihail
rewrite js skript...
|
60
61
|
.css({'display': 'block', opacity: 1, marginTop: -modalHeight, marginLeft: -modalWidth}) // убираем у модального окна display: none;
.animate({opacity: 1, top: scrollTop + (viewportHeight / 2)}, 200); // плавно прибавляем прозрачность одновременно со съезжанием вниз
|
e0e82549
OlenaKl
table
|
62
63
64
65
|
});
});
/* Закрытие модального окна, тут делаем то же самое но в обратном порядке */
|
40e4f314
Mihail
rewrite js skript...
|
66
|
$(document).on( "click",'#modal_close, #overlay', function () { // ловим клик по крестику или подложке
|
e0e82549
OlenaKl
table
|
67
68
|
$('#modal_form_photo')
.animate({opacity: 0, top: '45%'}, 200, // плавно меняем прозрачность на 0 и одновременно двигаем окно вверх
|
40e4f314
Mihail
rewrite js skript...
|
69
|
function () { // после анимации
|
e0e82549
OlenaKl
table
|
70
71
72
73
74
|
$(this).css('display', 'none'); // делаем ему display: none;
$('#overlay').fadeOut(400); // скрываем подложку
}
);
});
|
40e4f314
Mihail
rewrite js skript...
|
75
|
|
e0e82549
OlenaKl
table
|
76
77
|
//открытие-закрытие карточки товара и смена текста на бирке карточки товара
function changeText() {
|
e0e82549
OlenaKl
table
|
78
|
e = document.getElementById('button_grey_card');
|
e0e82549
OlenaKl
table
|
79
80
|
e.innerHTML = e.innerHTML == "Скрыть карточку товара" ? "Открыть карточку товара" : "Скрыть карточку товара";
}
|
40e4f314
Mihail
rewrite js skript...
|
81
82
|
$(document).on( "click",'#button_grey_card' , function () {
|
e0e82549
OlenaKl
table
|
83
84
85
86
87
88
89
|
changeText();
$(this).toggleClass('change_b');
$('.tovar_card').toggleClass('tovar_card_visible');
$('.table').toggleClass('table_height');
});
//стрелочки вниз
|
40e4f314
Mihail
rewrite js skript...
|
90
|
$(document).on( "click",'.link_sort', function () {
|
e0e82549
OlenaKl
table
|
91
92
93
94
95
96
|
$(this).find('.desc').toggleClass('arrow_downA');
})
});
|