Skip to content

Instantly share code, notes, and snippets.

View kudinovfedor's full-sized avatar

Fedir Kudinov kudinovfedor

View GitHub Profile
@kudinovfedor
kudinovfedor / vh100.js
Created November 6, 2019 15:46
Viewport Height 100 percent
/**
* Viewport Height 100 percent
*
* @param {string} element
* @returns {void}
*/
const vh100 = (element) => {
const w = $(window);
const el = $(element);
tabs('.fk-tabs', '.fk-tabs-list', '.fk-tab-item');
/**
* Tabs
*
* @example
* tabs('.tabs', '.tabs-list', '.tab-item');
* @param {(string|Object)} container - main container for tabs
* @param {(string|Object)} list - ul list for each tab item
* @param {(string|Object)} item - tab block for each li item
@kudinovfedor
kudinovfedor / get-url-params.js
Created April 10, 2019 07:21
Get string with URL parameters for using when Ajax post request ('Content-Type', 'application/x-www-form-urlencoded')
/**
* Get URL Params
*
* @description String with URL parameters for using when Ajax post request
*
* @example
* getUrlParams({prop1: value1, prop2: value2});
*
* @param {Object} object - object with properties and values
* @returns {string|null}
@kudinovfedor
kudinovfedor / cookie.js
Created April 10, 2019 07:12
An object with methods for working with javascript cookies
<!-- Let's load this in-viewport image normally -->
<img src="hero.jpg" alt=".."/>
<!-- Let's lazy-load the rest of these images -->
<img data-src="unicorn.jpg" loading="lazy" alt=".." class="lazyload"/>
<img data-src="cats.jpg" loading="lazy" alt=".." class="lazyload"/>
<img data-src="dogs.jpg" loading="lazy" alt=".." class="lazyload"/>
<script>
(async () => {
@kudinovfedor
kudinovfedor / check-js-enebled.js
Created April 7, 2019 19:44
Replace class no-js to js on html element (check if javascript is enabled)
((html) => {
html.className = html.className.replace(/\bno-js\b/, 'js');
})(document.documentElement);
@kudinovfedor
kudinovfedor / selector-all.js
Last active May 18, 2020 06:19
Returns all element descendants of node that match selectors
/**
* Selector All
*
* @description
* Returns all element descendants of node that match selectors.
*
* @example
* selectorAll('div');
* selectorAll('div', document);
*
@kudinovfedor
kudinovfedor / selector.js
Created April 7, 2019 19:36
Returns the first element that is a descendant of node that matches selectors.
/**
* Selector
*
* @description
* Returns the first element that is a descendant of node that matches selectors.
*
* @example
* selector('div');
* selector('div', document);
*
@kudinovfedor
kudinovfedor / get-date-range.js
Created April 7, 2019 19:32
Get date range depending on the set number of days
/**
* Get date range
*
* @example
* getDateRange(30);
*
* @param {number} [days=1] - Number of days
* @returns {{start: string, end: string}}
*/
const getDateRange = (days = 1) => {
@kudinovfedor
kudinovfedor / copy-to-clipboard.js
Created April 7, 2019 19:02
Copy string to clipboard (buffer)
/**
* Copy string to the clipboard
*
* @example
* copy('random string');
*
* @param {string} string
* @returns {void}
*/
const copy = (string) => {