mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-12 08:58:25 +00:00
5593b23aa8
Replace all occurrences of `M.require( 'mobile.startup/pathToModule' )` with `M.require( 'mobile.startup' ).pathToModule`. Where multiple requires existed, add an intermediate variable, `var mobile = M.require( 'mobile.startup' )`, and dot off that. This changes improves the consistency of MinervaNeue which currently contains a mix of require styles and eliminates any deprecated requires. Bug: T208915 Change-Id: If14f280672d914d07275197100b12421bb217b67
40 lines
1 KiB
JavaScript
40 lines
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 () {
|
|
navigator.share( {
|
|
title: config.get( 'wgTitle' ),
|
|
text: config.get( 'wgTitle' ),
|
|
url: window.location.href.split( '#' )[ 0 ]
|
|
} );
|
|
};
|
|
}
|
|
|
|
/**
|
|
* 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 ) );
|