Skip to content

Commit 86de757

Browse files
author
Gabriel Schulhof
committed
[popup] Get rid of _globalHandlers and use ._on() instead
1 parent d9fb58c commit 86de757

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

js/widgets/popup.js

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,7 @@ define( [ "jquery",
188188
_isOpen: false,
189189
_tolerance: null,
190190
_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
202192
});
203193

204194
$.each( this.options, function( key, value ) {
@@ -210,8 +200,10 @@ define( [ "jquery",
210200

211201
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
212202

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" )
215207
});
216208
},
217209

@@ -655,26 +647,17 @@ define( [ "jquery",
655647
},
656648

657649
_destroy: function() {
658-
var self = this;
659-
660650
// hide and remove bindings
661-
self._close();
651+
this._close();
662652

663653
// 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 )
667657
.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();
678661
},
679662

680663
// any navigation event after a popup is opened should close the popup

0 commit comments

Comments
 (0)