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
<div id="tagme" style="height:500px;width:500px;background-color:#DDF"></div> |
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
/* | |
Copyright (C) 2013 Sam Greenhalgh - RadicalResearch Ltd | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH TH |
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
// Only executes the most recent call after the specified timeout. | |
function Debouncer() { | |
var timeout; | |
this.execute = function(callback, wait) { | |
if (timeout) { | |
clearTimeout(timeout); | |
timeout = null; | |
} |
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
Object.extend = function(toObj, fromObj){ | |
var p = Object.getOwnPropertyNames(fromObj), | |
i = p.length; | |
while(i--) | |
{ | |
Object.defineProperty(toObj, p[i], Object.getOwnPropertyDescriptor(fromObj, p[i])); | |
} | |
}; |
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
/* Valuechange event and handler | |
* See: http://learn.jquery.com/events/event-extensions/ | |
*/ | |
(function($) { | |
var name = "valuechange"; | |
$.event.special[name] = { | |
// Event is bound |
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
// Creates a function that executes with the given context and pushes the original context to the first argument of the function. | |
unshiftContext: function(func, thisArg) { | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift(this); | |
func.apply(thisArg, args); | |
}; | |
}, |
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
function formatPostcode(postcode){ | |
return( | |
//if character fourth from the right is not space | |
postcode.slice(-4,-3) !== " " | |
//insert space three characters from the right | |
?postcode.slice(0,-3) + " " + postcode.slice(-3) | |
//otherwise use origional | |
:postcode | |
) | |
// upper case |
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
function wait(/* functions returning promises*/) { | |
return (function() { | |
return $.when.apply($, Array.prototype.map.call(actions, function(a) { return a(); })); | |
}).bind(Array.prototype.slice.call(arguments)); | |
} |
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
function hash(s){ | |
return Array.prototype.reduce.call(s, function(a,b){ a = (( a << 5) -a ) + b.charCodeAt(0); return a&a }, 0); | |
} |
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
(function() { | |
var call = Function.prototype.call; | |
Function.prototype.call = function() { | |
console.log(this, arguments); | |
return call.apply(this, arguments); | |
}; | |
}()); |
OlderNewer