mediawiki-skins-MinervaNeue/resources/skins.minerva.options/share.js
James D. Forrester 75a751f1c6 build: Upgrade eslint-config-wikimedia from 0.10.1 to 0.11.0
Change-Id: I36a88cbf8b468646c21d47c3b58433895e8ff31a
2019-04-04 18:01:40 +00:00

29 lines
1 KiB
JavaScript

( function ( M, config ) {
var shareIcon = M.require( 'skins.minerva.share/shareIcon' ),
trackShare = M.require( 'skins.minerva.share/track' ),
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' );
}
}( mw.mobileFrontend, mw.config ) );