mediawiki-extensions-Popups/resources/ext.popups.renderer/mobileRenderer.js
Florian c93047666e Add link preview feature to mobile beta mode
Linkpreview will try to fetch a text extract using the api and, if this
doesn't fail, show the extract as a drawer with a button "Continue to
article". If the query fails, it will redirect the user to the article
directly.

Bug: T113243
Depends-On: I6d8c5b80e70c3d8d1a92a70cc91e1b90d598cb0f
Change-Id: Idbaae9fe2decd89b73e623a25fbd39464c316fb2
2016-03-05 18:22:30 +01:00

32 lines
731 B
JavaScript

( function ( $, mw, M ) {
/**
* @class mw.popups.render
* @singleton
*/
mw.popups.render = {};
/**
* Render a new LinkPreviewDrawer
*
* @method render
* @param {Object} link
* @param {Object} event
*/
mw.popups.render.render = function ( link, event ) {
var LinkPreviewDrawer = M.require( 'ext.popups.mobilelinkpreview/LinkPreviewDrawer' );
// Ignore if its meant to call a function
// TODO: Remove this when adding reference popups
if ( link.attr( 'href' ) === '#' ) {
return;
}
if ( !mw.popups.$popup ) {
mw.popups.$popup = new LinkPreviewDrawer();
}
mw.popups.$popup.loadNew( event.target.title );
event.preventDefault();
};
} )( jQuery, mediaWiki, mediaWiki.mobileFrontend );