Skip to content

Commit d3be8c8

Browse files
author
Keks
committed
✔️ Сборка #13
1 parent 4955e4e commit d3be8c8

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

13/js/form.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,22 @@ const toggleSubmitButton = (isDisabled, text) => {
3838
submitButtonElement.textContent = text;
3939
};
4040

41-
function openModalForm() {
41+
const resetForm = () => {
42+
formElement.reset();
43+
};
44+
45+
const openModalForm = () => {
4246
modalFormElement.classList.remove('hidden');
4347
bodyElement.classList.add('modal-open');
4448
document.addEventListener('keydown', onDocumentKeydown);
4549
sliderWrapperElement.classList.add('hidden');
46-
}
50+
};
4751

4852
function closeModalForm() {
4953
modalFormElement.classList.add('hidden');
5054
bodyElement.classList.remove('modal-open');
5155
document.removeEventListener('keydown', onDocumentKeydown);
52-
formElement.reset();
56+
resetForm();
5357
resetPhotoFilters();
5458
resetScaleValue();
5559
resetValidation();
@@ -91,6 +95,7 @@ const initModalForm = () => {
9195
preview.style.backgroundImage = `url(${imageURL})`;
9296
});
9397
} else {
98+
resetForm();
9499
showAlertTemporarily('Неверный формат изображения');
95100
}
96101
});

13/js/photo-filters.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ const DefaultSettings = {
55
STEP: 1
66
};
77

8-
const EffectsMap = {
9-
'chrome': 'grayscale',
10-
'sepia': 'sepia',
11-
'marvin': 'invert',
12-
'phobos': 'blur',
13-
'heat': 'brightness',
14-
};
15-
168
const EffectsSettings = {
179
'chrome': {
1810
range: {
@@ -56,6 +48,14 @@ const EffectsSettings = {
5648
}
5749
};
5850

51+
const effectsMap = {
52+
'chrome': 'grayscale',
53+
'sepia': 'sepia',
54+
'marvin': 'invert',
55+
'phobos': 'blur',
56+
'heat': 'brightness',
57+
};
58+
5959
const sliderWrapperElement = document.querySelector('.img-upload__effect-level');
6060
const sliderElement = sliderWrapperElement.querySelector('.effect-level__slider');
6161
const effectFieldElement = sliderWrapperElement.querySelector('.effect-level__value');
@@ -84,7 +84,7 @@ const onSliderUpdate = () => {
8484
const sliderValue = sliderElement.noUiSlider.get();
8585
effectFieldElement.value = `${sliderValue}`;
8686

87-
const propertyValue = `${EffectsMap[currentFilter]}(${sliderValue}${currentFilter === 'marvin' ? '%' : ''}${currentFilter === 'phobos' ? 'px' : ''})`;
87+
const propertyValue = `${effectsMap[currentFilter]}(${sliderValue}${currentFilter === 'marvin' ? '%' : ''}${currentFilter === 'phobos' ? 'px' : ''})`;
8888

8989
imageElement.style.filter = `${propertyValue}`;
9090
};

13/js/photo-modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const renderBigPhoto = ({url, likes, description}) => {
4545
modalDescriptionElement.textContent = description;
4646
};
4747

48-
function openPhotoModal(photo) {
48+
const openPhotoModal = (photo) => {
4949
modalElement.classList.remove('hidden');
5050
comments = photo.comments;
5151

@@ -56,7 +56,7 @@ function openPhotoModal(photo) {
5656

5757
document.addEventListener('keydown', onDocumentKeydown);
5858
bodyElement.classList.add('modal-open');
59-
}
59+
};
6060

6161
function closePhotoModal() {
6262
startIndex = 0;

13/js/send-info-modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const createSendInfoModal = (template, message) => {
3737
return templateModalElement;
3838
};
3939

40-
function renderSendInfoModal(status, message) {
40+
const renderSendInfoModal = (status, message) => {
4141
if (!VALID_STATUSES.includes(status)) {
4242
return;
4343
}
@@ -47,7 +47,7 @@ function renderSendInfoModal(status, message) {
4747
bodyElement.append(modalElement);
4848
document.addEventListener('keydown', onBodyKeydown);
4949
modalElement.addEventListener('click', onModalClick);
50-
}
50+
};
5151

5252
function removeSendInfoModal() {
5353
modalElement.remove();

13/js/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ const getPluralForm = (number, formForOne, formForFew, formForMany) => {
5757
return formForMany;
5858
};
5959

60-
function debounce (callback, timeoutDelay = DEFAULT_TIMEOUT_DELAY) {
60+
const debounce = (callback, timeoutDelay = DEFAULT_TIMEOUT_DELAY) => {
6161
let timeoutId;
6262

6363
return (...rest) => {
6464
clearTimeout(timeoutId);
6565
timeoutId = setTimeout(() => callback.apply(this, rest), timeoutDelay);
6666
};
67-
}
67+
};
6868

6969
export {
7070
findTemplateById,

0 commit comments

Comments
 (0)