Skip to content

Instantly share code, notes, and snippets.

@bchumney
bchumney / touchwipe-jquery.js
Created October 7, 2013 20:07
Touchwipe jQuery Plugin
(function($){$.fn.touchwipe=function(settings){var config={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(settings)$.extend(config,settings);this.each(function(){var startX;var startY;var isMoving=false;function cancelTouch(){this.removeEventListener('touchmove',onTouchMove);startX=null;isMoving=false}function onTouchMove(e){if(config.preventDefaultEvents){e.preventDefault()}if(isMoving){var x=e.touches[0].pageX;var y=e.touches[0].pageY;var dx=startX-x;var dy=startY-y;if(Math.abs(dx)>=config.min_move_x){cancelTouch();if(dx>0){config.wipeLeft()}else{config.wipeRight()}}else if(Math.abs(dy)>=config.min_move_y){cancelTouch();if(dy>0){config.wipeDown()}else{config.wipeUp()}}}}function onTouchStart(e){if(e.touches.length==1){startX=e.touches[0].pageX;startY=e.touches[0].pageY;isMoving=true;this.addEventListener('touchmove',onTouchMove,false)}}if('ontouchstart'in document.documentElement){this.addEventListener('touchst
@bchumney
bchumney / ie-generated-html.js
Created October 17, 2013 03:31
Generated HTML Source for IE
javascript:void(window.open("javascript:document.open(\"text/plain\");document.write(opener.document.body.parentNode.outerHTML)"))
@bchumney
bchumney / mobile-detect.php
Created October 17, 2013 03:33
Mobile Detection PHP
<?php
/**
* Mobile Detect
* $Id: Mobile_Detect.php 49 2012-06-06 20:46:30Z serbanghita@gmail.com $
*
* @usage require_once 'Mobile_Detect.php';
* $detect = new Mobile_Detect();
* $detect->isMobile() or $detect->isTablet()
*
* For more specific usage see the documentation navigate to:
@bchumney
bchumney / s-tag-hpc-calculations.txt
Created October 17, 2013 14:26
Convio S-tag HPC Conditionalization
Displays largest transaction amount X 1.5 or 35, whichever is higher
----------------------------------------------------------------------
[[?x[[E130:[[S1:largest_trans_amount]] 35 - 0 > ]]x::x1x::[[E130:[[S1:largest_trans_amount]] 1.5 *]]::35]]
Your donation of
$[[?x[[E130:[[S1:largest_trans_amount]] 25 - 0 > ]]x::x1x::[[E130:[[S1:largest_trans_amount]] 1 *]]::25]].00,
$[[?x[[E130:[[S1:largest_trans_amount]] 50 - 0 > ]]x::x1x::[[E130:[[S1:largest_trans_amount]] 1.5 *]]::50]].00, or
$[[?x[[E130:[[S1:largest_trans_amount]] 100 - 0 > ]]x::x1x::[[E130:[[S1:largest_trans_amount]] 2 *]]::100]].00
will go directly into our Challenge Grant matching funds.
@bchumney
bchumney / s-tag-action-count-conditionalization.txt
Created October 17, 2013 14:28
S-tag Action Count Conditionalization
You've taken [[S1:curr_year_alert_response_count]] actions this year[[?x[[S1:curr_year_alert_response_count]]x::x0x::.::&mdash;that puts you in the top [[?x[[S1:curr_year_alert_response_count]]x::x1x::12::[[?x[[S1:curr_year_alert_response_count]]x::x2x::8::[[?x[[E130:[[S1:curr_year_alert_response_count]] 9 - 0 > ]]x::x1x::2::6]]]]]]% of the EDF list!]][[?x[[S1:curr_year_alert_response_count]]x::x0x:: Join the 232,498 EDF supporters who have!::]][[?[[S1:creation_date]]::2013::::<br><span style="font-size: 11px;" class="smallText">2012 action count: [[S1:prev_year_alert_response_count]]</span>]]
@bchumney
bchumney / jvectormap-sample.html
Created October 17, 2013 16:01
JVectorMap Sample
<link rel="stylesheet" media="all" href="../jvectormap/jquery-jvectormap.css"/>
<script src="../jvectormap/jquery-jvectormap-1.1.1.min.js" type="text/javascript"></script>
<script src="../jvectormap/jquery-mousewheel.js" type="text/javascript"></script>
<script src="../jvectormap/tests/assets/jquery-jvectormap-world-mill-en.js" type="text/javascript"></script>
<script src="../jvectormap/tests/assets/jquery-jvectormap-us-aea-en.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
var states = {
"US-AL": 0, "US-AK": 1, "US-AZ": 2, "US-AR": 3, "US-CA": 4, "US-CO": 5, "US-CT": 6, "US-DE": 7, "US-DC": 8, "US-FL": 9, "US-GA": 10, "US-HI": 11, "US-ID": 12, "US-IL": 13, "US-IN": 14, "US-IA": 15, "US-KS": 16, "US-KY": 17, "US-LA": 18, "US-ME": 19, "US-MD": 20, "US-MA": 21, "US-MI": 22, "US-MN": 23, "US-MS": 24, "US-MO": 25, "US-MT": 26, "US-NE": 27, "US-NV": 28, "US-NH": 29, "US-NJ": 30, "US-NM": 31, "US-NY": 32, "US-NC": 33, "US-ND": 34, "U
@bchumney
bchumney / jquery-plugin-template.js
Created October 19, 2013 20:52
jQuery Plugin Template
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;(function ( $, window, undefined ) {
// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
// window and document are passed through as local variables rather than globals
@bchumney
bchumney / meta-tags-mobile.html
Created October 19, 2013 20:55
Meta Tags for Mobile
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="320" />
<meta name="Viewport" content="width=device-width" />
@bchumney
bchumney / modernizr-example.html
Created October 19, 2013 20:56
Modernizr Example
<script src="../modernizr-1.7.js" type="text/javascript"></script>
<script type="text/javascript">
function testFeatures() {
// Test for JavaScript Features
document.querySelector("#geoloc").innerHTML = Modernizr.geolocation ? "supported" : "not supported";
document.querySelector("#touch").innerHTML = Modernizr.touch ? "supported" : "not supported";
// Test for HTML5 Features
document.querySelector("#svg").innerHTML = Modernizr.svg ? "supported" : "not supported";
document.querySelector("#canvas").innerHTML = Modernizr.canvas ? "supported" : "not supported";
@bchumney
bchumney / mobile-events-listeners.js
Created October 19, 2013 21:00
Mobile Events Listeners
//Simple Orientation
onorientationchange="updateOrientation();"; onload="updateOrientation();";
var displayStr = "Orientation : ";
switch (window.orientation) {
case 0:
displayStr += "Portrait (0 deg)";
break;