Skip to content

Instantly share code, notes, and snippets.

View TCotton's full-sized avatar
🏠
Working from home

Andrew Walpole TCotton

🏠
Working from home
View GitHub Profile
MOBILE = window.MOBILE || {};
MOBILE.QUERIES = (function() {
'use strict';
// declare document and windows in variables for performace
var doc = document,
win = window;
var _private = {
set: function(args) {
// use the HTML5 API matchMedia to target phones and tablets
@TCotton
TCotton / web_worker_detection.js
Created January 21, 2013 17:06
Detects browser web worker support
WEB_WORKER = window.WEB_WORKER || {};
WEB_WORKER = (function($, window) {
var _private = {
worker: null,
file: null,
web_worker: function() {
return !!window.Worker;
},
set_url: function(args) {
@TCotton
TCotton / wordpress-breadcrumbs.php
Last active December 12, 2015 04:29
Code for creating Wordpress breadcrumbs in a theme
<?php
/* explanation of code here: http://www.suburban-glory.com/blog?page=170 */
function my_breadcrumb($id = null) {
echo '<a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a> &gt; ";
@TCotton
TCotton / wordpress-breadcrumb-advanced.php
Last active November 20, 2017 17:37
Code for creating Wordpress breadcrumbs in a theme including custom taxonomy
<?php
// --> http://www.suburban-glory.com/blog?page=170
/*
* based on http://snipplr.com/view/57988/
*/
function get_term_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {
$chain = '';
$parent = &get_term($id, $taxonomy);
@TCotton
TCotton / animation.js
Last active December 12, 2015 08:08
Change CSS3 animation using the JavaScript CSSOM
/* See blog post for details: http://www.suburban-glory.com/blog?page=171 */
var ANDY = window.ANDY || {};
ANDY.ANIMATION = (function (window) {
'use strict';
var _private, doc = document;
@TCotton
TCotton / form-validation.js
Last active December 12, 2015 09:09
A reusable JavaScript form class
;(function(window){
// for browsers without navite bind support
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
@TCotton
TCotton / form-validation-advanced.js
Last active September 18, 2020 13:09
A JavaScript reusable form class
/* See blog post for details: http://www.suburban-glory.com/blog?page=173 */
;(function(window, document, undefined) {
// for browsers without navite bind support
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
@TCotton
TCotton / Content_Type_Jobs_Template.php
Last active December 13, 2015 19:58
Creating a PHP class to create Wordpress custom post types with dynamic metaboxes
<?php namespace content;
/**
* See blog post for details: http://www.suburban-glory.com/blog?page=174
*
* Content_Type
*
* @package class for creating dynamic Wordpress metaboxes
* @author Andy Walpole
* @copyright AWalpole
* @version 2013
@TCotton
TCotton / wordpress_category_redirect.php
Created March 5, 2013 06:43
A quick way to add a URL redirect feature to Wordpress categories
<?php namespace content;
/**
* Category_Add_Field
*
* redirect() method is called in the header.php file
* if the user specifies an external URL in the category field
*
* @package class for creating dynamic Wordpress metaboxes
* @author Andy Walpole
* @copyright A Walpole
@TCotton
TCotton / media-query-testing.css
Last active December 15, 2015 07:58
Media query testing on different devices
@media only screen and (max-width:1280px) and (-webkit-min-device-pixel-ratio: 1.0),
only screen and (max-width:1280px) and (min-resolution: 120dpi) {
/* ipad 3 portrait / landscape
ipad 2 portrait / landscape
ipad 1 portrait / landscape
amazon kindle fir hd portrait
nexus 7 landscape
Samsung Galaxy Note 10.1 landscape
Samsung Galaxy Tab 2 10.1 landscape
LG Nexus 4 portrait