Skip to content

Instantly share code, notes, and snippets.

View designfrontier's full-sized avatar

Daniel Sellers designfrontier

View GitHub Profile
@designfrontier
designfrontier / titleCase
Created February 2, 2012 16:03
Some code extending the JavaScript string prototype for working with titles and headers
String.prototype.titleCaps = function(){
var thisString = this.replace(/( )([a-z])/g, function(m, $1, $2){return $1 + $2.toUpperCase();});
//remove and, the, or of from caps if they are not the first element in the string
thisString = thisString.replace(/(and|of|to|the|or)/ig, function(m,$1){return $1.toLowerCase();});
thisString = thisString.replace(/(^[a-z])/,function(m,$1){return $1.toUpperCase();});
return thisString;
};
@designfrontier
designfrontier / jquery.pinme.0.1.js
Created November 2, 2011 21:37
Pin me... an awesome jQuery plugin
//pins elements in place with JS
(function($){
$.pinme = function(el){
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
// Add a reverse reference to the DOM object