Skip to content

Instantly share code, notes, and snippets.

View englishextra's full-sized avatar
💜
the beat goes on

englishextra englishextra

💜
the beat goes on
View GitHub Profile
@englishextra
englishextra / rebuild_masonry_after_disqus_ready.js
Last active April 24, 2016 19:03
Rebuild Masonry / Packery after Disqus is ready
evento.add(window, "load", function () {
var w = window,
d = document,
disqus_thread = d.getElementById("disqus_thread") || "",
disqus_shortname = disqus_thread ? (disqus_thread.dataset.shortname || "") : "",
embed_js_src = ("https:" == w.location.protocol ? "https" : "http") + "://" + disqus_shortname + ".disqus.com/embed.js",
g = ".grid",
h = ".grid-item",
k = ".grid-sizer",
grid = d.querySelector(g) || "",
@englishextra
englishextra / externalcounters-clicks.js
Last active May 3, 2016 09:27
track clicks on external links
/*!
* externalcounters-clicks.js
* track clicks on external links
* gist.github.com/englishextra/b1e2dec7ab9b5d5af28a02c7257b17e6
*/
"undefined" !== typeof window.jQuery && $(function () {
$(document).on("click", ".superbox-current-desc a", function (e) {
e.preventDefault();
e.stopPropagation();
var w = window,
@englishextra
englishextra / hyphenator.js
Created May 3, 2016 16:58
modified github.com/ykyuen/hyphenator.js/blob/master/Hyphenator.js
/*!
* modified github.com/ykyuen/hyphenator.js/blob/master/Hyphenator.js
* only English and Russian support
* some functions and checks are cut off
* usage <p class="hyphenate text" lang="ru"> <p class="hyphenate text" lang="en">
* dont minify with JSMin
* minify with closure-compiler.appspot.com/home and then remove new lines
*/
var Hyphenator = function (e) {
var p = {
@englishextra
englishextra / getChildrenByTags.js
Last active May 5, 2016 13:49
get children of a parent element by tag names
/*!
* get children of a parent element by tag nameS
* gist.github.com/englishextra/d4789c5d30f6f6b429fdf7aaebeda7b1
* based on quirksmode.org/dom/getElementsByTagNames.html
* takes two arguments:
* A string with a comma-separated list of tag names.
* An optional start element, otherwise document is used.
* var element = document.getElementById('test');
* var formFieldList = getElementsByTagNames('input,select,textarea',element);
*/
<?xml version="1.0" encoding="Windows-1252" ?>
<!--// HelpingHand Notepad++ XML Theme
Copyright (c) 2016 Seguei Shimansky <http://shimansky.biz/>
gist.github.com/englishextra/1132a0a940768984cd4735837a22aba2
//-->
<NotepadPlus>
<LexerStyles>
<LexerType name="xml" desc="XML" ext="">
<WordsStyle name="XMLSTART" styleID="12" fgColor="000000" bgColor="F1F1F1" fontName="" fontStyle="0" fontSize="10" />
<WordsStyle name="XMLEND" styleID="13" fgColor="000000" bgColor="F1F1F1" fontName="" fontStyle="0" fontSize="10" />
@englishextra
englishextra / querySelector.polyfill.js
Created May 6, 2016 18:53 — forked from chrisjlee/querySelector.polyfill.js
IE document.querySelector() polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);
@englishextra
englishextra / delegate.js
Created May 6, 2016 18:58 — forked from cvan/delegate.js
simple querySelectorAll wrapper + event delegation
function $(sel) {
if (!sel) {
return document.body;
}
var r = document.querySelectorAll(sel);
return r.length == 1 ? r[0] : Array.prototype.slice.call(r);
}
$.matches = function(el, sel) {
var matchesSelector = el.webkitMatchesSelector || el.mozMatchesSelector ||
@englishextra
englishextra / getChildrenByTag.js
Last active May 7, 2016 14:10
get children of a parent element by tag name
/*!
* get children of a parent element by tag name
* no fallback to document if parent fail
* gist.github.com/englishextra/6d843e16c49cfde0a394bd9d76383b13
* jsfiddle.net/englishextra/c2vr5gxd/
* jsbin.com/xavocu/edit?html,js,output
*/
getChildrenByTag = (function (d, m) {
function g(t, p, o) {
o = Object.create(g.fn);
@englishextra
englishextra / FadeIn.js
Created May 9, 2016 15:38
FadeIn in pure JS
/*!
* Fade In
* gist.github.com/englishextra/cbf5137a95ed5e02927cd3e19e271bae
* youmightnotneedjquery.com
* fadeIn(el);
* fadeIn(el, "inline-block");
*/
function fadeIn(el){el.style.opacity=0;var last=+new Date();var tick=function(){el.style.opacity=+el.style.opacity+(new Date()-last)/400;last=+new Date();if(+el.style.opacity<1){(window.requestAnimationFrame&&requestAnimationFrame(tick))||setTimeout(tick,160);}};tick();}
@englishextra
englishextra / FadeOut.js
Last active May 9, 2016 15:44
FadeOut in pure JS
/*!
* Fade Out
* gist.github.com/englishextra/818ba5b558f9c15f9776684b8e8feaf9
* youmightnotneedjquery.com
* chrisbuttery.com/articles/fade-in-fade-out-with-javascript/
* fadeOut(el);
*/
function fadeOut(el){el.style.opacity=1;(function fade(){if((el.style.opacity-=.1)<0){el.style.display="none";}else{requestAnimationFrame(fade);}})();}