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
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
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
/* | |
* Mithril.Elements | |
* Copyright (c) 2014 Phil Toms (@PhilToms3). | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
'use strict'; | |
var m = (function app(window, mithril) { |
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
export default ( object, jsonIndent = 2 ) => | |
JSON.stringify( | |
object, ( key, value ) => | |
value instanceof Function | |
? value.toString() | |
: value, | |
jsonIndent | |
) | |
.replace( /\\n/g, '\n' ) | |
.replace( /\\r/g, '\r' ) |
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 state (namespace) { | |
if (!namespace) return internalState[internalState.length - 1] | |
internalState.push([namespace, options]) | |
m.redirect(namespace, options) | |
} | |
function goto (namespace, options) { | |
return function (e) { | |
e.preventDefault() | |
e.stopPropagation() |
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
m.initComponent = function (component, options, content) { | |
var controller = new component.controller(options) | |
controller.render = function (options2, content2) { | |
return component.view(controller, options2 || options, content2 || content) | |
} | |
return controller | |
} |
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
//helpers | |
var target | |
function tenant(id, module) { | |
return { | |
controller: module.controller, | |
view: function(ctrl) { | |
return target == id ? module.view(ctrl) : {subtree: "retain"} | |
} | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mithril experiment</title> | |
<meta name="description" content="mithriljs: Mithril template"> | |
<meta charset="utf-8"> | |
<script> | |
window.log = function(){ | |
log.history = log.history || []; // store logs to an array for reference |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mithril experiment</title> | |
<meta name="description" content="mithriljs: Mithril template from Github"> | |
<meta charset="utf-8"> | |
<script> | |
window.log = function(){ | |
log.history = log.history || []; // store logs to an array for reference |
OlderNewer