mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 11:13:34 +00:00
8a844a9699
Apply provenance parameter to all shared links via Share api. Bug: T207280 Change-Id: I175dcd45bd25f6ed21f06eeecfc22d97bd5a210a
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
( function ( M, msg, config ) {
|
|
var Icon = M.require( 'mobile.startup' ).Icon;
|
|
|
|
/**
|
|
* 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' );
|
|
navigator.share( {
|
|
title: config.get( 'wgTitle' ),
|
|
text: config.get( 'wgTitle' ),
|
|
url: url.toString()
|
|
} );
|
|
};
|
|
}
|
|
|
|
/**
|
|
* 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: 'li',
|
|
glyphPrefix: 'minerva',
|
|
title: msg( 'skin-minerva-share' ),
|
|
name: 'share',
|
|
events: {
|
|
click: clickShareHandler( navigator )
|
|
}
|
|
} );
|
|
}
|
|
|
|
M.define( 'skins.minerva.share/shareIcon', shareIcon );
|
|
}( mw.mobileFrontend, mw.msg, mw.config ) );
|