Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
kentaromiura / transform.js
Created July 26, 2015 16:43
MooTools Class to ES 2015
module.exports = function(file, api) {
var j = api.jscodeshift;
var root = j(file.source);
root.find(j.Identifier).forEach(function(p) {
if(p.value.name === 'Class') {
if(p.parentPath.name === 'init'){
var classDefinition = p.parentPath.value.arguments[0];
var varname = p.parentPath.parentPath;
var name = varname.value.id;
var target = varname.parentPath.parentPath
@defunctzombie
defunctzombie / browser.md
Last active April 10, 2024 17:45
browser field spec for package.json
" TESTING: Entity Escaper
command Entities :call Entities()
function Entities()
silent %s/&/\&/eg
silent %s/"/\"/eg
silent %s/'/\'/eg
silent %s/</\&lt;/eg
silent %s/>/\&gt;/eg
silent %s/¡/\&iexcl;/eg
silent %s/¢/\&cent;/eg
@sebmarkbage
sebmarkbage / Template.js
Created February 15, 2012 18:43
HTML Template
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;
}
define({
/*
* Simplified prototypal inheritance, see http://javascript.crockford.com/prototypal.html
*/
create: function (obj){
function F() {}
F.prototype = obj;
return new F();
},
@jrburke
jrburke / apiexamples.js
Created April 7, 2011 05:50
Description of browser-friendly module APIs: AMD and Loader Plugins
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
/* XML Methods for MooTools */
/* Requires MooTools v1.3 */
var XML = {
rootFromFile: function(file){
var root = null;
switch (Browser.name){
case 'safari':
case 'chrome':
@cpojer
cpojer / Element.Transition.js
Created February 25, 2011 02:25
WIP. Might be part of PowerTools! someday.
(function(){
// thanks @astolwijk
var key = (function(){
var list = ['', 'webkit', 'Moz', 'O', 'ms'],
element = document.html;
for (var i = 0; i < list.length; i++){
var prefix = list[i];
if (element.style[prefix ? prefix + 'TransitionProperty' : 'transitionProperty'] != null)
@subtleGradient
subtleGradient / Declarative Component Mapping Syntax Options.textile
Created December 30, 2010 01:36
What is the best syntax to use for declarative markup in HTML5?

Declarative Component Mapping Syntax Options

Language / Prior Art ‘Valid’ HTML HTML Mapping Example Example with Args
‘Valid’ CSS Selectable CSS Mapping CSS Select CSS Selector w Args
JavaScript MooTools Multiple instance Separate Args new Foo(element); new Bar(element) new Foo(element, {a:"a", bB:"b B", c:{c:1}}); new Bar(element, {d:"d"})
HTML attr Dojo <1.6 NO
1 Element per instance