it('should work', function(){ var key = action({ keydown: spy }) car.action('keydown=>keydown', key) runKeyDown(car) })
it('should work with hooks defined at bind time', function(){ var dispatch = action(function(e){ this.dispatch('down') }).on('down', spy) Car.prototype.action('keydown', dispatch) runKeyDown(new Car) })
it('should copy all attributes of the action when instantiated', function(){ var dispatch = action({ myattr: {}, stdin: chai.spy(function(){ this.should.not.equal(dispatch) this.should.deep.equal(dispatch) this.stdin.should.equal(dispatch.stdin) this.myattr.should.not.equal(dispatch.myattr) }) }) Car.prototype.action('keydown', dispatch) happen.keydown(new Car().el) dispatch.stdin.should.have.been.called(1) })
it('should maintain identity across actions', function(){ var first var dispatch = action({ stdin: chai.spy(function(){ this.should.not.equal(dispatch) if (first) this.should.equal(first) else first = this }) }) Car.prototype.action('keydown', dispatch) Car.prototype.action('keyup', dispatch) var car = new Car happen.keydown(car.el) happen.keyup(car.el) dispatch.stdin.should.have.been.called(2) })
module.exports = function(){ var path = 'BODY ' return action(function delegator(e, pres){ var view = pres.view if (e.target === view) return if (view.parentNode.querySelector(path) !== view) { path = unique(view) + ' ' } var selectors = this.pins for (var selector in selectors) { var targ = find(view, e.target, path + selector) if (targ) { e.delegate = targ this.dispatch(selector, e, pres) } } }) }
export function getImages() { action('/run/_albums/get_images', templateGetImages); }
export function refreshAlbum() { action('/run_cmd/album/refresh', templateRefresh); }
export function createAlbum() { action('/run_cmd/album/create', templateNew); }
export function deportAlbum() { action('/run_cmd/album/deport', templateDeport); }
.map(res => action('response', { success: (typeof res.error == 'undefined' || !res.error), title: 'Created', text: ((typeof res.error == 'undefined' || !res.error) && res.body.length) ? 'User ' + res.body[0].email + ' created with ID ' + res.body[0].id + '.' : 'An unknown error occured, please try again later.' }))
export function reloadEditorials() { action('/run/_editorials/reload_table', templateReload); }
export function createBanner() { action('/run_cmd/banner/create', templateCreate); }
export function importAlbum() { action('/run_cmd/album/import', templateImport); }
export function deportEditorial() { action('/run_cmd/editorial/deport', templateDeport); }
export function refreshBanner() { action('/run_cmd/banner/refresh', templateRefresh); }
export function reloadBanners() { action('/run/_banners/reload_table', templateReload); }
it('should work', function(){ Car.prototype.action('keydown=>keydown', action({ keydown: spy })) runKeyDown(new Car) })
export function importBanner() { action('/run_cmd/banner/import', templateImport); }
export function getImages() { action('/run/_banners/get_images', templateGetImages); }
export function importEditorial() { action('/run_cmd/editorial/import', templateImport); }
input$: DOM.select('input').events('input').map(ev => action('input', {target: ev.target.name, value: ev.target.value})),
export function refreshEditorial() { action('/run_cmd/editorial/refresh', templateRefresh); }
submit$: DOM.select('button').events('click').map(ev => action('submit', {target: ev.target.name})),
export function getImages() { action('/run/_editorials/get_images', templateGetImages); }
export function deportBanner() { action('/run_cmd/banner/deport', templateDeport); }