JSConf.eu opening song - JavaScript Will Listen - Bella Morningstar
- Plask - Dean McNamee
- Plask
| Element.Storage = { | |
| UID: 1 | |
| }; | |
| Element.addMethods({ | |
| getStorage: function(element) { | |
| if (!(element = $(element))) return; | |
| if (Object.isUndefined(element._prototypeUID)) | |
| element._prototypeUID = Element.Storage.UID++; |
| // See my blog post: | |
| // http://benalman.com/news/2010/09/partial-application-in-javascript/ | |
| // In the following code sample, invoking the curried function will always | |
| // return a function until all arguments are satisfied, at which point the | |
| // original function is invoked, returning its result. This means that all | |
| // function arguments are required, which also allows the function to be | |
| // called either like foo( 1, 2, 3 ) or foo( 1 )( 2 )( 3 ). This also means | |
| // that if any argument is omitted, the original function is never invoked. |
| (function() { | |
| var origDefine = define; | |
| function redefine(name, definitions) { | |
| return function (prereqs, definition) { | |
| if (arguments.length > 2) { | |
| throw new Error('Cannot have more than two arguments to define in ' + name); | |
| } else if (arguments.length === 1) { | |
| definition = prereqs; | |
| prereqs = []; |
| (function($){ | |
| $(function(){ | |
| $.support.fixedPosition = (function(){ | |
| var container = document.body; | |
| if (document.createElement && container && container.appendChild && container.removeChild) { | |
| var el = document.createElement('div'); | |
| if (!el.getBoundingClientRect) return null; |
| function(b,c){return b.replace(/{[\w\.\(\)]+}/g,function(a){a=a.replace(/[\{\}]/g,"");try{with(c)return eval(a)}catch(b){return""}})}; |
| # Swappable Mixins in CoffeeScript | |
| # ================================ | |
| # Many thanks to Hashmal, who wrote this to start. | |
| # https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e | |
| # Usage | |
| # ----- | |
| # class Derp extends Mixin |
| function clone( obj ) { | |
| var val, length, i, | |
| temp = []; | |
| if ( Array.isArray(obj) ) { | |
| for ( i = 0, length = obj.length; i < length; i++ ) { | |
| // Store reference to this array item's value | |
| val = obj[ i ]; | |
| // If array item is an object (including arrays), derive new value by cloning |
| util.request = (function(){ | |
| var fn = { | |
| body: 'return null' | |
| }; | |
| if ('XDomainRequest' in window){ | |
| fn.body = 'return new XDomainRequest();'; | |
| fn.xdomain = true; | |
| } else if ('XMLHttpRequest' in window) { | |
| fn.body = 'return new XMLHttpRequest();'; |
| //Came across this in the es-discuss list, on the "clean scope" thread: | |
| https://mail.mozilla.org/pipermail/es-discuss/2011-August/thread.html#16294 | |
| //I do not understand what the "null," part buys. | |
| //Has to do something with scope(?), but at least in Firebug, | |
| //I can see foo inside the string being evaled. | |
| var foo = 'foo'; | |
| (null,eval)('(function(){console.log(foo);}())'); |