Skip to content

Instantly share code, notes, and snippets.

View jasonbellamy's full-sized avatar

Jason Bellamy jasonbellamy

View GitHub Profile
/**
* @name EventViewFactory
* @constructor
*/
var EventViewFactory = function() {
return {
/**
* @name create
@jasonbellamy
jasonbellamy / featuretest.js
Created November 7, 2012 19:35
Simple JavaScript feature detection.
var testFeature = (function () {
return {
/**
* Accepts a feature name and feature test function to test for truthness
* @param {String} featureName of the feature being tested
* @param {Function} testMethod the feature test method ( this should always return true or false )
*/
addTest: function( featureName, testMethod ) {
@jasonbellamy
jasonbellamy / timed_event_manager.js
Created November 13, 2012 16:12
Simple timed event manager
/**
* Handles set up / clean up of multiple named event timers
* @constructor
*/
var TimedEventManager = function () {
this.timers = {};
};
TimedEventManager.prototype = {
.element-to-clearfix
*zoom: 1
&:before,
&:after
content: ''
display: table
&:after
clear: both
@jasonbellamy
jasonbellamy / disable-hover
Created August 18, 2014 13:34
Disable hover on scroll
// Used to track the enabling of hover effects
var enableTimer = 0;
/*
* Listen for a scroll and use that to remove
* the possibility of hover effects
*/
window.addEventListener('scroll', function() {
clearTimeout(enableTimer);
removeHoverClass();
@jasonbellamy
jasonbellamy / variadic.js
Created December 2, 2014 16:07
Basic implmentation of a variadic helper function/
var variadic = function( fn ) {
var _slice = Array.prototype.slice;
var _length = fn.length;
if ( _length < 1 ) {
return fn;
}
if( _length === 1 ) {
return function () {
@jasonbellamy
jasonbellamy / modal-with-outline-overlay.css
Created February 26, 2015 22:52
Modal overlay created using CSS outline property.
.modal {
background: black;
color: rgb(255, 255, 255);
height: 200px;
left: 50%;
position: relative;
text-align: center;
top: 50%;
transform: translate(-50%, 50%);
width: 200px;
@jasonbellamy
jasonbellamy / index.html
Last active August 29, 2015 14:16
Modal overlay created using CSS fixed positioning.
<div class="modal">
<div class="modal-content">
modal content
</div>
<div class="modal-overlay"></div>
</div>
@jasonbellamy
jasonbellamy / index.html
Last active August 29, 2015 14:16
Modal overlay created using CSS box-shadow.
<div class="modal">
modal content
</div>
@jasonbellamy
jasonbellamy / nfe.js
Created May 21, 2015 15:12
Named function expressions
/**
* When working with Named function expressions which one of the following is preffered and why?
*/
/* Use the same name for the function and the variable its assigned to.*/
var foo = function foo() {
return foo;
}
/* Use a different name for the function and the variable its assigned to. */