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.implement({ | |
substitute: function(object, regexp){ | |
return this.replace(regexp || (/\\?\{([^{}:]+)(?::([^{}:]+))?\}/g), function(match, name, format){ | |
if (match.charAt(0) == '\\') return match.slice(1); | |
var value = (object[name] != null) ? object[name] : ''; | |
if (format && typeof value.format == 'function') value = value.format(format); | |
return value; | |
}); |
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
ART; // inherits ART.SVG | |
ART.Shape; // inherits ART.SVG.Shape | |
var surface = new ART(100, 100); // inherits ART.SVG | |
new ART.Shape().inject(surface); // inherits ART.SVG.Shape | |
var CustomClass = new Class({ | |
Extends: ART.Shape |
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
// Util | |
function placeholder(){} | |
function derive(Child, Parent){ | |
placeholder.prototype = Parent.prototype | |
var proto = new placeholder() | |
for (var i = 2, l = arguments.length; i < l; i++){ | |
var mixin = arguments[i] | |
for (var key in mixin) proto[key] = mixin[key] |
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
var Browser = require('Browser').Browser; | |
var Request; | |
(function(){ | |
Request = Browser.something ? new Class(...) : new Class(...); | |
})(); |
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
class Point(x, y) extends Something { | |
move(x, y); | |
public X = 0, Y = 0; | |
public move(x, y) { | |
X = x; | |
Y = y; | |
repaint(); |
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
### | |
The indentation on a line following a statement creates an implicit variable. | |
That variable can be reused by placing more statements on the same whitespace level. | |
### | |
createElement 'a' | |
.style | |
.width = 100 | |
.height = 100 | |
.setAttribute 'href', 'http://...' |
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
var two = 2, four = 4, five = 5; | |
exports: function sum(x, y) { | |
return x + y; | |
} | |
exports: var pi = 3.141593, birthday = 12; | |
exports: two, four; |
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 parseCSStransform(transform){ | |
var result = new ART.Transform(), tranform, | |
commandMatcher = /(\w+)\(([^\)]*)\)/g, command, | |
paramMatcher = /([\d\.]+)/g, params; | |
while (command = commandMatcher.exec(transform)){ | |
params = command[2].match(paramMatcher); | |
for (var i = 0; i < params.length; i++) | |
params[i] = parseFloat(params[i]); | |
transform = new ART.Transform(); | |
transform[command[1]].apply(transform, params); |
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
setCurrentGlobalState('foo'); | |
throw E; |
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
var template = function(html){ | |
var root = document.createElement('root'); | |
root.innerHTML = html; | |
var nodes = root.getElementsByTagName('*'), ids = {}; | |
for (var i = 0, l = nodes.length; i < l; i++){ | |
var id = nodes[i].getAttribute('id'); | |
if (id){ | |
nodes[i].removeAttribute('id'); | |
ids[id] = i; | |
} |