From 137d8b91da577d74dc9a18aa2484cffa08941fbc Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Thu, 31 Mar 2016 10:09:36 +0300 Subject: [PATCH 1/6] Update jquery.ba-outside-events.js --- jquery.ba-outside-events.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/jquery.ba-outside-events.js b/jquery.ba-outside-events.js index 62e83e4..efd9814 100644 --- a/jquery.ba-outside-events.js +++ b/jquery.ba-outside-events.js @@ -1,5 +1,5 @@ /*! - * jQuery outside events - v1.1 - 3/16/2010 + * jQuery outside events - v1.2 - 3/16/2010 * http://benalman.com/projects/jquery-outside-events-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman @@ -9,6 +9,7 @@ // Script: jQuery outside events // +// *Version: 1.2, Last updated: 3/31/2016* // *Version: 1.1, Last updated: 3/16/2010* // // Project Home - http://benalman.com/projects/jquery-outside-events-plugin/ @@ -44,6 +45,7 @@ // // About: Release History // +// 1.2 - Use "elems" variable as pure JS array and not jQuery array to avoid memory leak when invoking the "not" method on it // 1.1 - (3/16/2010) Made "clickoutside" plugin more general, resulting in a // whole new plugin with more than a dozen default "outside" events and // a method that can be used to add new ones. @@ -122,7 +124,7 @@ // A jQuery object containing all elements to which the "outside" event is // bound. - var elems = $(), + var elems = new Array(), // The "originating" event, namespaced for easy unbinding. event_namespaced = event_name + '.' + outside_event_name + '-special-event'; @@ -165,12 +167,12 @@ // Add this element to the list of elements to which this "outside" // event is bound. - elems = elems.add( this ); + elems.push( this ); // If this is the first element getting the event bound, bind a handler // to document to catch all corresponding "originating" events. if ( elems.length === 1 ) { - $(doc).bind( event_namespaced, handle_event ); + $(doc).on( event_namespaced, handle_event ); } }, @@ -180,12 +182,15 @@ // Remove this element from the list of elements to which this // "outside" event is bound. - elems = elems.not( this ); + var elemIndex = $.inArray(this, elems); + if ( elemIndex !== -1 ) { + elems.splice( elemIndex, 1 ); + } // If this is the last element removed, remove the "originating" event // handler on document that powers this "outside" event. if ( elems.length === 0 ) { - $(doc).unbind( event_namespaced ); + $(doc).off( event_namespaced ); } }, From f978dfe59c7d82d87f025a89d8940bfd8a95aec3 Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Thu, 31 Mar 2016 10:11:39 +0300 Subject: [PATCH 2/6] Update jquery.ba-outside-events.js --- jquery.ba-outside-events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.ba-outside-events.js b/jquery.ba-outside-events.js index efd9814..e4954a3 100644 --- a/jquery.ba-outside-events.js +++ b/jquery.ba-outside-events.js @@ -1,5 +1,5 @@ /*! - * jQuery outside events - v1.2 - 3/16/2010 + * jQuery outside events - v1.2 - 3/31/2016 * http://benalman.com/projects/jquery-outside-events-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman @@ -9,7 +9,7 @@ // Script: jQuery outside events // -// *Version: 1.2, Last updated: 3/31/2016* +// *Version: 1.2, Last updated: 3/31/2016, By: TomerSH17* // *Version: 1.1, Last updated: 3/16/2010* // // Project Home - http://benalman.com/projects/jquery-outside-events-plugin/ From d7823238fd665c2f17ebe3330b4f670f0f10798b Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Sun, 3 Apr 2016 12:23:05 +0300 Subject: [PATCH 3/6] Update jquery.ba-outside-events.js --- jquery.ba-outside-events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.ba-outside-events.js b/jquery.ba-outside-events.js index e4954a3..4e9786d 100644 --- a/jquery.ba-outside-events.js +++ b/jquery.ba-outside-events.js @@ -1,6 +1,6 @@ /*! * jQuery outside events - v1.2 - 3/31/2016 - * http://benalman.com/projects/jquery-outside-events-plugin/ + * https://github.com/TomerSH17/jquery-outside-events * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. From 37146265d19de07dd0df5e72543a0435078f9a69 Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Sun, 3 Apr 2016 12:26:43 +0300 Subject: [PATCH 4/6] Update README.markdown --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index 785e771..88e4a7f 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,9 @@ # jQuery outside events # [http://benalman.com/projects/jquery-outside-events-plugin/](http://benalman.com/projects/jquery-outside-events-plugin/) +Version: 1.2, Last updated: 3/31/2016, By: TomerSH17 +Remove jQuery array and use pure JS array in order to avoid the memory leak that exists in "not" method when the jQuery array is used + Version: 1.1, Last updated: 3/16/2010 With jQuery outside events you can bind to an event that will be triggered only when a specific "originating" event occurs *outside* the element in question. For example, you can click outside, double-click outside, mouse-over outside, focus outside (and over ten more default "outside" events). Also, if an outside event hasn't been provided by default, you can easily define your own. From c65060d4e4340b114d5b08bf174b2ce2d4259740 Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Sun, 3 Apr 2016 12:27:22 +0300 Subject: [PATCH 5/6] Update README.markdown --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index 88e4a7f..92195f0 100644 --- a/README.markdown +++ b/README.markdown @@ -44,6 +44,7 @@ Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1. ## Release History ## +1.2 - (3/31/2016) Remove jQuery array and use pure JS array in order to avoid the memory leak that exists in "not" method when the jQuery array is used. 1.1 - (3/16/2010) Made "clickoutside" plugin more general, resulting in a whole new plugin with more than a dozen default "outside" events and a method that can be used to add new ones. 1.0 - (2/27/2010) Initial release From b3f6250a5f7368ceabca160b31184f6bd6abbccf Mon Sep 17 00:00:00 2001 From: Tomer Shroitman Date: Sun, 3 Apr 2016 12:27:44 +0300 Subject: [PATCH 6/6] Update README.markdown --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 92195f0..0d6770e 100644 --- a/README.markdown +++ b/README.markdown @@ -44,7 +44,7 @@ Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1. ## Release History ## -1.2 - (3/31/2016) Remove jQuery array and use pure JS array in order to avoid the memory leak that exists in "not" method when the jQuery array is used. +1.2 - (3/31/2016) Remove jQuery array and use pure JS array in order to avoid the memory leak that exists in "not" method when the jQuery array is used. 1.1 - (3/16/2010) Made "clickoutside" plugin more general, resulting in a whole new plugin with more than a dozen default "outside" events and a method that can be used to add new ones. 1.0 - (2/27/2010) Initial release