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
'use strict'; | |
var m = require('mithril'); | |
var icons = require('client/utils/icons'); | |
var remove = require('lodash/array/remove'); | |
var transform = require('lodash/object/transform'); | |
var last = require('lodash/array/last'); | |
var code = require('yields-keycode'); | |
function sameAs(filterA) { |
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 test = {}; | |
test.getnews = function(exa) { | |
return m.request({ | |
method: 'GET', | |
dataType: "jsonp", | |
url: "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&q=" + exa, | |
unwrapSuccess: function(response) { | |
return response.responseData.feed.entries; | |
}, |
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
/* | |
This code uses a regular expression to make the json safer. | |
An potentially safer alternative is https://github.com/joewalnes/filtrex (untested) at the cost of 130Kb. | |
Can be used for example with this JSON structure: | |
{ | |
"_meta_po_header": "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);", | |
"COLLECTION_CONTENTS[0]": "Kolekcja zawiera %@ przepis.", | |
"COLLECTION_CONTENTS[1]": "Kolekcja zawiera %@ przepisy.", | |
"COLLECTION_CONTENTS[2]": "Kolekcja zawiera %@ przepisów." |
OlderNewer