Skip to content

Instantly share code, notes, and snippets.

View paulgosnell's full-sized avatar

Paul paulgosnell

View GitHub Profile
@paulgosnell
paulgosnell / hideaddrbar.js
Created September 9, 2011 16:17 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
//scroll to top, hide address bar on mobile devices - 1 for android, 0 for the rest
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash || !win.addEventListener ){
//scroll to 1
window.scrollTo( 0, 1 );
var scrollTop = 1,
@paulgosnell
paulgosnell / Get thumbnail src
Created October 8, 2011 08:57
commonly used snippets of WP code
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div class="bgImg" style="background:url(<?php echo $image[0]; ?>) no-repeat 50% 50%;"></div>
<?php endif; ?>
@paulgosnell
paulgosnell / load-twitter-asynchronously.js
Created October 8, 2011 09:02
Load Twitter JS-API asynchronously
// load twitter
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'http://platform.twitter.com/widgets.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
@paulgosnell
paulgosnell / load-facebook-asynchronously.js
Created October 11, 2011 09:36
Load Facebook asynchronously
// load facebook
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'http://connect.facebook.net/en_US/all.js#xfbml=1';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
@paulgosnell
paulgosnell / load-googleplus-asynchronously.js
Created October 11, 2011 10:06
Load Google Plus asynchronously
// load google plus
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
@paulgosnell
paulgosnell / hash-tabs.js
Created October 11, 2011 10:08
Simple tabs using hash
$(function() {
var tabContent = $(".tab_content");
// Modified tutorial's code for this
var tabs = $("ul#tabsNav li");
var hash = window.location.hash;
tabContent.not(hash).hide();
tabs.find('[href=' + hash + ']').addClass('active');
tabs.click(function() {
@paulgosnell
paulgosnell / Full Sample for v 0.3
Created December 7, 2011 20:34 — forked from rpupkin77/Full Sample for v 0.3
place engine - jquery plugin for gmaps place search
<html>
<head>
<title>Place Engine Test</title>
</head>
<body>
<a href="#" id="clear">Clear markers</a><br />
<div id="map" style="width:100%;height:600px;">
</div>
@paulgosnell
paulgosnell / linktastic.css
Created March 12, 2012 11:35 — forked from psyked/linktastic.css
Auto-matic link type icons
a[href^="http:"] {
display:inline-block;
padding-right:14px;
background:transparent url(/Images/ExternalLink.gif) center right no-repeat;
}
a[href^="mailto:"] {
display:inline-block;
padding-left:20px;
line-height:18px;
background:transparent url(/Images/MailTo.gif) center left no-repeat;
@paulgosnell
paulgosnell / snippet.js
Created April 11, 2012 09:11 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@paulgosnell
paulgosnell / localStorageSync.js
Created May 3, 2012 08:23 — forked from akgupta/localStorageSync.js
Overriding backbone sync to use local storage
// overriding sync to use local storage when possible
sync : function(method, model, options){
var key, now, timestamp, refresh;
if(method === 'read' && this.constants.isStoredInLocalStorage) {
// only override sync if it is a fetch('read') request
key = this.getKey();
if(key) {
now = new Date().getTime();
timestamp = $storage.get(key + ":timestamp");
refresh = options.forceRefresh;