Commit fec3d546 authored by Nikolay Gromov's avatar Nikolay Gromov

Рефакторинг JS

parent fe88f97d
/* eslint-disable */
'use strict';
// Генератор файлов блока
......@@ -39,7 +40,7 @@ if (blockName) {
}
else if (extension === 'js') {
fileContent = `// document.addEventListener(\'DOMContentLoaded\', function(){});\n// (function(){\n// код\n// }());\n`;
fileContent = `/* global document */\n\n// const ready = require('../../js/documentReady.js');\n\n// ready(function(){\n// \n// });\n`;
}
else if (extension === 'md') {
......
/* global document */
const ready = require('../../js/documentReady.js');
const baron = require('baron');
var baron = require('baron');
document.addEventListener('DOMContentLoaded', function(){
ready(function(){
baron({
root: '#baron-demo',
......
/* global document */
document.addEventListener('DOMContentLoaded', function(){
const ready = require('../../js/documentReady.js');
ready(function(){
function $$(selector, context) {
context = context || document;
......
/* global document */
const closest = require('closest');
const ready = require('../../js/documentReady.js');
/*
ready(function(){
/*
Форма: работа стилизованного input[type="file"]
Автор: Osvaldas Valutis, www.osvaldas.info (адаптировано под используемую разметку)
Available for use under the MIT License
*/
*/
var inputs = document.querySelectorAll( '.field-file__input:not([disabled])' );
Array.prototype.forEach.call( inputs, function( input )
{
var inputs = document.querySelectorAll( '.field-file__input:not([disabled])' );
Array.prototype.forEach.call( inputs, function( input )
{
var label = closest(input, '.field-file').querySelector( '.field-file__name-text' ),
labelVal = label.innerHTML;
......@@ -30,4 +33,6 @@ Array.prototype.forEach.call( inputs, function( input )
label.innerHTML = labelVal;
}
});
});
});
if (typeof Object.assign != 'function') {
const ready = require('../../js/documentReady.js');
ready(function(){
if (typeof Object.assign != 'function') {
Object.assign = function(target) {
'use strict';
if (target == null) {
......@@ -18,11 +22,13 @@ if (typeof Object.assign != 'function') {
}
return target;
};
}
}
const Choices = require('choices.js');
const Choices = require('choices.js');
new Choices('.field-select__select', {
new Choices('.field-select__select', {
searchEnabled: false,
placeholderValue: 'Выберите',
});
});
/* global document */
const autosize = require('autosize');
const ready = require('../../js/documentReady.js');
autosize(document.querySelectorAll('textarea'));
ready(function(){
autosize(document.querySelectorAll('textarea'));
});
/* global document Element */
document.addEventListener('DOMContentLoaded', function(){
const ready = require('../../js/documentReady.js');
ready(function(){
// Добавление/удаление модификаторов при фокусировке на ссылочном элементе
var linkClassName = 'main-nav__link';
......
/* global document window console */
var $ = require('jquery');
const $ = require('jquery');
// Демо событий модальных окон
$(document).ready(function(){
......
/* global document */
const objectFitImages = require('object-fit-images');
const ready = require('../../js/documentReady.js');
var objectFitImages = require('object-fit-images');
document.addEventListener('DOMContentLoaded', function(){
ready(function(){
objectFitImages();
});
/* global document */
document.addEventListener('DOMContentLoaded', function(){
const ready = require('../../js/documentReady.js');
ready(function(){
document.addEventListener('click', function(event) {
if(event.target.dataset.toggle === 'off-canvas') {
......@@ -13,47 +15,6 @@ document.addEventListener('DOMContentLoaded', function(){
}
});
// реакция на свайп
// document.addEventListener('touchstart', handleTouchStart, false);
// document.addEventListener('touchmove', handleTouchMove, false);
// var xDown = null;
// var yDown = null;
// function handleTouchStart(evt) {
// xDown = evt.touches[0].clientX;
// yDown = evt.touches[0].clientY;
// };
// function handleTouchMove(evt) {
// if ( ! xDown || ! yDown ) {
// return;
// }
// var xUp = evt.touches[0].clientX;
// var yUp = evt.touches[0].clientY;
// var xDiff = xDown - xUp;
// var yDiff = yDown - yUp;
// if(Math.abs( xDiff )+Math.abs( yDiff )>100){ //to deal with to short swipes
// if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
// if ( xDiff > 0 ) {/* left swipe */
// document.getElementById('off-canvas').classList.remove('off-canvas--open');
// } else {/* right swipe */
// document.getElementById('off-canvas').classList.add('off-canvas--open');
// }
// }
// // else {
// // if ( yDiff > 0 ) {/* up swipe */
// // alert('Up!');
// // } else { /* down swipe */
// // alert('Down!');
// // }
// // }
// /* reset values */
// xDown = null;
// yDown = null;
// }
// };
function offCanvasToggle() {
document.getElementById('off-canvas').classList.toggle('off-canvas--open');
}
......
/* global document window performance requestAnimationFrame */
document.addEventListener('DOMContentLoaded', function(){
const ready = require('../../js/documentReady.js');
ready(function(){
var links = document.querySelectorAll('[href^="#"][data-scroll-link]');
for (var i = 0; i < links.length; i++) {
......
/* global document window performance requestAnimationFrame */
document.addEventListener('DOMContentLoaded', function(){
const ready = require('../../js/documentReady.js');
ready(function(){
if(document.getElementById('to-top')) {
......
// var ready = require('./documentReady.js');
// const ready = require('./documentReady.js');
// ready(function(){
// console.log('DOM героически построен!');
// });
// var $ = require('jquery');
// const $ = require('jquery');
// $( document ).ready(function() {});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment