Skip to content
This repository
Browse code

[popup] Get rid of _globalHandlers and use ._on() instead

commit 86de757a4b4a4fd97cbfd6effecfdf059fd07fe3 1 parent d9fb58c
Gabriel "_|Nix|_" Schulhof gabrielschulhof authored

Showing 1 changed file with 12 additions and 29 deletions. Show diff stats Hide diff stats

  1. +12 29 js/widgets/popup.js
41 js/widgets/popup.js
@@ -188,17 +188,7 @@ define( [ "jquery",
188 188 _isOpen: false,
189 189 _tolerance: null,
190 190 _resizeData: null,
191   - _orientationchangeInProgress: false,
192   - _globalHandlers: [
193   - {
194   - src: $( window ),
195   - handler: {
196   - orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
197   - resize: $.proxy( this, "_handleWindowResize" ),
198   - keyup: $.proxy( this, "_handleWindowKeyUp" )
199   - }
200   - }
201   - ]
  191 + _orientationchangeInProgress: false
202 192 });
203 193
204 194 $.each( this.options, function( key, value ) {
@@ -210,8 +200,10 @@ define( [ "jquery",
210 200
211 201 ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
212 202
213   - $.each( this._globalHandlers, function( idx, value ) {
214   - value.src.bind( value.handler );
  203 + this._on( $( window ), {
  204 + orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
  205 + resize: $.proxy( this, "_handleWindowResize" ),
  206 + keyup: $.proxy( this, "_handleWindowKeyUp" )
215 207 });
216 208 },
217 209
@@ -655,26 +647,17 @@ define( [ "jquery",
655 647 },
656 648
657 649 _destroy: function() {
658   - var self = this;
659   -
660 650 // hide and remove bindings
661   - self._close();
  651 + this._close();
662 652
663 653 // Put the element back to where the placeholder was and remove the "ui-popup" class
664   - self._setTheme( "none" );
665   - self.element
666   - .insertAfter( self._ui.placeholder )
  654 + this._setTheme( "none" );
  655 + this.element
  656 + .insertAfter( this._ui.placeholder )
667 657 .removeClass( "ui-popup ui-overlay-shadow ui-corner-all" );
668   - self._ui.screen.remove();
669   - self._ui.container.remove();
670   - self._ui.placeholder.remove();
671   -
672   - // Unbind handlers that were bound to elements outside self.element (the window, in self case)
673   - $.each( self._globalHandlers, function( idx, oneSrc ) {
674   - $.each( oneSrc.handler, function( eventType, handler ) {
675   - oneSrc.src.unbind( eventType, handler );
676   - });
677   - });
  658 + this._ui.screen.remove();
  659 + this._ui.container.remove();
  660 + this._ui.placeholder.remove();
678 661 },
679 662
680 663 // any navigation event after a popup is opened should close the popup

0 comments on commit 86de757

Please sign in to comment.
Something went wrong with that request. Please try again.