Skip to content

Commit

Permalink
Исправляет ошибки
Browse files Browse the repository at this point in the history
  • Loading branch information
elviraSolov committed Feb 13, 2023
1 parent 3719ed8 commit 61a30f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions js/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getData = (onSuccess) => {
fetch('https://25.javascript.pages.academy/kekstagram/data')
fetch('https://25.javascript.pages.academy/kekstagram/data')
.then((response) => response.json())
.then((posts) => {
onSuccess(posts);
Expand All @@ -21,7 +21,7 @@ const sendData = (onSuccess, onFail, body) => {
})
.catch((err) => {
onFail(err.message);
});
});
};

export { getData, sendData };
26 changes: 13 additions & 13 deletions js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ const MIN_HASHTAG_LENGTH = 2;
const MAX_HASHTAG_LENGTH = 20;
const UNVALID_SYMBOLS = /[^a-zA-Z0-9а-яА-ЯёЁ]/g;

const closeUploadOverlay = () => {
form.reset();
pristine.reset();
uploadOverlay.classList.add('hidden');
body.classList.remove('modal-open');
document.removeEventListener('keydown', onEscKeydown);
};

const isTextFieldFocused = () =>
document.activeElement === hashtags ||
document.activeElement === comment;

const onEscKeydown = (evt) => {
if (isEscapeKey(evt) && !isTextFieldFocused()) {
evt.preventDefault();
closeUploadOverlay();
}
};

let pristine = new Pristine(form, {
const pristine = new Pristine(form, {
classTo: 'img-upload__element',
errorTextParent: 'img-upload__element',
errorTextClass: 'img-upload__error'
Expand All @@ -35,18 +47,6 @@ const openUploadOverlay = () => {
document.addEventListener('keydown', onEscKeydown);
};

const closeUploadOverlay = () => {
form.reset();
pristine.reset();
uploadOverlay.classList.add('hidden');
body.classList.remove('modal-open');
document.removeEventListener('keydown', onEscKeydown);
};

const isTextFieldFocused = () =>
document.activeElement === hashtags ||
document.activeElement === comment;

const startsWithHash = (string) => string[0] === '#';

const hasValidLength = (string) =>
Expand Down
3 changes: 1 addition & 2 deletions js/picture-editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const EFFECTS = [

const DEFAULT_EFFECT = EFFECTS[0];
let chosenEffect = DEFAULT_EFFECT;
const isDefault = () => chosenEffect === DEFAULT_EFFECT;

noUiSlider.create(slider, {
range: {
Expand Down Expand Up @@ -98,8 +99,6 @@ const onFormChange = (evt) => {
updateSlider(chosenEffect);
};

const isDefault = () => chosenEffect === DEFAULT_EFFECT;

const onSliderUpdate = () => {
image.style.filter = 'none';
image.className = '';
Expand Down

0 comments on commit 61a30f8

Please sign in to comment.