Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
margin: 0;
padding: 0;
background: #fff;
public function sync()
{
$models = array(
"issue" => new Issue(),
"layout" => new Layout(),
"template" => new Template(),
"page" => new Page(),
"element" => new Element(),
"style" => new Style(),
"event" => new Event(),
@assertchris
assertchris / gist:3370234
Created August 16, 2012 13:49
Declarative Behaviors (Moo/CS)
do ->
walk = (parts, value) ->
stack = {}
part = parts.shift()
if parts.length
stack[part] = walk(parts, value)
else
stack[part] = value
@assertchris
assertchris / gist:3370239
Created August 16, 2012 13:50
Moofx3 Mootools Adapter (Moo/CS)
do ->
animate = (property, value, options) ->
moo = moofx(this)
moo and moo.animate(property, value, options)
return this
design = (property, value) ->
moo = moofx(this)
moo and moo.style(property, value)
return this
@assertchris
assertchris / gist:3370241
Created August 16, 2012 13:50
Namespaced Events (Moo/CS)
do ->
splitter = ":" # e.g. foo:click
key = "events.namespace." # e.g. events.namespace.foo
# do not edit below this line unless you know what you are doing!
addNamespaceEvent = (name, callback, s) ->
[namespace, type] = name.split(s or splitter)
cache = @retrieve(key + namespace) or {}
@assertchris
assertchris / gist:3370243
Created August 16, 2012 13:51
Stored Events Shortcuts (Moo/CS)
Element.implement({
"call": (name, parameters...) ->
if callback = @retrieve(name)
callback.apply(this, parameters)
})
@assertchris
assertchris / gist:3370262
Created August 16, 2012 13:52
Example Declarative Behavior (Moo/CS)
do ->
namespace = "behaviors.tabs"
fm.behaviors.add("tabs", {
"onAdd": (scope, parameters) ->
_tab = parameters?.selector?.tab or ".tab"
_subtabs = parameters?.selector?.subtabs or ".subtabs"
_text = parameters?.selector?.text or ".text"
<!DOCTYPE html>
<html lang="en">
<head>
<title>Invaders</title>
<style type="text/css">
body, html {
width: 100%;
height: 100%;
overflow: hidden;
}
@assertchris
assertchris / gist:3508343
Created August 29, 2012 08:08
MooTools + Moofx + CoffeeScript: scrollTop animation
$up = $container.getElement(".up")
$down = $container.getElement(".down")
$grains = $container.getElement(".grains")
animator = moofx((value) ->
$grains.scrollTop = value
)
$up.addEvent("click", (e) ->
e and e.preventDefault()
$callbacks = array(
"cb" => function($value) {
return $value;
}
);
echo $callbacks["cb"]("hello world");
// This works in PHP 5.4.4 (not sure when it started working really...)