2019-01-03 23:26:54 +00:00
|
|
|
( function ( M, msg, config ) {
|
2019-03-15 22:37:11 +00:00
|
|
|
var Icon = M.require( 'mobile.startup' ).Icon,
|
2019-07-05 22:21:34 +00:00
|
|
|
trackShare = require( './trackShare.js' );
|
2019-01-03 23:26:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 () {
|
2019-03-15 21:46:54 +00:00
|
|
|
var url = new URL( window.location.href );
|
|
|
|
url.searchParams.append( 'wprov', 'mfsw1' );
|
|
|
|
url.searchParams.delete( 'debug' );
|
2019-03-15 22:37:11 +00:00
|
|
|
trackShare( 'clickShareButton' );
|
2019-01-03 23:26:54 +00:00
|
|
|
navigator.share( {
|
|
|
|
title: config.get( 'wgTitle' ),
|
|
|
|
text: config.get( 'wgTitle' ),
|
2019-03-15 21:46:54 +00:00
|
|
|
url: url.toString()
|
2019-03-15 22:37:11 +00:00
|
|
|
} ).then( function () {
|
|
|
|
trackShare( 'SharedToApp' );
|
2019-01-03 23:26:54 +00:00
|
|
|
} );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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( {
|
2019-03-15 22:37:11 +00:00
|
|
|
tagName: 'button',
|
2019-01-03 23:26:54 +00:00
|
|
|
glyphPrefix: 'minerva',
|
|
|
|
title: msg( 'skin-minerva-share' ),
|
|
|
|
name: 'share',
|
|
|
|
events: {
|
|
|
|
click: clickShareHandler( navigator )
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2019-07-05 22:21:34 +00:00
|
|
|
module.exports = shareIcon;
|
2019-01-03 23:26:54 +00:00
|
|
|
}( mw.mobileFrontend, mw.msg, mw.config ) );
|