2016-11-21 12:07:23 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an instance of the render change listener.
|
|
|
|
*
|
2016-11-28 12:00:07 +00:00
|
|
|
* @param {Object} boundActions
|
2016-11-21 12:07:23 +00:00
|
|
|
* @return {ext.popups.ChangeListener}
|
|
|
|
*/
|
2016-11-28 12:00:07 +00:00
|
|
|
mw.popups.changeListeners.render = function ( boundActions ) {
|
2016-11-21 12:07:23 +00:00
|
|
|
var preview;
|
|
|
|
|
|
|
|
return function ( prevState, state ) {
|
2016-11-25 12:42:02 +00:00
|
|
|
if ( state.preview.shouldShow && !preview ) {
|
2016-11-21 12:07:23 +00:00
|
|
|
preview = mw.popups.renderer.render( state.preview.fetchResponse );
|
2016-11-28 12:00:07 +00:00
|
|
|
preview.show( state.preview.activeEvent, boundActions );
|
2016-11-25 12:42:02 +00:00
|
|
|
} else if ( !state.preview.shouldShow && preview ) {
|
2016-11-21 12:07:23 +00:00
|
|
|
preview.hide()
|
|
|
|
.done( function () {
|
|
|
|
preview = undefined;
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}( mediaWiki ) );
|