Uses Craft.js
(API docs).
var myTemplate = Template.create({
template : "<p>#{foo}<p><i>#{bar.baz}</i>",
pattern : /#\{([a-zA-Z0-9-_.]*)\}/g,
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Matthias Le Brun http://mlb.li | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
function Class(o){ | |
var klass = function(){ return o.init.apply(this, arguments) }, | |
parent = o.parent, | |
prototype = "prototype", | |
i; | |
if(parent) { | |
klass[prototype] = parent[prototype]; | |
klass[prototype].parent = function(){parent.apply(this, arguments)}; | |
} | |
for(i in o) if(o.hasOwnProperty(i)) klass[prototype][i] = o[i]; |
// var dateFormat -> something returning a date like "YYYY/MM/DD", "DD-MM-YYYY", "MM/DD/YYYY" ... | |
// Function#curry from Craft.js | |
// https://github.com/mlbli/Craft/ | |
var convertDate = (function(string, date){ | |
var year = string.indexOf("Y"), | |
month = string.indexOf("M"), | |
day = string.indexOf("D") | |
return [date.slice(year, year + 4), date.slice(month, month + 2), date.slice(day, day + 2)].join("-") |
Uses Craft.js
(API docs).
var myTemplate = Template.create({
template : "<p>#{foo}<p><i>#{bar.baz}</i>",
pattern : /#\{([a-zA-Z0-9-_.]*)\}/g,
Craft.extend(DOM.prototype, { | |
wrapFirstWord : function(tag){ | |
var element = this, | |
text = element.get("innerHTML"); | |
return element.empty().insert(text.replace(/^([\w]*\s)/,"<" + tag + ">$1</" + tag + ">")) | |
} | |
}) |
var root = DOM(window) | |
, isScrolling = false | |
, interval | |
function getScrollState() { // verifies if window is still scrolling | |
if(!isScrolling) isScrolling = true | |
} | |
function getScrollStart() { // targets scrollStart and stops immediately | |
root.stopListening("scroll", getScrollStart).listen("scroll", getScrollState) |
/* | |
Runs on Craft.js | |
Inspired by Thomas Fuchs DomMonster (https://github.com/madrobby/dom-monster/blob/master/src/dommonster.js) | |
*/ | |
Hash(window).keys().difference(Hash(Element.make("iframe").css({display:"none"}).appendTo(document.body).get("contentWindow")).keys()) |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Todo List</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<h1>Todo List</h1> | |
<input type="text" value="" id="add" placeholder="Add a new item and hit enter" name="add"> |