mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 22:25:27 +00:00
b9862d7d24
I want to remove the need for M.define in the Minerva repository. It's no longer necessary with packageFiles and will help tame a lot of the code we have here! Change-Id: If6a35a23e84a44adb965fd9c41265ba37eb8368e
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
( function ( M, msg, config ) {
|
|
var Icon = M.require( 'mobile.startup' ).Icon,
|
|
trackShare = require( './trackShare.js' );
|
|
|
|
/**
|
|
* Generate a mouse event that when run
|
|
* shares the current url with the current page title as the title and text
|
|
* @param {Navigator} navigator object with method share
|
|
* @return {Function} mouse event click handler
|
|
*/
|
|
function clickShareHandler( navigator ) {
|
|
return function () {
|
|
var url = new URL( window.location.href );
|
|
url.searchParams.append( 'wprov', 'mfsw1' );
|
|
url.searchParams.delete( 'debug' );
|
|
trackShare( 'clickShareButton' );
|
|
navigator.share( {
|
|
title: config.get( 'wgTitle' ),
|
|
text: config.get( 'wgTitle' ),
|
|
url: url.toString()
|
|
} ).then( function () {
|
|
trackShare( 'SharedToApp' );
|
|
} );
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Generate a share icon for sharing pages using the navigation share API
|
|
*
|
|
* @param {Navigator} navigator object with method share
|
|
* @return {Icon}
|
|
*/
|
|
function shareIcon( navigator ) {
|
|
return new Icon( {
|
|
tagName: 'button',
|
|
glyphPrefix: 'minerva',
|
|
title: msg( 'skin-minerva-share' ),
|
|
name: 'share',
|
|
events: {
|
|
click: clickShareHandler( navigator )
|
|
}
|
|
} );
|
|
}
|
|
|
|
module.exports = shareIcon;
|
|
}( mw.mobileFrontend, mw.msg, mw.config ) );
|