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
const names = [ 'Jon', 'Jacob', 'Jeff' ] | |
const copy1 = names.slice() | |
const copy2 = [].concat(names) | |
const copy3 = Object.values(names) | |
const copy4 = [...names] | |
const copy5 = Array.of(...names) | |
const copy6 = JSON.parse(JSON.stringify(names)) | |
const copy7 = names.map(i => i) | |
const copy8 = Object.assign([], names) |
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
function doPrevent(e) { | |
e.preventDefault(); | |
} | |
// Prevent events | |
$(window).on('scroll mousewheel DOMMouseScroll', doPrevent); | |
$(window).on('mousemove', function (e) { | |
// Revert | |
$(window).off('scroll mousewheel DOMMouseScroll', doPrevent); |
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
/* | |
* Usage | |
* | |
$(function () { | |
$(".todayMenu article").removeOrphans(); | |
}); | |
*/ |
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 ('objectFit' in document.documentElement.style === false) { | |
var imgToFit = document.querySelectorAll('img.object-fit'); | |
for (var i = 0; i < imgToFit.length; i++) { | |
var container = imgToFit[i].parentElement; | |
var imgToFitUrl = imgToFit[i].src; | |
if (imgToFitUrl) { | |
container.classList.add('no-object-fit'); | |
container.style.backgroundImage = 'url(' + imgToFitUrl + ')'; |
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
// --------------------------------------------------------- | |
// USER OS & BROWSER | |
// --------------------------------------------------------- | |
var userEnvironment = (function(){ | |
var userOS = ""; | |
var userBrowser = ""; | |
var mobile = { | |
deviceOrientation: function(){ |
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
// Resource https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c | |
var scrollValInit = 200; | |
var didScroll; | |
$(window).scroll(function () { | |
didScroll = true; | |
}); | |
setInterval(function () { |
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
var keys = {}; | |
$(document).keydown(function (e) { | |
keys[e.which] = true; | |
showThemeSelector(e); | |
}); | |
$(document).keyup(function (e) { | |
delete keys[e.which]; |
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
function loadScript(url, callback) { | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
// Then bind the event to the callback function. | |
// There are several events for cross browser compatibility. | |
script.onreadystatechange = callback; | |
script.onload = callback; |
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
// Uniwersal hider | |
// ============================================================ | |
function hider(targetToHide, trigger) { | |
$(document).on('mouseup', function (e) { | |
if (!targetToHide.is(e.target) // if the target of the click isn't the container... | |
&& targetToHide.has(e.target).length === 0 // ... nor a descendant of the container | |
&& !trigger.is(e.target)) // ... nor a trigger of the container | |
{ | |
console.log(targetToHide); | |
targetToHide.add(trigger).removeClass('active'); |
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
// jak przygotowac metode: http://jsfiddle.net/rafx/rtmtkqto/ | |
// http://stackoverflow.com/questions/3502468/unbind-remove-kill-a-jquery-plugin | |
// przyklad na pluginie Stellar: | |
// http://stackoverflow.com/questions/12236631/can-stellar-js-readjust-element-offsets-on-window-resize | |
$(window).data('plugin_stellar').destroy(); | |
$(window).data('plugin_stellar').init(); |
NewerOlder