View Blockem.js
const Blocker = () => {
const blockers = new Map
const register = v => {
if(v.attrs.blockers)
v.attrs.blockers.set(v.state, () =>
Promise.all(
['attrs', 'state']
.map(host =>
v[host].onbeforeremove
View README.md

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
View diffm.js
export default (component, previous = undefined) => ({
...component,
onbeforeupdate: (a, b) => (
component.onbeforeupdate
&&
component.onbeforeupdate(a, b) !== false
&&
previous = b
),
View fileInput.css
.fileContainer {
overflow: hidden;
position: relative;
}
.fileContainer [type=file] {
cursor: inherit;
display: block;
font-size: 999px;
filter: alpha(opacity=0);
View domicile.js
import m from 'mithril'
const find = predicate => generator => {
for(const item of generator)
if(predicate(item))
return item
}
const horizontalElementQuery = function * (root = document){
const backlog = []
View pave.js
const pave = (container, target, path = []) => (
container === target
?
path
:
Array.isArray(container)
?
container.filter((a, i) => pave(a, target, [...path, i])).pop()
:
container.instance
View ordinal-suffix.html
<span
class="ordinal"
data-number="22">
22
</span>
<span
class="ordinal"
data-number="0">
0
</span>
View detectCSS.js
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
var
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
if(i==1)
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
View overloaded-patchinko.js
export default function O(a){
return (
arguments.length == 1
?
typeof a != 'function'
?
new O(a => O(b, a))
:
this instanceof O
?
View m.inline-refs.js
const login = {
view : ({state}) =>
m('form#login', {
onsubmit: e => {
e.preventDefault()
console.log(
state.email.dom.value,
state.pass.dom.value,
)