Skip to content

Commit

Permalink
Add ability to remove all listeners
Browse files Browse the repository at this point in the history
call instance.off() with no parameters to remove all listeners at one
fell swoop.
  • Loading branch information
thebarge committed Mar 10, 2015
1 parent 0d876b5 commit 7aa3eb7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bellhop",
"version": "1.1.3",
"version": "1.1.4",
"main": "dist/bellhop.min.js",
"dependencies": {
"bind-polyfill": "*"
Expand Down
10 changes: 8 additions & 2 deletions dist/bellhop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Bellhop 1.1.3 */
/*! Bellhop 1.1.4 */
(function(window, undefined){

/**
Expand Down Expand Up @@ -332,13 +332,19 @@
/**
* Remove an event listener
* @method off
* @param {String} type The type of event to listen for
* @param {String} type The type of event to listen for. If undefined, remove all listeners.
* @param {Function} [callback] The optional handler when an event is triggered, if no callback
* is set then all listeners by type are removed
* @return {Bellhop} Return instance of current object
*/
p.off = function(type, callback)
{
if (type === undefined)
{
//remove all listeners
this._listeners = {};
return this;
}
if (this._listeners[type] === undefined)
{
return this;
Expand Down
4 changes: 2 additions & 2 deletions dist/bellhop.min.js

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

2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bellhop",
"version": "1.1.3",
"version": "1.1.4",
"description": "Javascript event-based communication layer between DOM and iframe.",
"url": "https://github.com/CloudKidStudio/Bellhop",
"output": "bellhop",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.1.3",
"version": "1.1.4",
"dependencies": {
"grunt": "~0.4.5",
"library-grunt": "*"
Expand Down
8 changes: 7 additions & 1 deletion src/Bellhop.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,19 @@
/**
* Remove an event listener
* @method off
* @param {String} type The type of event to listen for
* @param {String} type The type of event to listen for. If undefined, remove all listeners.
* @param {Function} [callback] The optional handler when an event is triggered, if no callback
* is set then all listeners by type are removed
* @return {Bellhop} Return instance of current object
*/
p.off = function(type, callback)
{
if (type === undefined)
{
//remove all listeners
this._listeners = {};
return this;
}
if (this._listeners[type] === undefined)
{
return this;
Expand Down

0 comments on commit 7aa3eb7

Please sign in to comment.