User:Jkatz (WMF)/social.js

/* * Adds option to share link to the current page in social networks and email * Written by he:User:ערן * */

$( document ).ready( function {	var shareLabel, emailLabel, socialShares;

shareLabel = 'שיתוף'; emailLabel = 'דוא\"ל';

socialShares = [ {			'title': emailLabel, 'url': 'mailto:?subject=' + encodeURIComponent( mw.config.get('wgPageName') ) + '&body=' + mw.config.get('wgServer') + '/wiki/' + encodeURIComponent( mw.config.get('wgPageName') ), 'img': '//upload.wikimedia.org/wikipedia/commons/4/42/Icon_External_Link_E-Mail.png' },		{			'title': 'facebook', 'url': 'http://www.facebook.com/sharer.php?u=' + mw.config.get('wgServer') + '/wiki/' + encodeURIComponent( mw.config.get('wgPageName') ) + '&t=' + encodeURIComponent( mw.config.get('wgPageName') ), 'img': '//upload.wikimedia.org/wikinews/en/5/55/Facebook.png' },		{			'title': 'twitter', 'url': 'http://twitter.com/?status=' + encodeURIComponent( 'ראו ערך: \n' + mw.config.get('wgPageName') + '\nבוויקיפדיה' ), 'img': '//upload.wikimedia.org/wikinews/en/f/f7/Twitter.png' }	];

try { var $whatLinksItem, $shareText, $item;

$whatLinksItem = $( '#t-whatlinkshere' );

if ( !$whatLinksItem.length ) { return; }		$shareText = $( ' ' ).text( shareLabel + ':' );

$( socialShares ).each( function {			var $socialSpan, $socialA, $socialImg;

$socialSpan = $( ' ' ); $socialA = $( '', { href: this.url, title: this.title } );

if ( this.title !== emailLabel ) { $socialA.click( function {					window.open( this.href, shareLabel, 'toolbar=0,status=0,resizable=1,width=550,height=400' );

return false; } );			}

$socialImg = $( ' ', { 'src': this.img } ); $socialA.append( $socialImg ); $socialSpan.append( $socialA ); $shareText.append( $socialSpan ); } );

$item = $( '', { id: 't-socialShare' } ); $item.append( $shareText ); $whatLinksItem.before( $item ); }	catch( e ) { return;     // lets just ignore what's happened } } );