mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-29 13:17:35 +00:00
Replace addEventListener call with jQuery's .on()
Bug: 70553 Change-Id: I24680e7b7759d30eca2a733d670e10c0b4bfe7ab Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/863
This commit is contained in:
parent
d4666c5715
commit
b70fa7251d
|
@ -172,13 +172,9 @@
|
|||
C.attach = function() {
|
||||
var canvas = this;
|
||||
|
||||
// TODO: Try to use Element.handleEvent() instead !
|
||||
if ( !this.resizeListener ) {
|
||||
this.resizeListener = function () {
|
||||
canvas.$mainWrapper.trigger( $.Event( 'mmv-resize') );
|
||||
};
|
||||
window.addEventListener( 'resize', this.resizeListener );
|
||||
}
|
||||
$( window ).on( 'resize.mmv-canvas', function () {
|
||||
canvas.$mainWrapper.trigger( $.Event( 'mmv-resize' ) );
|
||||
} );
|
||||
|
||||
this.$imageDiv.on( 'click.mmv-canvas', 'img', function () {
|
||||
canvas.$mainWrapper.trigger( $.Event( 'mmv-image-click' ) );
|
||||
|
@ -191,10 +187,7 @@
|
|||
C.unattach = function() {
|
||||
this.clearEvents();
|
||||
|
||||
if ( this.resizeListener ) {
|
||||
window.removeEventListener( 'resize', this.resizeListener );
|
||||
this.resizeListener = null;
|
||||
}
|
||||
$( window ).off( 'resize.mmv-canvas' );
|
||||
|
||||
this.$imageDiv.off( 'click.mmv-canvas' );
|
||||
|
||||
|
|
|
@ -99,21 +99,6 @@
|
|||
assert.strictEqual( canvas.$image.css( 'maxHeight' ), canvas.$imageDiv.height() + 'px', 'MaxHeight set correctly.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'attach and unattach', 3, function( assert ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
canvas = new mw.mmv.ui.Canvas( $qf );
|
||||
|
||||
assert.ok( ! canvas.resizeListener, 'resize listener has not been set yet.' );
|
||||
|
||||
canvas.attach();
|
||||
|
||||
assert.ok( canvas.resizeListener, 'resize listener is set.' );
|
||||
|
||||
canvas.unattach();
|
||||
|
||||
assert.ok( ! canvas.resizeListener, 'resize listener has been removed.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: Constrained area for SVG files', 4, function ( assert ) {
|
||||
var $image,
|
||||
blurredThumbnailShown,
|
||||
|
|
Loading…
Reference in a new issue