• Stars
    star
    316
  • Rank 132,587 (Top 3 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 15 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom events…

Eve

Tiny event helping JavaScript library.

eve(name, scope, varargs)

Fires event with given name, given scope and other parameters.

Parameters

  • name string name of the event, dot (.) or slash (/) separated
  • scope object context for the event handlers
  • varargs ... the rest of arguments will be sent to event handlers

Returns: object array of returned values from the listeners. Array has two methods .firstDefined() and .lastDefined() to get first or last not undefined value.

eve.listeners(name)

Internal method which gives you array of all event handlers that will be triggered by the given name.

Parameters

  • name string name of the event, dot (.) or slash (/) separated

Returns: array array of event handlers

eve.separator(separator)

If for some reasons you don’t like default separators (. or /) you can specify yours here. Be aware that if you pass a string longer than one character it will be treated as a list of characters.

Parameters

  • separator string new separator. Empty string resets to default: . or /.

eve.on(name, f, name, f)

Binds given event handler with a given name. You can use wildcards “*” for the names:

eve.on("*.under.*", f);
eve("mouse.under.floor"); // triggers f

Use eve to trigger the listener.

Parameters

  • name string name of the event, dot (.) or slash (/) separated, with optional wildcards
  • f function event handler function
  • name array if you don’t want to use separators, you can use array of strings
  • f function event handler function

Returns: function returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.

Example:

eve.on("mouse", eatIt)(2);
eve.on("mouse", scream);
eve.on("mouse", catchIt)(1);

This will ensure that catchIt function will be called before eatIt.

If you want to put your handler before non-indexed handlers, specify a negative value. Note: I assume most of the time you don’t need to worry about z-index, but it’s nice to have this feature “just in case”.

eve.f(event, varargs)

Returns function that will fire given event with optional arguments. Arguments that will be passed to the result function will be also concated to the list of final arguments.

el.onclick = eve.f("click", 1, 2);
eve.on("click", function (a, b, c) {
    console.log(a, b, c); // 1, 2, [event object]
});

Parameters

  • event string event name
  • varargs and any other arguments

Returns: function possible event handler function

eve.stop()

Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.

eve.nt([subname])

Could be used inside event handler to figure out actual name of the event.

Parameters

  • subname string subname of the event

Returns: string name of the event, if subname is not specified or

Returns: boolean true, if current event’s name contains subname

eve.nts()

Could be used inside event handler to figure out actual name of the event.

Returns: array names of the event

eve.off(name, f)

Removes given function from the list of event listeners assigned to given name. If no arguments specified all the events will be cleared.

Parameters

  • name string name of the event, dot (.) or slash (/) separated, with optional wildcards
  • f function event handler function

eve.unbind()

See eve.off

eve.once(name, f)

Binds given event handler with a given name to only run once then unbind itself.

eve.once("login", f);
eve("login"); // triggers f
eve("login"); // no listeners

Use eve to trigger the listener.

Parameters

  • name string name of the event, dot (.) or slash (/) separated, with optional wildcards
  • f function event handler function

Returns: function same return function as eve.on

eve.version()

Current version of the library.

More Repositories

1

Snap.svg

The JavaScript library for modern SVG graphics.
JavaScript
13,954
star
2

dropcap.js

Beautiful CSS drop caps made easy
HTML
929
star
3

css-shapes-polyfill

Polyfill for the CSS Shapes Specification
JavaScript
303
star
4

css-regions-polyfill

Experimental CSS Regions polyfill written in JavaScript
JavaScript
159
star
5

Demo-for-Alice-s-Adventures-in-Wonderland

Demo of CSS Shapes using the Alice in Wonderland story.
CSS
149
star
6

Demo-for-National-Geographic-Forest-Giant

A prototypical adaptation of the National Geographic article "Forest Giants" using Adobe's contributions to WebKit.
JavaScript
135
star
7

css-shapes-editor

Standalone in-browser editor for CSS Shapes.
JavaScript
120
star
8

dr.js

Tiny documentation builder
JavaScript
114
star
9

shaderdsl

A compiler from a subset of JavaScript to GLSL.
JavaScript
97
star
10

brackets-css-shapes-editor

CSS Shapes Editor extension for Brackets / Adobe Edge Code
JavaScript
94
star
11

custom-filters-demo-travel-app

An app that explores the use of custom filters to create UI enhancements
JavaScript
55
star
12

iframeflow.js

A Javascript helper for cross-browser CSS Regions support
JavaScript
41
star
13

coding-guidelines

JavaScript
28
star
14

Demo-for-PBS-Kids-Word-Girl

Digital comic book adaptation using Photoshop Generator
JavaScript
21
star
15

Demo-for-Food-Network-Cupcakes

Demo using Food Network content to showcase Web Engine features
JavaScript
21
star
16

Demo-for-National-Geographic-Orphan-Elephants

A prototypical adaptation of the National Geographic article "Orphan Elephants" showcasing Regions in use with Viewport Units.
JavaScript
15
star
17

html5devconf-2013

Slides from @adobe-webplatform team presented at HTML5 Dev Conf.
CSS
14
star
18

road-trip

“Road Trip” CSS Regions Demo
JavaScript
7
star
19

exclusionsrecipe

Demo of exclusions for mobile.
CSS
7
star
20

regions-adaptive

Demo of an adaptive web app UI built with CSS Regions
6
star
21

transform-tests

2
star