This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is the least sucky way i could think of to | |
// detect and deal with a cross-browser impl of the page visibility api | |
// forks welcome. | |
function getHiddenProp(){ | |
var prefixes = ['webkit','moz','ms','o']; | |
if ('hidden' in document) return 'hidden'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Cranium MVC | |
* A minimalist MVC implementation written for | |
* demonstration purposes at my workshops | |
* http://addyosmani.com | |
* Copyright (c) 2012 Addy Osmani; Licensed MIT */ | |
var Cranium = Cranium || {}; | |
// Set DOM selection utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* picked from http://stackoverflow.com/questions/5186441/javascript-drag-and-drop-for-touch-devices | |
* | |
*/ | |
function touchHandler(event) | |
{ | |
// trick to add support for touch event to elements/widgets that do not support it | |
// by convetting convert touchevents into mouseevents | |
// only apply this trick to ui-draggable elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.reverse = function() { | |
return this.split("").reverse().join(""); | |
} | |
Number.prototype.formatAsCurrency = function() { | |
return this.toString() | |
.replace(/^(\d)$/, "00$1") // pad 1 digit | |
.replace(/^(\d{2})$/, "0$1") // pad 2 digits | |
.reverse() | |
.replace(/(\d{2}(?=\d))/, "$1.") // place decimal point |