Skip to content

Instantly share code, notes, and snippets.

@benjaminfisher
benjaminfisher / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@benjaminfisher
benjaminfisher / jq_test.js
Last active August 29, 2015 14:13
JS: Test that TD element width matchs declared width (jQuery)
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
<script>
$(function(){
$('<p>').html('Width').prependTo('body');
$('tr').each(function(){
$(this).children('td').each(function(i){
var $this = $(this);
if(!$this.attr('colspan') && !($this.width() == $this.attr("width"))){
/*!
* PubSub.js
* ---------
*
* Extremely basic PubSub functionality.
*
* To subscribe to the topic `news`:
*
* PubSub.on("news", function(str){
* alert(str);
@benjaminfisher
benjaminfisher / ir.css
Created January 7, 2015 18:02
CSS: Image replacement class
.ir{
border:0;
font:0/0 a;
text-shadow:none;
color: transparent;
background-color:transparent;
}
// If true, start function. If false, listen for INIT.
if (Enabler.isInitialized()) {
enablerInitHandler();
} else {
Enabler.addEventListener(studio.events.StudioEvent.INIT, enablerInitHandler);
};
function enablerInitHandler() {
// Start ad, initialize animation,
@benjaminfisher
benjaminfisher / email-testing
Last active December 26, 2015 05:39 — forked from anonymous/gist:7102642
HTML Email - style tests for layout issues
<style>
body.align:before{
content: "Alignment";
}
.align td:not([align]),
.align td:not([valign]){
border:1px solid red;
}
body.colspan:before{
@benjaminfisher
benjaminfisher / HR
Last active December 22, 2015 11:19
No image 2px horizontal rule for HTML Email
<tr>
<td align="left" valign="top" width="20" style="font-family:Arial;font-size:15px;line-height:15px">&nbsp;</td>
<td align="left" valign="top" width="560" style="font-family:Arial;font-size:15px;line-height:15px">&nbsp;</td>
<td align="left" valign="top" width="20" style="font-family:Arial;font-size:15px;line-height:15px">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF" height="2" width="20" style="line-height:2px;font-size:2px">&nbsp;</td>
<td align="center" valign="top" bgcolor="#f28c9b" height="2" width="560" style="line-height:2px;font-size:2px">&nbsp;</td>
<td align="center" valign="top" bgcolor="#FFFFFF" height="2" width="20" style="line-height:2px;font-size:2px">&nbsp;</td>
</tr>
@benjaminfisher
benjaminfisher / jquery.mobile.vmouse.js
Created December 26, 2012 20:54
This plugin is an experiment for abstracting away the touch and mouse events so that developers don't have to worry about which method of input the device their document is loaded on supports. The idea here is to allow the developer to register listeners for the basic mouse events, such as mousedown, mousemove, mouseup, and click, and the plugin…
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Normalizes touch/mouse events.
//>>label: Virtual Mouse (vmouse) Bindings
//>>group: Core
//>>excludeEnd("jqmBuildExclude");
(function( $, window, document, undefined ) {
var dataPropertyName = "virtualMouseBindings",
touchTargetPropertyName = "virtualTouchID",
@benjaminfisher
benjaminfisher / active.js
Created December 6, 2012 21:36
function to add active state to buttons in dynamically loaded content
var activeState = function(){
var uriInfo = window.location.pathname.split("/"),
pageName = uriInfo[uriInfo.length-1],
buttons = $(this).find("li.button"),
$button, i;
i = buttons.length;
while(i--){
$button = $(buttons[i]);
if($button.find("a").attr("id") === pageName){
@benjaminfisher
benjaminfisher / fadein.css
Created December 5, 2012 15:22
CSS for fadein keyframes
/* name, duration, timing function, delay, fill mode */
-webkit-animation: fadeIn 700ms ease-in-out 1s both;
animation: fadeIn 700ms ease-in-out 1s both;
@-webkit-keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}