Skip to content

Commit

Permalink
Merge pull request #75 from edenspiekermann/release/4.0.0
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
KittyGiraudel authored Oct 4, 2017
2 parents c91a085 + b1deec8 commit aec2720
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,19 @@ If necessary, the `create()` method also accepts the `targets` containers (the o

## Events

When shown, hidden and destroyed, the instance will emit certain events. It is possible to subscribe to these with the `on()` method which will receive the dialog DOM element, the [event target](https://developer.mozilla.org/en-US/docs/Web/API/Event/target) (if any) and the [event current target](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget) (if any).
When shown, hidden and destroyed, the instance will emit certain events. It is possible to subscribe to these with the `on()` method which will receive the dialog DOM element and the [event object](https://developer.mozilla.org/en-US/docs/Web/API/Event) (if any).

The event object can be used to know which trigger (opener / closer) has been used in case of a `show` or `hide` event.

```javascript
dialog.on('show', function (dialogEl, target, currentTarget) {
dialog.on('show', function (dialogEl, event) {
// Do something when dialog gets shown
// Note: opener is `event.currentTarget`
});

dialog.on('hide', function (dialogEl, target, currentTarget) {
dialog.on('hide', function (dialogEl, event) {
// Do something when dialog gets hidden
// Note: closer is `event.currentTarget`
});

dialog.on('destroy', function (dialogEl) {
Expand Down
7 changes: 2 additions & 5 deletions a11y-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,17 @@

/**
* Iterate over all registered handlers for given type and call them all with
* the dialog element as first argument, event target as second argument, if
* any, actual trigger (opener / closer) as third argument, if any.
* the dialog element as first argument, event as second argument (if any).
*
* @access private
* @param {string} type
* @param {Event} event
*/
A11yDialog.prototype._fire = function (type, event) {
var listeners = this._listeners[type] || [];
var target = event ? event.target : void 0;
var currentTarget = event ? event.currentTarget : void 0;

listeners.forEach(function (listener) {
listener(this.node, target, currentTarget);
listener(this.node, event);
}.bind(this));
};

Expand Down
4 changes: 2 additions & 2 deletions a11y-dialog.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,17 @@

/**
* Iterate over all registered handlers for given type and call them all with
* the dialog element as first argument, event target as second argument, if
* any, actual trigger (opener / closer) as third argument, if any.
* the dialog element as first argument, event as second argument (if any).
*
* @access private
* @param {string} type
* @param {Event} event
*/
A11yDialog.prototype._fire = function (type, event) {
var listeners = this._listeners[type] || [];
var target = event ? event.target : void 0;
var currentTarget = event ? event.currentTarget : void 0;

listeners.forEach(function (listener) {
listener(this.node, target, currentTarget);
listener(this.node, event);
}.bind(this));
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "a11y-dialog",
"version": "3.1.0",
"version": "4.0.0",
"description": "A tiny script to make dialog windows accessible to assistive technology users.",
"homepage": "https://github.com/edenspiekermann/a11y-dialog",
"main": "a11y-dialog.js",
Expand Down

0 comments on commit aec2720

Please sign in to comment.