This file contains hidden or 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
Show hidden characters
{ | |
"scope": "source.js", | |
"completions": | |
[ | |
{"trigger": "m\tm() Mithril", "contents": "m('${1:div}',{\n\t${2:style: { \\}}, \n\t${3:config: 'function name'}\n\t},[\n\t\t${4:'Children'}\n\t])"}, | |
{"trigger": "mi\tinput Mithril", "contents": "m('input${1:[type=]}', ${2:oninput:}, value: $3)"}, | |
{"trigger": "ma\tlink Mithril", "contents": "m('a[href=${1:/myroute}]', {config: ${2:m.route}}, ${3:'Myroute'})"}, | |
{"trigger": "mm\tmodule Mithril", "contents": "var mymodule = {};\n\nmymodule.vm = ${1:'Object literal \\{\\} or function Constructor'}\n\nmymodule.controller = function (options) {\n\t${2:mymodule.vm.init();}\n};\n\nmymodule.view = function (ctrl) {\n\treturn ${3:'view here'};\n}\nm.module(document${4:.body}, mymodule);"}, | |
{"trigger": "mp\tgetter/setter Mithril", "contents" : "m.prop(${1:'initial value'});"}, | |
{"trigger": "mw\tevent handler Mithril", "contents": "m.withAttr(${1:'string here'}, ${2:callback here})"}, |
This file contains hidden or 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.route( document.body, "/dashboard/johndoe", { | |
"/dashboard/:userID": { | |
controller : function(){ | |
return m.request( { | |
url : "/permissions/" + m.route.param( "userID" ), | |
deserialize : function( xml ){ | |
return new DOMParser().parseFromString( xml, "text/xml" ); | |
} | |
} ).then( | |
function success(){}, |
This file contains hidden or 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
/** | |
* This version works | |
**/ | |
var dashboard = {}; | |
dashboard.model = function(id) { | |
return m.request({ | |
method: 'GET', | |
url: window.location.origin + '/example/' + id, | |
}) |
This file contains hidden or 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
var Ids = [139502, 92769, 57443]; | |
forecasts.model2 = function(Ids) { | |
console.log(Ids); | |
return m.request({ | |
method: 'GET', | |
url: window.location.origin + '/api/', | |
data: { | |
reportIds: Ids | |
} |
This file contains hidden or 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
https://jsfiddle.net/3p90n4mn/2/ | |
https://github.com/jasonmayes/mdl-component-design-pattern | |
https://github.com/Satyam/malt | |
https://github.com/dvcolgan/superflux | |
http://mithril.js.org/components.html#the-observer-pattern |
This file contains hidden or 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
// React version is here: https://github.com/ccoenraets/react-employee-directory/blob/master/iteration8/js/pageslider-react.js | |
var PageSlider = { | |
controller: function(args) { | |
var ctrl = this; | |
ctrl.history = m.prop([]); | |
ctrl.pages = m.prop([]); | |
ctrl.animating = m.prop(false); | |
ctrl.slidePage = function(page) { | |
var history = ctrl.history(); | |
var pages = ctrl.pages(); |
This file contains hidden or 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
var tabset = function tabset(tabnames, active) { | |
return m("ul", { className: "nav nav-tabs" }, tabnames.map(function (tab) { | |
return m("li", { role: "presentation", className: tab == active() && "active" }, m("a", { onclick: function onclick() { | |
return active(tab); | |
} }, tab)); | |
})); | |
}; |
This file contains hidden or 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
var checkbox = function checkbox(label, prop) { | |
return m("label.checkbox-inline", m("input[type=checkbox]", { | |
checked: prop(), | |
onclick: m.withAttr("checked", prop) | |
}), _.capitalize(label)); | |
}; |
This file contains hidden or 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
var select = function select(options, prop, attr) { | |
if (typeof prop() == "undefined" || prop() == "") { | |
prop(options[0]); | |
} | |
if (options.length == 0) { | |
prop(""); | |
} | |
return m("select.form-control", _.extend({ |
This file contains hidden or 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
var pluck = require("lodash").pluck; | |
var groupBy = require("lodash").groupBy; | |
var forceRender = require("lodash").identity; | |
var m = require("mithril"); | |
var horsey = require("horsey"); | |
var controller = function controller(label, data, property) { | |
//split the data set into subsets for performance |