MinervaNeue/resources/skins.minerva.options/ShareIcon.js
Piotr Miazga 51b6e8209b Add share icon as mobile web beta feature
Add a new beta feature - share icon. When user opts into beta
the share icon will be visible on supported devices (Android OS
and Chrome browser).

Bug: T181195
Change-Id: Ie4b9dd05eea9b63422bd174048d8b1251cb02bf4
2018-10-12 22:08:28 +02:00

42 lines
906 B
JavaScript

( function ( M, msg, config ) {
var GLYPH = 'share',
Icon = M.require( 'mobile.startup/Icon' );
/**
* A download icon for triggering print functionality
* @class ShareIcon
* @extends Icon
* @constructor
*/
function ShareIcon() {
var options = {};
options.tagName = 'li';
options.glyphPrefix = 'minerva';
options.title = msg( 'skin-minerva-share' );
options.name = GLYPH;
Icon.call( this, options );
}
OO.mfExtend( ShareIcon, Icon, {
/**
* onClick handler for button that invokes print function
*
* @memberof ShareIcon
* @instance
*/
onClick: function () {
navigator.share( {
title: config.get( 'wgTitle' ),
text: config.get( 'wgTitle' ),
url: window.location.href.split( '#' )[ 0 ]
} );
},
events: {
click: 'onClick'
}
} );
M.define( 'skins.minerva.share/ShareIcon', ShareIcon );
}( mw.mobileFrontend, mw.msg, mw.config ) );