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
/***************************************** | |
/* DOM touch support module | |
/*****************************************/ | |
(function(document) { | |
var TAPTRESHOLD = 200, // time within a double tap should have happend | |
TAPPRECISION = 60 / 2, // distance to identify a swipe gesture | |
touch = { }, | |
tapCount = 0, // counts the number of touchstart events | |
tapTimer = 0, // timer to detect double tap | |
isTouchSwipe = false, // set to true whenever |
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.createComponent = function(proto) { | |
function _component(attrs, children) { | |
// always return a fresh instance, allows for call without new | |
if(!(this instanceof _component)) { | |
return new _component(attrs, children); | |
} | |
if(!children && Array.isArray(attrs)) { | |
children = attrs; |
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
var z = (function (){ | |
//helpers | |
var cache = {}; | |
var target; | |
var type = {}.toString; | |
var tenant=function(componentName, component) { | |
return { | |
controller: component.controller, | |
view: function(ctrl) { | |
var args=[]; |
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
var Router = function(module, name) { | |
return { | |
controller: function() { | |
// Do something generic like calling Google Analytics from here | |
console.log("Router", name) | |
return new module.controller() | |
}, | |
view: module.view | |
} | |
} |
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
var slice = Array.prototype.slice; | |
function multi(){ | |
var handlers = slice.call( arguments ); | |
return function execute(){ | |
var args = slice.call( arguments ); | |
var ctxt = this; | |
handlers.map( function applyCtxt( fn ){ |
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
var onKey = (function(){ | |
var keymap = { | |
'enter' : 13, | |
'space' : 31, | |
'tab' : 9, | |
'esc' : 27, | |
'left' : 37, | |
'up' : 38, | |
'right' : 39, | |
'down' : 40 |
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
// var ListComponent = m.component({ ... }) -> component | |
// var list = ListComponent() -> component instance | |
// list.view() -> view | |
m.component = function (component) { | |
return function (options, content) { | |
var controller = new component.controller(options) | |
controller.view = function () { | |
return component.view(controller, arguments[0] || options, arguments[1] || content) | |
} |
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
local application = require "hs.application" | |
local tiling = require "hs.tiling" -- git clone https://github.com/dsanson/hs.tiling $HOME/.hammerspoon/hs/tiling | |
local hotkey = require "hs.hotkey" | |
local mash = {"ctrl", "cmd"} | |
local safari = nil | |
-- settings | |
hs.window.animationDuration = 0 -- disable window animations | |
-- tiling |
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 setPosition(el, ctrl) { | |
var rect = el.getBoundingClientRect() | |
if (rect.left < 0) { | |
ctrl.position('left') | |
} else { | |
ctrl.position('right') | |
} | |
} | |
function initSubEvents(el, ctrl) { |
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
'use strict' | |
function createView(ctrl, opts, children) { | |
opts = opts || {} | |
opts.shadow = opts.shadow || true | |
return m('.modal[layout][horizontal][center-center]', { | |
active: ctrl.active(), | |
shadow: opts.shadow, | |
config: function(element, isInitialized, context) { |
OlderNewer