This file contains hidden or 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 a simplified sample of an idea I had today inspired by the fab | |
| project. Event loops currently suck... so I've built this wonky DSL for you. | |
| I'll release a real library later that actually implements some not so easy | |
| things. | |
| */ |
This file contains hidden or 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 () { | |
| function detectMutation() { | |
| mutationSupported = true; | |
| this.removeEventListener('DOMAttrModified', detectMutation, false); | |
| } | |
| var forEach = [].forEach, | |
| regex = /^data-(.+)/, | |
| el = document.createElement('div'), | |
| mutationSupported = false, |
This file contains hidden or 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(window, document, undefined) { | |
| // Enable all HTML5 elements in IE. For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/ | |
| /*@cc_on'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)})@*/ | |
| var each = [].forEach || function (fn) { | |
| var len = this.length || 0, that = arguments[1]; | |
| if (typeof fn == 'function') { | |
| for (var i = 0; i < len; i++) { | |
| fn.call(that, this[i], i, this); |
This file contains hidden or 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 how I fixed IE crashing on | |
| // dynamic injections of AtRules inside | |
| // stylesheets (for example @font-face) | |
| function setStyle(rules) { | |
| var d = document, | |
| s = d.createElement('style'), | |
| h = d.getElementsByTagName('head')[0] || d.documentElement; | |
| s.type = 'text/css'; | |
| d.createElement('div').appendChild(s).styleSheet.cssText = rules; |
This file contains hidden or 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
| .mouse{ | |
| position: absolute; | |
| background-image: url('../images/cursor.png'); | |
| width: 15px; | |
| height: 22px; | |
| z-index: 100; | |
| } |
This file contains hidden or 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 doc = document, | |
| htm = doc.documentElement, | |
| lct = null, // last click target | |
| nearest = function(elm, tag) { | |
| while (elm && elm.nodeName != tag) { | |
| elm = elm.parentNode; | |
| } | |
| return elm; | |
| }; |
This file contains hidden or 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 might be useful for certain size-limited JS competitions, or not. #js | |
| function super_shrinkify( str ){ | |
| var prefix = 'eval("', | |
| suffix = '".replace(/./g,function(a){return String.fromCharCode((a=a.charCodeAt())/128,a%128)}))', | |
| out = prefix + str.replace( /(.)(.)/g, function(a,b,c){ | |
| return String.fromCharCode( 128 * b.charCodeAt() + c.charCodeAt() ); | |
| }) + suffix; | |
| console.log( 'overhead: ' + ( prefix.length + suffix.length ) + ' chars' ); |
This file contains hidden or 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 forEach = [].forEach, | |
| regex = /^data-(.+)/, | |
| dashChar = /\-([a-z])/ig, | |
| el = document.createElement('div'), | |
| mutationSupported = false, | |
| match | |
| ; | |
| function detectMutation() { |
This file contains hidden or 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
| // So what I'm doing here seems cool, but I'm not sure exactly what it should be | |
| // called. Is this partial application? Currying? Something else? Vindaloo maybe? | |
| // | |
| // Either way, it's a pretty interesting pattern.. I wonder if it has any | |
| // real-world application. Probably not. | |
| // | |
| // Invoking the partially applied 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 |