Skip to content

Instantly share code, notes, and snippets.

View daveespionage's full-sized avatar

David Cox-Espenlaub daveespionage

View GitHub Profile
@daveespionage
daveespionage / ios6webkittouch
Created March 4, 2013 18:46
ios 6 webkit with jquery for cross-browser touch issue fix
(function ($, window, document, undefined) {
$(function(){
// ios6 scroll issue fix
$(document).on('scroll', function () {
// trigger touch event
$(document).trigger('touchend');
});
});
@daveespionage
daveespionage / char_limit.js
Created September 25, 2012 15:08
Super simple Character Limit checker in Javascript
// Check character count and limit input field
// -------------------------------------------
// Original from: http://www.9lessons.info/2010/04/live-character-count-meter-with-jquery.html
//
$("#tweetBox").on('keyup',function()
{
var box=$(this).val();
var limit= 140
var count= limit - box.length;
@daveespionage
daveespionage / pxtoem.scss
Created September 20, 2012 18:07
px to em in sass
// from http://forrst.com/posts/SASS_px_to_em_and_em_to_px-JAd
// Convert px to em
@function pxtoem($target, $context){
@return ($target/$context)+0em;
}
@daveespionage
daveespionage / post_to_feed.js
Created September 20, 2012 11:16
Facebook Post To Feed functionality for Javascript with data attribute overrides
/*global $:false */
/*global FB:false */
function postToFeed(sourceObj) {
// using code from https://developers.facebook.com/docs/reference/dialogs/feed/
// calling the API ...
var obj = {
method: 'feed',
@daveespionage
daveespionage / scroll_to_top.js
Created September 20, 2012 11:10
Force Scroll to Top in Javascript for Touch/Mobile
/*global pageYOffset:false */
/*=========== Force Scroll to Top ===========*/
var userHasNotScrolled = true;
$(window).on('touchmove', function(e) {
userHasNotScrolled = false;
});
if(/mobi/i.test(navigator.userAgent) && !location.hash)
{
setTimeout(function () {
@daveespionage
daveespionage / touch_detect.js
Created September 20, 2012 11:09
Simple touch support detection for javascript
/*=========== Touch support detection ===========*/
(function detect_touch_support(){
if ("ontouchend" in document) {
$('html').addClass('touch');
} else {
$('html').addClass('no-touch');
}
}());
@daveespionage
daveespionage / addInheritance.js
Created September 7, 2012 13:38 — forked from ElliotChong/addInheritance.js
Add inheritance to JavaScript
(function ()
{
if (!Function.prototype.inherit)
{
Function.prototype.inherit = function (p_parent)
{
if (p_parent.constructor == Function)
{
// Normal Inheritance
this.prototype = new p_parent();