mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 03:08:12 +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
30 lines
1 KiB
JavaScript
30 lines
1 KiB
JavaScript
module.exports = function () {
|
|
var config = mw.config,
|
|
shareIcon = require( './shareIcon.js' ),
|
|
trackShare = require( './trackShare.js' ),
|
|
features = config.get( 'wgMinervaFeatures', {} );
|
|
|
|
/**
|
|
* Checks whether shareIcon is available for given user agent
|
|
*
|
|
* @return {boolean}
|
|
*/
|
|
function isShareAvailable() {
|
|
return navigator.share !== undefined;
|
|
}
|
|
|
|
// check if browser supports share feature and the feature is enabled
|
|
if ( isShareAvailable() && features.shareButton ) {
|
|
// Because the page actions are floated to the right, their order in the
|
|
// DOM is reversed in the display. The watchstar is last in the DOM and
|
|
// left-most in the display. Since we want the download button to be to
|
|
// the left of the watchstar, we put it after it in the DOM.
|
|
$( '<li>' ).addClass( 'page-actions-menu__list-item' )
|
|
.append( shareIcon( navigator ).$el )
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
.insertAfter( $( '#ca-watch' ).parent() );
|
|
trackShare( 'shownShareButton' );
|
|
}
|
|
|
|
};
|