Skip to content

Instantly share code, notes, and snippets.

View HendrikRoth's full-sized avatar

Hendrik Roth HendrikRoth

  • Dusseldorf, Germany
View GitHub Profile
/*****************************************
/* 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
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;
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=[];
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
}
}
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 ){
var onKey = (function(){
var keymap = {
'enter' : 13,
'space' : 31,
'tab' : 9,
'esc' : 27,
'left' : 37,
'up' : 38,
'right' : 39,
'down' : 40
// 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)
}
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
function setPosition(el, ctrl) {
var rect = el.getBoundingClientRect()
if (rect.left < 0) {
ctrl.position('left')
} else {
ctrl.position('right')
}
}
function initSubEvents(el, ctrl) {
'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) {