Skip to content

Instantly share code, notes, and snippets.

View insin's full-sized avatar
⚠️
Cannot read property 'status' of undefined

Jonny Buchanan insin

⚠️
Cannot read property 'status' of undefined
View GitHub Profile
@insin
insin / CHANGES.rst
Last active August 29, 2015 14:00
Draft CHANGES for newforms 0.6

0.6.0 / 199X

Breaking Changes

  • Renamed form.isBound to form.isInitialRender, which more accurately reflects usage of this property (it was always being used in Forms as !isBound)
  • Changed setData() to no longer accept prefixed data by default. Added a
@insin
insin / SortableTable.js
Last active August 29, 2015 14:00
QUnit test starter example
void function () {
'use strict';
var SortableTable = {
//Initialize
init: function (element) {
this.table = element;
this.header = this.table.getElementsByTagName('thead')[0];
@insin
insin / app.js
Last active August 29, 2015 13:58
Newforms hacked for Mithril output - http://bl.ocks.org/insin/raw/9952028/
/** @jsx m */
'use strict';
var choices = [
[1, 'foo']
, [2, 'bar']
, [3, 'baz']
, [4, 'ter']
]
@insin
insin / view.jsx
Last active November 23, 2017 16:45
JSX version of a Mithril TODO example - try it with http://facebook.github.io/react/jsx-compiler.html
/**
* JSX version of https://github.com/jpmonette/todomvc-mithril/blob/1d627f1d5dc0890d0a99cdcb16d09387f68f6df0/js/views/todo-view.js
* Assumes the use of the vanilla JSX Transformer and an "mshim" object to translate tag calls to the format m() expects.
* @jsx mshim
*/
'use strict';
var m = require('mithril')
@insin
insin / app.jsx
Created March 9, 2014 17:41
"Template" component in React
var AddContact = React.createClass({
render: function() {
return <form ref="form">
<h2>Add {this.props.type}</h2>
{this.props.children}
<div>Phone Fields</div>
<div>Email Fields</div>
<div>Address Fields</div>
</form>
}
@insin
insin / Concur-0.2.4.min.js
Last active August 29, 2015 13:56
Newforms: Custom Form Layout - - http://bl.ocks.org/insin/raw/9335123/
/**
* Concur 0.2.4 - https://github.com/insin/concur
* MIT Licensed
*/
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Concur=t()}}(function(){return function t(n,r,e){function o(u,c){if(!r[u]){if(!n[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=r[u]={exports:{}};n[u][0].call(a.exports,function(t){var r=n[u][1][t];return o(r?r:t)},a,a.exports,t,n,r,e)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<e.length;u++)o(e[u]);return o}({1:[function(t,n){"use strict";function r(t,n){i.Function(n)?u.extend(t,n.prototype):u.extend(t,n)}function e(t){var n=t.__mixin__;i.Array(n)||(n=[n]);for(var e={},o=0,c=n.length;c>o;o++)r(e,n[o]);return delete t.__mixin__,u.extend(e,t)}function o(t,n,r){var e;return e=n&&u.hasOw
@insin
insin / allfields.js
Last active August 29, 2015 13:56
Newforms: All Default Fields - http://bl.ocks.org/insin/raw/9299833/
/**
* @jsx React.DOM
*/
var choices = [
[1, 'foo']
, [2, 'bar']
, [3, 'baz']
, [4, 'ter']
]
/**
* Replaces string {placeholders} with properties of a given object, but
* interpolates into and returns an array instead of a string.
* By default, any resulting empty strings are stripped out of the array. To
* disable this, pass an options object with a 'strip' property which is false.
*/
function formatToArray(str, obj, options) {
var parts = str.split(/\{(\w+)\}/g)
for (var i = 1, l = parts.length; i < l; i += 2) {
parts[i] = (object.hasOwn(obj, parts[i])
/**
* Creates an array in which the contents of the given array are interspersed
* with... something. If that something is a function, it will be called on each
* insertion.
*/
function intersperse(array, something) {
if (array.length < 2) { return array }
var result = [], i = 0, l = array.length
if (typeof something == 'function') {
for (; i < l; i ++) {
// Hash and OrderedObject initially based on http://dailyjs.com/2012/09/24/linkedhashmap/
;(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory)
}
else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,