Skip to content

Instantly share code, notes, and snippets.

View hkfoster's full-sized avatar

H. Kyle Foster hkfoster

  • Richmond, Virginia
View GitHub Profile
@hkfoster
hkfoster / unhover.js
Last active January 2, 2016 22:59
Disable hover events on scroll.
/**
* Disable hover events on scroll
* @see http://www.thecssninja.com/javascript/pointer-events-60fps
*/
var root = document.documentElement, timer;
window.addEventListener( 'scroll', function() {
clearTimeout( timer );
@hkfoster
hkfoster / smarten.js
Created January 11, 2014 16:41
Replace dumb quotes with smart quotes, double dashes with an em dash, and three dots with an ellipsis.
// Make punctuation smarter
jQuery.fn.smarten = (function() {
function smartenNode(node) {
if (node.nodeType === 3) {
node.data = node.data
.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // Opening singles
.replace(/'/g, "\u2019") // Closing singles & apostrophes
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c") // Opening doubles
.replace(/"/g, "\u201d") // Closing doubles
{
"bold_folder_labels": true,
"color_scheme": "Packages/Theme - Flatland/Flatland Monokai.tmTheme",
"flatland_sidebar_tree_large": true,
"flatland_square_tabs": true,
"font_size": 15,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
@hkfoster
hkfoster / nodemaker.js
Last active August 29, 2015 14:02
Native JS Node Maker Function
/**
* Node Maker Function
* @author Kyle Foster
*/
var makeNode = function( parent, content ) {
var node = document.createElement( parent );
if ( content ) node.innerHTML = content;
return node;
};
@hkfoster
hkfoster / nodefromstring.js
Last active August 29, 2015 14:02
Native JS Node From String Function
/**
* Node From String Function
* @author Kyle Foster
* @license MIT (http://www.opensource.org/licenses/mit-license.php/)
*/
var nodeFromString = function( string ) {
var match = /^<([a-z]+)/g.exec( string ),
tag = match[ 1 ],
wrapper = 'div',
outliers = {
@hkfoster
hkfoster / fancysands.js
Last active May 15, 2019 11:56
Wrap ampersands with <span class="amp"></span> for styling
/**
* Fancysands v0.0.1
* Wrap ampersands with <span class="amp"></span> for styling
* @author Kyle Foster (@hkfoster)
* @license MIT (http://www.opensource.org/licenses/mit-license.php/)
*/
( function( window ) {
'use strict';
@hkfoster
hkfoster / wrapnodes.js
Created March 17, 2015 20:36
Native JS node-wrapping function
function wrapNodes( nodes, type ) {
for ( var index = 0; index < nodes.length; index++ ) {
var node = nodes[ index ],
wrapper = document.createElement( type );
node.parentNode.insertBefore( wrapper, node );
wrapper.appendChild( node );
}
}
@hkfoster
hkfoster / validation.js
Last active May 2, 2017 00:08
Native JS HTML5 form validation.
/**
* HTML5 Form Validation 0.0.1
* @author Kyle Foster (@hkfoster)
* @license MIT (http://www.opensource.org/licenses/mit-license.php/)
*/
var formValidation = ( function() {
var init = function() {
@hkfoster
hkfoster / spectral.js
Last active November 13, 2015 20:16
A full-text search engine for Ghost based on lunr.js
/**
* Spectral.js 0.0.6
* Full-text search for the Ghost blogging platform
* @author Kyle Foster (@hkfoster)
* @license MIT (http://www.opensource.org/licenses/mit-license.php/)
*/
// Lunr 0.6.0 | lunrjs.com | by Oliver Nightingale | @license MIT
!function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.6.0",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.utils.asString=function(t){return void 0===t||null===t?"":t.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].spli
@hkfoster
hkfoster / lightbox.js
Last active August 29, 2015 14:22
A Simple Lightbox Trigger
/**
* Lightbox.js 0.0.1
* @author Kyle Foster (@hkfoster)
* @license MIT (http://www.opensource.org/licenses/mit-license.php/)
*/
var lightBoxInit = ( function() {
var triggers = document.querySelectorAll( '[rel="modal"]' );