# Conflicts: # .gitignore # project/templates/lilcity/index.htmlremotes/origin/hasaccess
commit
854f102ada
19 changed files with 13857 additions and 3951 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,248 +1,12 @@ |
||||
// example of simple includes for js
|
||||
//=include lib/jquery.min.js
|
||||
//=include lib/owl.carousel.min.js
|
||||
//=include lib/jquery-ui.min.js
|
||||
//=include lib/datepicker-ru.js
|
||||
|
||||
// global
|
||||
var mobileWidth = 600; |
||||
|
||||
// header
|
||||
(function(){ |
||||
var header = $('.js-header'), |
||||
menu = header.find('.js-header-menu'), |
||||
wrap = header.find('.js-header-wrap'), |
||||
close = header.find('.js-header-close'), |
||||
section = header.find('.js-header-section'), |
||||
list = header.find('.js-header-list'); |
||||
|
||||
menu.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
wrap.addClass('visible'); |
||||
} |
||||
}); |
||||
|
||||
close.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
wrap.removeClass('visible'); |
||||
$(window).scrollTop(0); |
||||
} |
||||
}); |
||||
|
||||
section.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
var _this = $(this); |
||||
|
||||
_this.toggleClass('open'); |
||||
_this.next().slideToggle(); |
||||
} |
||||
}); |
||||
}()); |
||||
|
||||
// search
|
||||
(function(){ |
||||
var search = $('.js-search'), |
||||
input = search.find('.js-search-input'), |
||||
btn = search.find('.js-search-btn'); |
||||
|
||||
btn.on('click', function(e){ |
||||
if ($(window).width() >= mobileWidth) { |
||||
if (!search.hasClass('open')) { |
||||
e.preventDefault(); |
||||
} |
||||
search.addClass('open'); |
||||
setTimeout(function(){ |
||||
input.focus(); |
||||
}, 200); |
||||
} |
||||
}); |
||||
|
||||
search.on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
search.removeClass('open'); |
||||
input.val(''); |
||||
}); |
||||
}()); |
||||
|
||||
// toggle
|
||||
(function(){ |
||||
$('.js-toggle-head').on('click', function(e){ |
||||
e.preventDefault(); |
||||
var _this = $(this); |
||||
_this.toggleClass('active'); |
||||
_this.next().slideToggle(); |
||||
}); |
||||
}()); |
||||
|
||||
// auth
|
||||
(function(){ |
||||
var auth = $('.js-auth'), |
||||
type = auth.find('.js-auth-type'), |
||||
tab = auth.find('.js-auth-tab'), |
||||
login = auth.find('.js-auth-login'), |
||||
pass = auth.find('.js-auth-pass'), |
||||
goPass = auth.find('.js-auth-go-pass'), |
||||
goEnter = auth.find('.js-auth-go-enter'); |
||||
|
||||
type.on('click', function(e){ |
||||
e.preventDefault(); |
||||
var _this = $(this), |
||||
index = _this.index(); |
||||
|
||||
type.removeClass('active'); |
||||
_this.addClass('active'); |
||||
tab.hide(); |
||||
tab.eq(index).fadeIn(); |
||||
}); |
||||
|
||||
goPass.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
login.hide(); |
||||
pass.fadeIn(); |
||||
}); |
||||
|
||||
goEnter.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
pass.hide(); |
||||
login.fadeIn(); |
||||
}); |
||||
}()); |
||||
|
||||
// select
|
||||
(function(){ |
||||
var select = $('.js-select'); |
||||
if (select.length) { |
||||
select.each(function(){ |
||||
var _this = $(this), |
||||
head = _this.find('.js-select-head'), |
||||
option = _this.find('.js-select-option'), |
||||
input = _this.find('.js-select-input'); |
||||
|
||||
head.on('click', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
if (_this.hasClass('active')) { |
||||
_this.removeClass('active'); |
||||
} else { |
||||
select.removeClass('active'); |
||||
_this.addClass('active'); |
||||
} |
||||
}); |
||||
|
||||
option.on('click', function(e){ |
||||
e.preventDefault(); |
||||
_this.addClass('selected'); |
||||
|
||||
var _thisOption = $(this), |
||||
value = _thisOption.text(); |
||||
|
||||
head.text(value); |
||||
|
||||
option.removeClass('active'); |
||||
_thisOption.addClass('active'); |
||||
|
||||
input.val(value); |
||||
}); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
select.removeClass('active'); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// datepicker
|
||||
(function(){ |
||||
var datepicker = $('.js-datepicker'); |
||||
if (datepicker.length) { |
||||
$.datepicker.setDefaults( $.datepicker.regional["ru"]); |
||||
datepicker.each(function(){ |
||||
$(this).datepicker({ |
||||
dateFormat: "dd/mm/yy" |
||||
}); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// tabs
|
||||
(function(){ |
||||
var tabs = $('.js-tabs'); |
||||
if (tabs.length) { |
||||
tabs.each(function(){ |
||||
var _this = $(this), |
||||
btn = _this.find('.js-tabs-btn'), |
||||
item = _this.find('.js-tabs-item'); |
||||
|
||||
btn.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
var _thisBtn = $(this), |
||||
index = _thisBtn.index(); |
||||
|
||||
btn.removeClass('active'); |
||||
_thisBtn.addClass('active'); |
||||
item.hide(); |
||||
item.eq(index).fadeIn(); |
||||
}); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// popup
|
||||
(function(){ |
||||
var body = $('body'), |
||||
popup; |
||||
|
||||
$('body').on('click', '[data-popup]', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
var data = $(this).data('popup'); |
||||
popup = $(data); |
||||
showPopup(); |
||||
}); |
||||
|
||||
$('.js-popup-close').on('click', function(e){ |
||||
e.preventDefault(); |
||||
hidePopup(); |
||||
}); |
||||
|
||||
$('body').on('click', '.js-outer', function(){ |
||||
if (popup != undefined) { |
||||
hidePopup(); |
||||
} |
||||
}); |
||||
|
||||
$('.js-popup-wrap').on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).keyup(function(e){ |
||||
if (e.keyCode === 27) hidePopup(); |
||||
}); |
||||
|
||||
function showPopup(){ |
||||
body.addClass('no-scroll'); |
||||
popup.addClass('open'); |
||||
setTimeout(function(){ |
||||
popup.addClass('visible'); |
||||
}, 100); |
||||
} |
||||
|
||||
function hidePopup(){ |
||||
body.removeClass('no-scroll'); |
||||
popup.removeClass('visible'); |
||||
setTimeout(function(){ |
||||
popup.removeClass('open'); |
||||
}, 300); |
||||
} |
||||
}()); |
||||
/** |
||||
* Входная точка клиентского приложения. |
||||
*/ |
||||
import "./modules/common"; |
||||
import "./modules/header"; |
||||
import "./modules/search"; |
||||
import "./modules/toggle"; |
||||
import "./modules/auth"; |
||||
import "./modules/select"; |
||||
// import "./modules/datepicker";
|
||||
import "./modules/tabs"; |
||||
import "./modules/popup"; |
||||
|
||||
@ -0,0 +1,248 @@ |
||||
// example of simple includes for js
|
||||
//=include lib/jquery.min.js
|
||||
//=include lib/owl.carousel.min.js
|
||||
//=include lib/jquery-ui.min.js
|
||||
//=include lib/datepicker-ru.js
|
||||
|
||||
// global
|
||||
var mobileWidth = 600; |
||||
|
||||
// header
|
||||
(function(){ |
||||
var header = $('.js-header'), |
||||
menu = header.find('.js-header-menu'), |
||||
wrap = header.find('.js-header-wrap'), |
||||
close = header.find('.js-header-close'), |
||||
section = header.find('.js-header-section'), |
||||
list = header.find('.js-header-list'); |
||||
|
||||
menu.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
wrap.addClass('visible'); |
||||
} |
||||
}); |
||||
|
||||
close.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
wrap.removeClass('visible'); |
||||
$(window).scrollTop(0); |
||||
} |
||||
}); |
||||
|
||||
section.on('click', function(e){ |
||||
if ($(window).width() < mobileWidth) { |
||||
e.preventDefault(); |
||||
var _this = $(this); |
||||
|
||||
_this.toggleClass('open'); |
||||
_this.next().slideToggle(); |
||||
} |
||||
}); |
||||
}()); |
||||
|
||||
// search
|
||||
(function(){ |
||||
var search = $('.js-search'), |
||||
input = search.find('.js-search-input'), |
||||
btn = search.find('.js-search-btn'); |
||||
|
||||
btn.on('click', function(e){ |
||||
if ($(window).width() >= mobileWidth) { |
||||
if (!search.hasClass('open')) { |
||||
e.preventDefault(); |
||||
} |
||||
search.addClass('open'); |
||||
setTimeout(function(){ |
||||
input.focus(); |
||||
}, 200); |
||||
} |
||||
}); |
||||
|
||||
search.on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
search.removeClass('open'); |
||||
input.val(''); |
||||
}); |
||||
}()); |
||||
|
||||
// toggle
|
||||
(function(){ |
||||
$('.js-toggle-head').on('click', function(e){ |
||||
e.preventDefault(); |
||||
var _this = $(this); |
||||
_this.toggleClass('active'); |
||||
_this.next().slideToggle(); |
||||
}); |
||||
}()); |
||||
|
||||
// auth
|
||||
(function(){ |
||||
var auth = $('.js-auth'), |
||||
type = auth.find('.js-auth-type'), |
||||
tab = auth.find('.js-auth-tab'), |
||||
login = auth.find('.js-auth-login'), |
||||
pass = auth.find('.js-auth-pass'), |
||||
goPass = auth.find('.js-auth-go-pass'), |
||||
goEnter = auth.find('.js-auth-go-enter'); |
||||
|
||||
type.on('click', function(e){ |
||||
e.preventDefault(); |
||||
var _this = $(this), |
||||
index = _this.index(); |
||||
|
||||
type.removeClass('active'); |
||||
_this.addClass('active'); |
||||
tab.hide(); |
||||
tab.eq(index).fadeIn(); |
||||
}); |
||||
|
||||
goPass.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
login.hide(); |
||||
pass.fadeIn(); |
||||
}); |
||||
|
||||
goEnter.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
pass.hide(); |
||||
login.fadeIn(); |
||||
}); |
||||
}()); |
||||
|
||||
// select
|
||||
(function(){ |
||||
var select = $('.js-select'); |
||||
if (select.length) { |
||||
select.each(function(){ |
||||
var _this = $(this), |
||||
head = _this.find('.js-select-head'), |
||||
option = _this.find('.js-select-option'), |
||||
input = _this.find('.js-select-input'); |
||||
|
||||
head.on('click', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
if (_this.hasClass('active')) { |
||||
_this.removeClass('active'); |
||||
} else { |
||||
select.removeClass('active'); |
||||
_this.addClass('active'); |
||||
} |
||||
}); |
||||
|
||||
option.on('click', function(e){ |
||||
e.preventDefault(); |
||||
_this.addClass('selected'); |
||||
|
||||
var _thisOption = $(this), |
||||
value = _thisOption.text(); |
||||
|
||||
head.text(value); |
||||
|
||||
option.removeClass('active'); |
||||
_thisOption.addClass('active'); |
||||
|
||||
input.val(value); |
||||
}); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
select.removeClass('active'); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// datepicker
|
||||
(function(){ |
||||
var datepicker = $('.js-datepicker'); |
||||
if (datepicker.length) { |
||||
$.datepicker.setDefaults( $.datepicker.regional["ru"]); |
||||
datepicker.each(function(){ |
||||
$(this).datepicker({ |
||||
dateFormat: "dd/mm/yy" |
||||
}); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// tabs
|
||||
(function(){ |
||||
var tabs = $('.js-tabs'); |
||||
if (tabs.length) { |
||||
tabs.each(function(){ |
||||
var _this = $(this), |
||||
btn = _this.find('.js-tabs-btn'), |
||||
item = _this.find('.js-tabs-item'); |
||||
|
||||
btn.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
var _thisBtn = $(this), |
||||
index = _thisBtn.index(); |
||||
|
||||
btn.removeClass('active'); |
||||
_thisBtn.addClass('active'); |
||||
item.hide(); |
||||
item.eq(index).fadeIn(); |
||||
}); |
||||
}); |
||||
} |
||||
}()); |
||||
|
||||
// popup
|
||||
(function(){ |
||||
var body = $('body'), |
||||
popup; |
||||
|
||||
$('body').on('click', '[data-popup]', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
var data = $(this).data('popup'); |
||||
popup = $(data); |
||||
showPopup(); |
||||
}); |
||||
|
||||
$('.js-popup-close').on('click', function(e){ |
||||
e.preventDefault(); |
||||
hidePopup(); |
||||
}); |
||||
|
||||
$('body').on('click', '.js-outer', function(){ |
||||
if (popup != undefined) { |
||||
hidePopup(); |
||||
} |
||||
}); |
||||
|
||||
$('.js-popup-wrap').on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).keyup(function(e){ |
||||
if (e.keyCode === 27) hidePopup(); |
||||
}); |
||||
|
||||
function showPopup(){ |
||||
body.addClass('no-scroll'); |
||||
popup.addClass('open'); |
||||
setTimeout(function(){ |
||||
popup.addClass('visible'); |
||||
}, 100); |
||||
} |
||||
|
||||
function hidePopup(){ |
||||
body.removeClass('no-scroll'); |
||||
popup.removeClass('visible'); |
||||
setTimeout(function(){ |
||||
popup.removeClass('open'); |
||||
}, 300); |
||||
} |
||||
}()); |
||||
@ -0,0 +1 @@ |
||||
export const MOBILE_WIDTH = 600; |
||||
@ -0,0 +1,241 @@ |
||||
import $ from 'jquery'; |
||||
import isEmail from 'validator/lib/isEmail'; |
||||
import isEmpty from 'validator/lib/isEmpty'; |
||||
import isLength from 'validator/lib/isLength'; |
||||
|
||||
$(document).ready(function () { |
||||
let auth = $('.js-auth'), |
||||
type = auth.find('.js-auth-type'), |
||||
tab = auth.find('.js-auth-tab'), |
||||
login = auth.find('.js-auth-login'), |
||||
pass = auth.find('.js-auth-pass'), |
||||
goPass = auth.find('.js-auth-go-pass'), |
||||
goEnter = auth.find('.js-auth-go-enter'); |
||||
|
||||
type.on('click', function (e) { |
||||
e.preventDefault(); |
||||
let _this = $(this), |
||||
index = _this.index(); |
||||
|
||||
type.removeClass('active'); |
||||
_this.addClass('active'); |
||||
tab.hide(); |
||||
tab.eq(index).fadeIn(); |
||||
}); |
||||
|
||||
goPass.on('click', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
login.hide(); |
||||
pass.fadeIn(); |
||||
}); |
||||
|
||||
goEnter.on('click', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
pass.hide(); |
||||
login.fadeIn(); |
||||
}); |
||||
|
||||
$('#password-reset__success-hide').on('click', function (e) { |
||||
e.preventDefault(); |
||||
$('#password-reset__form-wrapper').show(); |
||||
$('#password-reset__sent').hide(); |
||||
}); |
||||
|
||||
let passwordResetForm = $('#password-reset-form'); |
||||
passwordResetForm.on('submit', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
let passwordResetAllowed = true; |
||||
$('#password-reset__email-field').removeClass('error'); |
||||
$('.password-reset-form__field-error').text(''); |
||||
|
||||
const emailValue = $('#password-reset__email').val(); |
||||
if (isEmpty(emailValue)) { |
||||
$('#password-reset__email-field').addClass('error'); |
||||
$('#password-reset-field-error__email').text('Укажите почту'); |
||||
passwordResetAllowed = false; |
||||
} else if (!isEmail(emailValue)) { |
||||
$('#password-reset__email-field').addClass('error'); |
||||
$('#password-reset-field-error__email').text('Похоже, вы допустили ошибку в почте'); |
||||
passwordResetAllowed = false; |
||||
} |
||||
|
||||
if (!passwordResetAllowed) { |
||||
return; |
||||
} |
||||
|
||||
$.ajax(passwordResetForm.attr('action'), { |
||||
method: 'POST', |
||||
data: passwordResetForm.serialize(), |
||||
}) |
||||
.done(function (data) { |
||||
if (data.success === true) { |
||||
$('#password-reset__form-wrapper').hide(); |
||||
$('#password-reset__sent').show(); |
||||
} |
||||
}) |
||||
.fail(function (xhr) { |
||||
console.log('error', xhr); |
||||
if (xhr.status === 400) { |
||||
if (xhr.responseJSON.errors) { |
||||
for (let errorField in xhr.responseJSON.errors) { |
||||
if (!xhr.responseJSON.errors.hasOwnProperty(errorField)) { |
||||
continue; |
||||
} |
||||
const errorMessage = xhr.responseJSON.errors[errorField][0].message; |
||||
if (errorField === '__all__') { |
||||
$('#password-reset-field-error__all').text(errorMessage); |
||||
} else { |
||||
$(`#password-reset-field-error__${errorField}`).text(errorMessage); |
||||
$(`#password-reset__${errorField}-field`).addClass('error'); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
} |
||||
$('#learner-auth-field-error__all').text('Произошла незвестная ошибка'); |
||||
}); |
||||
}); |
||||
|
||||
let authForm = $('#learner-auth-form'); |
||||
authForm.on('submit', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
let authAllowed = true; |
||||
$('.learner-auth-form__field').removeClass('error'); |
||||
$('.learner-auth-form__field-error').text(''); |
||||
|
||||
const emailValue = $('#learner-auth-form__email').val(); |
||||
if (isEmpty(emailValue)) { |
||||
$('#learner-auth-field__email').addClass('error'); |
||||
$('#learner-auth-field-error__username').text('Укажите почту'); |
||||
authAllowed = false; |
||||
} else if (!isEmail(emailValue)) { |
||||
$('#learner-auth-field__email').addClass('error'); |
||||
$('#learner-auth-field-error__username').text('Похоже, вы допустили ошибку в почте'); |
||||
authAllowed = false; |
||||
} |
||||
|
||||
if (!isLength($('#learner-auth-form__password').val(), {min: 5, max: undefined})) { |
||||
$('#learner-auth-field__password').addClass('error'); |
||||
$('#learner-auth-field-error__password').text('Наберите ваш пароль, минимум 5 символов в длину'); |
||||
authAllowed = false; |
||||
} |
||||
|
||||
if (!authAllowed) { |
||||
return; |
||||
} |
||||
|
||||
$.ajax(authForm.attr('action'), { |
||||
method: 'POST', |
||||
data: authForm.serialize(), |
||||
}) |
||||
.done(function (data) { |
||||
if (data.success === true) { |
||||
alert("DEV - Успешный вход"); |
||||
// TODO: Куда редиректить пользователя?
|
||||
} |
||||
}) |
||||
.fail(function (xhr) { |
||||
console.log('error', xhr); |
||||
if (xhr.status === 400) { |
||||
if (xhr.responseJSON.errors) { |
||||
for (let errorField in xhr.responseJSON.errors) { |
||||
if (!xhr.responseJSON.errors.hasOwnProperty(errorField)) { |
||||
continue; |
||||
} |
||||
const errorMessage = xhr.responseJSON.errors[errorField][0].message; |
||||
if (errorField === '__all__') { |
||||
$('#learner-auth-field-error__all').text(errorMessage); |
||||
} else { |
||||
$(`#learner-auth-field-error__${errorField}`).text(errorMessage); |
||||
$(`#learner-auth-field__${errorField}`).addClass('error'); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
} |
||||
$('#learner-auth-field-error__all').text('Произошла незвестная ошибка'); |
||||
}); |
||||
}); |
||||
|
||||
let registrationForm = $('#learner-registration-form'); |
||||
registrationForm.on('submit', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
let registrationAllowed = true; |
||||
|
||||
$('.learner-registration-form__field').removeClass('error'); |
||||
$('.learner-registration-form__field-error').text(''); |
||||
|
||||
if (isEmpty($('#learner-registration-form__first-name').val())) { |
||||
$('#learner-registration-field__first-name').addClass('error'); |
||||
$('#learner-registration-field-error__first-name').text('Укажите имя'); |
||||
registrationAllowed = false; |
||||
} |
||||
if (isEmpty($('#learner-registration-form__last-name').val())) { |
||||
$('#learner-registration-field__last-name').addClass('error'); |
||||
$('#learner-registration-field-error__last-name').text('Укажите фамилию'); |
||||
registrationAllowed = false; |
||||
} |
||||
|
||||
const emailValue = $('#learner-registration-form__email').val(); |
||||
if (isEmpty(emailValue)) { |
||||
$('#learner-registration-field__email').addClass('error'); |
||||
$('#learner-registration-field-error__email').text('Укажите почту'); |
||||
registrationAllowed = false; |
||||
} else if (!isEmail(emailValue)) { |
||||
$('#learner-registration-field__email').addClass('error'); |
||||
$('#learner-registration-field-error__email').text('Похоже, вы допустили ошибку в почте'); |
||||
registrationAllowed = false; |
||||
} |
||||
|
||||
if (!isLength($('#learner-registration-form__password').val(), {min: 5, max: undefined})) { |
||||
$('#learner-registration-field__password').addClass('error'); |
||||
$('#learner-registration-field-error__password').text('Укажите пароль, минимум 5 символов в длину'); |
||||
registrationAllowed = false; |
||||
} |
||||
|
||||
if (!registrationAllowed) { |
||||
return; |
||||
} |
||||
|
||||
$.ajax(registrationForm.attr('action'), { |
||||
method: 'POST', |
||||
data: registrationForm.serialize(), |
||||
}) |
||||
.done(function (data) { |
||||
if (data.success === true) { |
||||
alert("DEV - Успешная регистрация"); |
||||
// TODO: Куда редиректить пользователя?
|
||||
} |
||||
}) |
||||
.fail(function (xhr) { |
||||
console.log('error', xhr); |
||||
if (xhr.status === 400) { |
||||
if (xhr.responseJSON.errors) { |
||||
for (let errorField in xhr.responseJSON.errors) { |
||||
if (!xhr.responseJSON.errors.hasOwnProperty(errorField)) { |
||||
continue; |
||||
} |
||||
const errorMessage = xhr.responseJSON.errors[errorField][0].message; |
||||
if (errorField === '__all__') { |
||||
$('#learner-registration-field-error__all').text(errorMessage); |
||||
} else { |
||||
$(`#learner-registration-field-error__${errorField}`).text(errorMessage); |
||||
$(`#learner-registration-field__${errorField}`).addClass('error'); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
} |
||||
|
||||
$('#learner-registration-field-error__all').text('Произошла незвестная ошибка'); |
||||
}); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,10 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
// Добавляем заголовок X-CSRFToken для всех AJAX запросов JQuery.
|
||||
$.ajaxSetup({ |
||||
headers: { |
||||
'X-CSRFToken': $('meta[name="csrf-token"]').attr('content') |
||||
} |
||||
}); |
||||
}); |
||||
@ -0,0 +1,13 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
let datepicker = $('.js-datepicker'); |
||||
if (datepicker.length) { |
||||
$.datepicker.setDefaults( $.datepicker.regional["ru"]); |
||||
datepicker.each(function(){ |
||||
$(this).datepicker({ |
||||
dateFormat: "dd/mm/yy" |
||||
}); |
||||
}); |
||||
} |
||||
}); |
||||
@ -0,0 +1,36 @@ |
||||
import $ from 'jquery'; |
||||
import {MOBILE_WIDTH} from "../constants"; |
||||
|
||||
$(document).ready(function () { |
||||
let header = $('.js-header'), |
||||
menu = header.find('.js-header-menu'), |
||||
wrap = header.find('.js-header-wrap'), |
||||
close = header.find('.js-header-close'), |
||||
section = header.find('.js-header-section'), |
||||
list = header.find('.js-header-list'); |
||||
|
||||
menu.on('click', function(e){ |
||||
if ($(window).width() < MOBILE_WIDTH) { |
||||
e.preventDefault(); |
||||
wrap.addClass('visible'); |
||||
} |
||||
}); |
||||
|
||||
close.on('click', function(e){ |
||||
if ($(window).width() < MOBILE_WIDTH) { |
||||
e.preventDefault(); |
||||
wrap.removeClass('visible'); |
||||
$(window).scrollTop(0); |
||||
} |
||||
}); |
||||
|
||||
section.on('click', function(e){ |
||||
if ($(window).width() < MOBILE_WIDTH) { |
||||
e.preventDefault(); |
||||
let _this = $(this); |
||||
|
||||
_this.toggleClass('open'); |
||||
_this.next().slideToggle(); |
||||
} |
||||
}); |
||||
}); |
||||
@ -0,0 +1,50 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
let body = $('body'), |
||||
popup; |
||||
|
||||
body.on('click', '[data-popup]', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
let data = $(this).data('popup'); |
||||
popup = $(data); |
||||
showPopup(); |
||||
}); |
||||
|
||||
$('.js-popup-close').on('click', function(e){ |
||||
e.preventDefault(); |
||||
hidePopup(); |
||||
}); |
||||
|
||||
body.on('click', '.js-outer', function(){ |
||||
if (popup !== undefined) { |
||||
hidePopup(); |
||||
} |
||||
}); |
||||
|
||||
$('.js-popup-wrap').on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).keyup(function(e){ |
||||
if (e.keyCode === 27) hidePopup(); |
||||
}); |
||||
|
||||
function showPopup(){ |
||||
body.addClass('no-scroll'); |
||||
popup.addClass('open'); |
||||
setTimeout(function(){ |
||||
popup.addClass('visible'); |
||||
}, 100); |
||||
} |
||||
|
||||
function hidePopup(){ |
||||
body.removeClass('no-scroll'); |
||||
popup.removeClass('visible'); |
||||
setTimeout(function(){ |
||||
popup.removeClass('open'); |
||||
}, 300); |
||||
} |
||||
}); |
||||
@ -0,0 +1,29 @@ |
||||
import $ from 'jquery'; |
||||
import {MOBILE_WIDTH} from "../constants"; |
||||
|
||||
$(document).ready(function () { |
||||
let search = $('.js-search'), |
||||
input = search.find('.js-search-input'), |
||||
btn = search.find('.js-search-btn'); |
||||
|
||||
btn.on('click', function(e){ |
||||
if ($(window).width() >= MOBILE_WIDTH) { |
||||
if (!search.hasClass('open')) { |
||||
e.preventDefault(); |
||||
} |
||||
search.addClass('open'); |
||||
setTimeout(function(){ |
||||
input.focus(); |
||||
}, 200); |
||||
} |
||||
}); |
||||
|
||||
search.on('click', function(e){ |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
search.removeClass('open'); |
||||
input.val(''); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,44 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
let select = $('.js-select'); |
||||
if (select.length) { |
||||
select.each(function(){ |
||||
let _this = $(this), |
||||
head = _this.find('.js-select-head'), |
||||
option = _this.find('.js-select-option'), |
||||
input = _this.find('.js-select-input'); |
||||
|
||||
head.on('click', function(e){ |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
|
||||
if (_this.hasClass('active')) { |
||||
_this.removeClass('active'); |
||||
} else { |
||||
select.removeClass('active'); |
||||
_this.addClass('active'); |
||||
} |
||||
}); |
||||
|
||||
option.on('click', function(e){ |
||||
e.preventDefault(); |
||||
_this.addClass('selected'); |
||||
|
||||
let _thisOption = $(this), |
||||
value = _thisOption.text(); |
||||
|
||||
head.text(value); |
||||
|
||||
option.removeClass('active'); |
||||
_thisOption.addClass('active'); |
||||
|
||||
input.val(value); |
||||
}); |
||||
}); |
||||
|
||||
$(document).on('click', function(){ |
||||
select.removeClass('active'); |
||||
}); |
||||
} |
||||
}); |
||||
@ -0,0 +1,24 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
let tabs = $('.js-tabs'); |
||||
if (tabs.length) { |
||||
tabs.each(function(){ |
||||
let _this = $(this), |
||||
btn = _this.find('.js-tabs-btn'), |
||||
item = _this.find('.js-tabs-item'); |
||||
|
||||
btn.on('click', function(e){ |
||||
e.preventDefault(); |
||||
|
||||
let _thisBtn = $(this), |
||||
index = _thisBtn.index(); |
||||
|
||||
btn.removeClass('active'); |
||||
_thisBtn.addClass('active'); |
||||
item.hide(); |
||||
item.eq(index).fadeIn(); |
||||
}); |
||||
}); |
||||
} |
||||
}); |
||||
@ -0,0 +1,10 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
$('.js-toggle-head').on('click', function(e){ |
||||
e.preventDefault(); |
||||
let _this = $(this); |
||||
_this.toggleClass('active'); |
||||
_this.next().slideToggle(); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,58 @@ |
||||
const webpack = require('webpack'); |
||||
const path = require('path'); |
||||
const NODE_ENV = process.env.NODE_ENV || 'development'; |
||||
|
||||
module.exports = { |
||||
entry: { |
||||
app: "./src/js/app.js" |
||||
}, |
||||
output: { |
||||
path: path.join(__dirname, "build/js"), |
||||
filename: NODE_ENV === 'development' ? '[name].js' : '[name].[id].[chunkhash].js', |
||||
library: '[name]' |
||||
}, |
||||
module: { |
||||
loaders: [ |
||||
{ |
||||
test: /\.js$/, |
||||
exclude: /(node_modules|bower_components)/, |
||||
use: { |
||||
loader: 'babel-loader', |
||||
options: { |
||||
presets: [ |
||||
["env", { |
||||
"targets": { |
||||
"browsers": ["last 2 versions", "safari >= 7"] |
||||
} |
||||
}] |
||||
] |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
plugins: [ |
||||
new webpack.DefinePlugin({ |
||||
'process.env': { |
||||
'NODE_ENV': JSON.stringify(NODE_ENV) |
||||
} |
||||
}) |
||||
], |
||||
|
||||
|
||||
watch: NODE_ENV === 'development', |
||||
|
||||
devtool: NODE_ENV === 'development' ? 'source-map' : false |
||||
}; |
||||
|
||||
if (NODE_ENV === 'production') { |
||||
module.exports.plugins.push( |
||||
new webpack.optimize.UglifyJsPlugin({ |
||||
compress: { |
||||
warnings: false, |
||||
drop_console: true, |
||||
unsafe: true |
||||
} |
||||
}) |
||||
); |
||||
} |
||||
Loading…
Reference in new issue