Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
K
kpp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Veselov
kpp
Commits
fec3d546
Commit
fec3d546
authored
Jan 06, 2019
by
Nikolay Gromov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Рефакторинг JS
parent
fe88f97d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
88 additions
and
104 deletions
+88
-104
createBlock.js
createBlock.js
+2
-1
baron.js
src/blocks/baron/baron.js
+3
-4
burger.js
src/blocks/burger/burger.js
+3
-1
field-file.js
src/blocks/field-file/field-file.js
+29
-24
field-select.js
src/blocks/field-select/field-select.js
+27
-21
field-text.js
src/blocks/field-text/field-text.js
+6
-1
main-nav.js
src/blocks/main-nav/main-nav.js
+3
-1
modal.js
src/blocks/modal/modal.js
+1
-1
object-fit-polyfill.js
src/blocks/object-fit-polyfill/object-fit-polyfill.js
+3
-4
off-canvas.js
src/blocks/off-canvas/off-canvas.js
+3
-42
scroll-link.js
src/blocks/scroll-link/scroll-link.js
+3
-1
to-top.js
src/blocks/to-top/to-top.js
+3
-1
script.js
src/js/script.js
+2
-2
No files found.
createBlock.js
View file @
fec3d546
/* 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'
)
{
...
...
src/blocks/baron/baron.js
View file @
fec3d546
/* 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'
,
...
...
src/blocks/burger/burger.js
View file @
fec3d546
/* global document */
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(){
const
ready
=
require
(
'../../js/documentReady.js'
);
ready
(
function
(){
function
$$
(
selector
,
context
)
{
context
=
context
||
document
;
...
...
src/blocks/field-file/field-file.js
View file @
fec3d546
/* global document */
const
closest
=
require
(
'closest'
);
const
ready
=
require
(
'../../js/documentReady.js'
);
/*
Форма: работа стилизованного input[type="file"]
Автор: Osvaldas Valutis, www.osvaldas.info (адаптировано под используемую разметку)
Available for use under the MIT License
*/
ready
(
function
(){
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
;
/*
Форма: работа стилизованного input[type="file"]
Автор: Osvaldas Valutis, www.osvaldas.info (адаптировано под используемую разметку)
Available for use under the MIT License
*/
input
.
addEventListener
(
'change'
,
function
(
e
)
{
var
fileName
=
''
;
if
(
this
.
files
&&
this
.
files
.
length
>
1
)
{
fileName
=
(
this
.
getAttribute
(
'data-multiple-caption'
)
||
''
).
replace
(
'{count}'
,
this
.
files
.
length
);
}
else
{
fileName
=
e
.
target
.
value
.
split
(
'
\
\'
).pop();
}
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
;
if( fileName ) {
label.innerHTML = fileName;
}
else {
label.innerHTML = labelVal;
}
input
.
addEventListener
(
'change'
,
function
(
e
)
{
var
fileName
=
''
;
if
(
this
.
files
&&
this
.
files
.
length
>
1
)
{
fileName
=
(
this
.
getAttribute
(
'data-multiple-caption'
)
||
''
).
replace
(
'{count}'
,
this
.
files
.
length
);
}
else
{
fileName
=
e
.
target
.
value
.
split
(
'
\
\'
).pop();
}
if( fileName ) {
label.innerHTML = fileName;
}
else {
label.innerHTML = labelVal;
}
});
});
});
src/blocks/field-select/field-select.js
View file @
fec3d546
if
(
typeof
Object
.
assign
!=
'function'
)
{
Object
.
assign
=
function
(
target
)
{
'use strict'
;
if
(
target
==
null
)
{
throw
new
TypeError
(
'Cannot convert undefined or null to object'
);
}
const
ready
=
require
(
'../../js/documentReady.js'
);
target
=
Object
(
target
);
for
(
var
index
=
1
;
index
<
arguments
.
length
;
index
++
)
{
var
source
=
arguments
[
index
];
if
(
source
!=
null
)
{
for
(
var
key
in
source
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
source
,
key
))
{
target
[
key
]
=
source
[
key
];
ready
(
function
(){
if
(
typeof
Object
.
assign
!=
'function'
)
{
Object
.
assign
=
function
(
target
)
{
'use strict'
;
if
(
target
==
null
)
{
throw
new
TypeError
(
'Cannot convert undefined or null to object'
);
}
target
=
Object
(
target
);
for
(
var
index
=
1
;
index
<
arguments
.
length
;
index
++
)
{
var
source
=
arguments
[
index
];
if
(
source
!=
null
)
{
for
(
var
key
in
source
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
source
,
key
))
{
target
[
key
]
=
source
[
key
];
}
}
}
}
}
return
target
;
};
}
return
target
;
};
}
const
Choices
=
require
(
'choices.js'
);
const
Choices
=
require
(
'choices.js'
);
new
Choices
(
'.field-select__select'
,
{
searchEnabled
:
false
,
placeholderValue
:
'Выберите'
,
});
new
Choices
(
'.field-select__select'
,
{
searchEnabled
:
false
,
placeholderValue
:
'Выберите'
,
});
src/blocks/field-text/field-text.js
View file @
fec3d546
/* global document */
const
autosize
=
require
(
'autosize'
);
const
ready
=
require
(
'../../js/documentReady.js'
);
autosize
(
document
.
querySelectorAll
(
'textarea'
));
ready
(
function
(){
autosize
(
document
.
querySelectorAll
(
'textarea'
));
});
src/blocks/main-nav/main-nav.js
View file @
fec3d546
/* global document Element */
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(){
const
ready
=
require
(
'../../js/documentReady.js'
);
ready
(
function
(){
// Добавление/удаление модификаторов при фокусировке на ссылочном элементе
var
linkClassName
=
'main-nav__link'
;
...
...
src/blocks/modal/modal.js
View file @
fec3d546
/* global document window console */
var
$
=
require
(
'jquery'
);
const
$
=
require
(
'jquery'
);
// Демо событий модальных окон
$
(
document
).
ready
(
function
(){
...
...
src/blocks/object-fit-polyfill/object-fit-polyfill.js
View file @
fec3d546
/* 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
();
});
src/blocks/off-canvas/off-canvas.js
View file @
fec3d546
/* 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'
);
}
...
...
src/blocks/scroll-link/scroll-link.js
View file @
fec3d546
/* 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
++
)
{
...
...
src/blocks/to-top/to-top.js
View file @
fec3d546
/* global document window performance requestAnimationFrame */
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(){
const
ready
=
require
(
'../../js/documentReady.js'
);
ready
(
function
(){
if
(
document
.
getElementById
(
'to-top'
))
{
...
...
src/js/script.js
View file @
fec3d546
//
var
ready = require('./documentReady.js');
//
const
ready = require('./documentReady.js');
// ready(function(){
// console.log('DOM героически построен!');
// });
//
var
$ = require('jquery');
//
const
$ = require('jquery');
// $( document ).ready(function() {});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment