Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / dabblet.css
Created August 27, 2012 18:25
no-js lightbox
/**
* no-js lightbox
*/
body {
margin: 100px 0 0 100px;
}
.thumbs li {
position: relative;
float: left;
margin: 20px 20px 0 0;
@james2doyle
james2doyle / dabblet.css
Created August 28, 2012 16:27
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
@james2doyle
james2doyle / jQuery Placeholder Fallback
Created August 28, 2012 16:35
jQuery Placeholder Fallback
$(document).ready(function() {
if ( !("placeholder" in document.createElement("input")) ) {
$("input[placeholder]").each(function() {
var val = $(this).attr("placeholder");
if ( this.value == "" ) {
this.value = val;
}
$(this).focus(function() {
if ( this.value == val ) {
@james2doyle
james2doyle / replaceAll
Created August 30, 2012 01:52
replaceAll
String.prototype.replaceAll = function(str1, str2, ignore) {
return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof(str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);
}
@james2doyle
james2doyle / dabblet.css
Created September 1, 2012 05:56
no-js image preview
/**
* no-js image preview
*/
#no-js-g > * {
box-sizing: border-box;
}
#no-js-g ul {
margin: 0;
@james2doyle
james2doyle / Navigation Timing
Created September 1, 2012 16:52
Navigation Timing
function supportsNavigationTiming() {
return !!(window.performance && window.performance.timing);
}
var navigation = window.performance.navigation;
var navType = navigation.type;
var redirectCount = navigation.redirectCount;
window.addEventListener("load", function() {
setTimeout(function() {
@james2doyle
james2doyle / dabblet.css
Created September 5, 2012 00:46
event widget
/**
* event widget
* url: http://dribbble.com/shots/713807-Extended
*/
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
* {
box-sizing: border-box;
}
@james2doyle
james2doyle / Nodelist each
Created September 6, 2012 16:56
Nodelist object prototype for each function
Object.prototype.each = function(callback) {
var a = [];
for (var i = 0; i < this.length; i++) {
a[i] = this[i];
callback(a[i]);
}
}
@james2doyle
james2doyle / Prototypes
Created September 6, 2012 18:20
Prototypes
Object.prototype.each = function(callback) {
var a = [];
for (var i = 0; i < this.length; i++) {
a[i] = this[i];
callback(a[i]);
}
}
String.prototype.replaceAll = function(str1, str2, ignore) {
return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof(str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);
@james2doyle
james2doyle / dabblet.css
Created September 17, 2012 14:02
css3 album flip
/* css3 album flip
http://labs.daryl.im/flipper/
http://dribbble.com/shots/731563-Music-player?list=popular&offset=0&page=2
*/
@font-face{
font-family: 'Pictos Custom';
src: url('http://codepen.io/fonts/icomoon.woff') format('woff');
}