Skip to content

Instantly share code, notes, and snippets.

@njif
njif / addEvent-closure-singleton-lazyloading.js
Last active August 29, 2015 14:07
Cross-browser event listener. This technique makes use of 3 patterns: closure + singleton + lazy loading
// http://javascriptrules.com/2009/07/22/cross-browser-event-listener-with-design-patterns/
var addEvent = (function () {
var setListener;
return function (el, ev, fn) {
if (!setListener) {
if (el.addEventListener) {
setListener = function (el, ev, fn) {
el.addEventListener(ev, fn, false);
};
@njif
njif / bind.js
Last active August 29, 2015 14:07
Cross-browser bind
// Try this: https://github.com/es-shims/es5-shim
Function.prototype.bind = (function() {
if (Function.prototype.bind)
return Function.prototype.bind;
function bind(context) {
var func = this;
var bindArgs = Array.prototype.slice.call(arguments, 1);
function wrapper() {
var args = Array.prototype.slice.call(arguments);
@njif
njif / inherit-class.js
Created October 14, 2014 09:23
Inherit class
function InheritClass(Base, Child, Context) {
if (!Base || !Child)
return;
Base.apply(Context, Array.prototype.slice.call(arguments, 3));
var MemberValue;
for (var MemberName in Base.prototype) {
MemberValue = Base.prototype[MemberName];
if (!Child.prototype[MemberName])
@njif
njif / responsive-slider.html
Last active August 29, 2015 14:07
responsive jquery slider
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
ul {
padding: 0;
margin: 0;
@njif
njif / jquery-slider.html
Last active August 29, 2015 14:07
jquery slider
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.slider {
position: relative;
display: inline-block; /*.inlineblock; mixin */
@njif
njif / image-align.html
Last active August 29, 2015 14:07
Image align
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image align</title>
<style>
.image__wrapper {
position: relative;
width:500px;
height:300px;
@njif
njif / exception.js
Created October 3, 2014 06:52
exception.js
// handlebars/exception.js
var __module5__ = (function() {
"use strict";
var __exports__;
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
function Exception(message, node) {
var line;
if (node && node.firstLine) {
@njif
njif / README.md
Last active August 29, 2015 14:07 — forked from addyosmani/README.md

CSS Layout Debbuger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@njif
njif / I-love-blur
Created September 22, 2014 10:48
This is a text blur demo with CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>I ♥ BLUR</title>
<style>
html { height: 100%; }
body {
display: flex;