Skip to content

Instantly share code, notes, and snippets.

@cuth
cuth / Timer.js
Last active December 18, 2015 05:19
Add this to any class to add timeout capabilities.
(function (exports, $) {
"use strict";
exports.Timer = function (opts) {
var defaults = {
delay: 5000,
start: null
};
this.opts = $.extend(defaults, opts);
this.timeout = null;
this.onHold = false;
@cuth
cuth / EventHandler.js
Last active December 18, 2015 05:19
Add this event handler to any class to give you the ability to trigger and bind events.
(function (exports) {
"use strict";
exports.EventHandler = function () {
this.collection = {};
};
exports.EventHandler.prototype.bind = function (events, callback) {
var names = events.split(" "),
x, xlen = names.length;
for (x = 0; x < xlen; x += 1) {
if (typeof this.collection[names[x]] !== 'object') {