Merge "Hygiene: Remove unnecessary IIFE in changeListeners/render.js"

This commit is contained in:
jenkins-bot 2017-02-20 17:30:02 +00:00 committed by Gerrit Code Review
commit 8097314077
3 changed files with 18 additions and 20 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,23 +1,21 @@
( function ( mw ) {
var renderer = require( '../renderer' );
/**
* Creates an instance of the render change listener.
*
* @param {ext.popups.PreviewBehavior} previewBehavior
* @return {ext.popups.ChangeListener}
*/
module.exports = function ( previewBehavior ) {
var preview;
/**
* Creates an instance of the render change listener.
*
* @param {ext.popups.PreviewBehavior} previewBehavior
* @return {ext.popups.ChangeListener}
*/
module.exports = function ( previewBehavior ) {
var preview;
return function ( prevState, state ) {
if ( state.preview.shouldShow && !preview ) {
preview = mw.popups.renderer.render( state.preview.fetchResponse );
preview.show( state.preview.activeEvent, previewBehavior );
} else if ( !state.preview.shouldShow && preview ) {
preview.hide();
preview = undefined;
}
};
return function ( prevState, state ) {
if ( state.preview.shouldShow && !preview ) {
preview = renderer.render( state.preview.fetchResponse );
preview.show( state.preview.activeEvent, previewBehavior );
} else if ( !state.preview.shouldShow && preview ) {
preview.hide();
preview = undefined;
}
};
}( mediaWiki ) );
};