Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / jQuery plugin boilerplate
Created May 7, 2012 13:41
jQuery plugin boilerplate for building proper jQuery plugins
(function($, window, undefined){
$.fn.myPlugin = function(opts) {
var defaults = {
// setting your default values for options
}
// extend the options from defaults with user's options
var options = $.extend(defaults, opts || {});
return this.each(function(){ // jQuery chainability
@james2doyle
james2doyle / Hover Tap
Created May 20, 2012 15:32
Adding a tap event to preserve as much functionality as possible for mobile users.
if( document.createTouch ) {
this.addEvent(c[j],'tap',this.tipOver,false);
} else {
this.addEvent(c[j],'mouseover',this.tipOver,false);
this.addEvent(c[j],'mouseout',this.tipOut,false);
}
@james2doyle
james2doyle / Every 23nth-child css
Created July 2, 2012 03:48
Select every 2nd item in a row of 3 items
li:nth-child(3n-7) {
margin: 0 5%;
/*select every 2nd child in a row of three*/
}
@james2doyle
james2doyle / roundNumber
Created July 11, 2012 19:17
Round a number to a set amount of decimal places
function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
@james2doyle
james2doyle / dabblet.css
Created July 12, 2012 22:20
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
html {
background: #fff;
min-height: 100%;
}
input,label,textarea {
outline: none;
@james2doyle
james2doyle / dabblet.css
Created July 14, 2012 18:44
Nice Button
/**
* Nice Button
*/
button {
border: 1px solid #000;
margin: 0;
outline: 0;
padding: 10px 30px;
color: rgba(255,255,255,0.9);
@james2doyle
james2doyle / Create Image
Created July 30, 2012 18:47
Create Image. Onload function.
var img = new Image();
img.src = 'url-to-my-image.jpg';
img.onload = function() {
document.body.appendChild( img );
}
/**
* stars
*/
html,body {
background: #222;
margin: 2em;
}
ul {
margin: 0;
@james2doyle
james2doyle / dabblet.css
Created August 27, 2012 04:35
faded buttons
/**
* faded buttons
*/
body {
background: #555;
font-family: Arial;
color: white;
font-size: 30px;
text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
@james2doyle
james2doyle / dabblet.css
Created August 27, 2012 18:19
faded buttons
/**
* faded buttons
*/
body {
background: #555;
font-family: Arial;
color: white;
font-size: 30px;
text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}