mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2025-01-09 12:44:16 +00:00
25 lines
587 B
JavaScript
25 lines
587 B
JavaScript
|
( function ( mw ) {
|
||
|
|
||
|
/**
|
||
|
* Creates an instance of the render change listener.
|
||
|
*
|
||
|
* @return {ext.popups.ChangeListener}
|
||
|
*/
|
||
|
mw.popups.changeListeners.render = function () {
|
||
|
var preview;
|
||
|
|
||
|
return function ( prevState, state ) {
|
||
|
if ( state.preview.fetchResponse && !preview ) {
|
||
|
preview = mw.popups.renderer.render( state.preview.fetchResponse );
|
||
|
preview.show( state.preview.activeEvent );
|
||
|
} else if ( prevState && prevState.preview.fetchResponse ) {
|
||
|
preview.hide()
|
||
|
.done( function () {
|
||
|
preview = undefined;
|
||
|
} );
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
}( mediaWiki ) );
|