// jQuery
$(document).ready(function() {
// code
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
const useWindowSize = () => { | |
// IMPLEMENT | |
const [size, setSize] = useState({width: window.innerWidth, height: window.innerHeight}); | |
useEffect(() => { | |
const eventResize = () => { | |
setSize({width: window.innerWidth, height: window.innerHeight}); | |
} | |
window.addEventListener('resize', eventResize); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For accept the lazy loading to images you need just add | |
* [data-lazy-src] with a path on image. | |
*/ | |
export default (window.onload = () => { | |
const images = document.querySelectorAll('[data-lazy-src]'); | |
if ('IntersectionObserver' in window) { | |
let observer = new IntersectionObserver( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RIGHT | |
if (window.location.hash) { | |
$('html, body').animate({ | |
scrollTop: $(window.location.hash).offset().top - 50 | |
}, 500); | |
} | |
WRONG | |
// let url = location.href; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('NodeList' in window && !NodeList.prototype.forEach) { | |
console.info('polyfill for IE11'); | |
NodeList.prototype.forEach = function (callback, thisArg) { | |
thisArg = thisArg || window; | |
for (var i = 0; i < this.length; i++) { | |
callback.call(thisArg, this[i], i, this); | |
} | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.location.href.split('/')[window.location.href.split('/').length - 1] !== "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.sme-form__form').validate({ | |
rules: { | |
phone: { | |
required: true, | |
regex : /\+38\(0(50|63|66|67|68|73|91|92|93|94|95|96|97|98|99)\)-\d{3}(-\d{2})(-\d{2})/ | |
}, | |
}); | |
$.validator.addMethod( | |
"regex", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 1 | |
// console.log(value.slice(5, 7)); | |
// if(value.slice(5, 7).includes('67'||'96'||'97'||'68'||'98'||'39'||'50'||'99'||'66'||'95'||'63'||'93'||'73')) { | |
// console.log('yyyyyyyyyyyyyyyyes'); | |
// } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/_ ES6 _/ | |
const isMomHappy = true; | |
// Промис | |
const willIGetNewPhone = new Promise( | |
(resolve, reject) => { // fat arrow | |
if (isMomHappy) { | |
const phone = { | |
brand: 'Samsung', | |
color: 'black' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ES5, using Bluebird */ | |
var isMomHappy = false; | |
// Promise | |
var willIGetNewPhone = new Promise( | |
function (resolve, reject) { | |
if (isMomHappy) { | |
var phone = { | |
brand: 'Samsung', | |
color: 'black' |
NewerOlder