2019-07-05 22:21:34 +00:00
|
|
|
module.exports = function () {
|
|
|
|
var config = mw.config,
|
|
|
|
shareIcon = require( './shareIcon.js' ),
|
|
|
|
trackShare = require( './trackShare.js' ),
|
2018-09-17 23:37:57 +00:00
|
|
|
features = config.get( 'wgMinervaFeatures', {} );
|
|
|
|
|
|
|
|
/**
|
2019-01-03 23:26:54 +00:00
|
|
|
* Checks whether shareIcon is available for given user agent
|
2018-09-17 23:37:57 +00:00
|
|
|
*
|
|
|
|
* @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.
|
2019-03-15 22:37:11 +00:00
|
|
|
$( '<li>' ).addClass( 'page-actions-menu__list-item' )
|
|
|
|
.append( shareIcon( navigator ).$el )
|
2019-04-03 23:32:18 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2019-03-15 22:37:11 +00:00
|
|
|
.insertAfter( $( '#ca-watch' ).parent() );
|
|
|
|
trackShare( 'shownShareButton' );
|
2018-09-17 23:37:57 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 22:21:34 +00:00
|
|
|
};
|