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 foo() { | |
return 'Hi from foo!'; | |
} | |
export default foo; | |
// or | |
// export default function foo() { | |
// return 'Hi from foo!'; | |
// } |
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 inFullScreen = document.fullscreenEnabled || document.fullscreenElement || | |
window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled; | |
if (inFullScreen) { | |
//do something.. | |
if (document.exitFullscreen) { | |
document.exitFullscreen(); | |
} else if (document.mozCancelFullScreen) { | |
document.mozCancelFullScreen(); | |
} else if (document.webkitExitFullscreen) { | |
document.webkitExitFullscreen(); |
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 fitElement = function fitElement(elementSelector, elementAspect) { | |
var element = (typeof elementSelector === 'string' || elementSelector instanceof String) ? document.querySelector(elementSelector) : elementSelector, | |
parW = element.parentNode.clientWidth, | |
parH = element.parentNode.clientHeight, | |
parAsp = parW / parH, | |
aspect = elementAspect || 16 / 9, | |
elW, elH; | |
if (aspect > parAsp) { | |
elW = parW; | |
elH = elW / aspect; |
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 excerpt($limit) { | |
$excerpt = explode(' ', get_the_excerpt(), $limit); | |
if (count($excerpt)>=$limit) { | |
array_pop($excerpt); | |
$excerpt = implode(" ",$excerpt).'...'; | |
} else { | |
$excerpt = implode(" ",$excerpt); | |
} | |
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); |
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 BrowserInfo() { | |
this.supported = false; | |
this.isBrowser = true; | |
this.webBrowser = null; | |
this.webBrowserVer = null; | |
this.os = 'unknown os'; | |
var detectedUA = null; | |
if (typeof window === 'undefined' || !window.navigator) { |
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
/** | |
* remove - removes DOM elements | |
* working with: usual dom element, selector, jQuery object, Polymer object | |
* @param {string | object} selectorOrObject - dom object | |
*/ | |
function remove(selectorOrObject) { | |
if (!selectorOrObject) { | |
return; | |
} |
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
//source: http://stackoverflow.com/questions/4508574/remove-hash-from-url | |
//Best is Homero Barbosa's answer below: | |
history.pushState('', document.title, window.location.pathname); | |
//... or, if you want to maintain the search parameters: | |
history.pushState('', document.title, window.location.pathname + window.location.search); | |
//Old, do not use, badwrongfun: | |
// var loc = window.location.href, | |
// index = loc.indexOf('#'); | |
// if (index > 0) { |
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
//https://developer.mozilla.org/en-US/docs/Web/Events/resize | |
; | |
(function() { | |
var throttle = function(type, name, obj_) { | |
var obj = obj_ || window; | |
var running = false; | |
var func = function() { | |
if (running) { | |
return; | |
} |
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
//Setup | |
let el = document.getElementById('thingy'); | |
let elChild = document.createElement('div'); | |
elChild.innerHTML = 'Content'; | |
//Append | |
el.appendChild(elChild); | |
//Prepend | |
el.insertBefore(elChild, el.firstChild); |
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 (window) { | |
document.addEventListener("DOMContentLoaded", function (e) { | |
var supports = { | |
srcset: false, | |
currentSrc: false, | |
sizes: false, | |
picture: false | |
}; | |
var img = new Image(); |