
define('wikia.pageShare',['wikia.window','wikia.tracker','wikia.log','jquery'],function(win,tracker,log,$){'use strict';var trackFunc=tracker.buildTrackingFunction({action:win.Wikia.Tracker.ACTIONS.CLICK,category:'social-share',trackingMethod:'analytics'});function shareLinkClick(event){event.stopPropagation();event.preventDefault();var service=$(event.target).closest('a'),url=service.prop('href'),title=service.prop('title'),h=Math.floor(win.innerHeight/2),w=Math.floor(win.innerWidth/2);trackFunc({label:service.data('share-service')});win.open(url,title,'width='+w+',height='+h);}
function appendShareIcons(data){if(data.socialIcons){var url=encodeURIComponent(win.location.origin+win.location.pathname),title=encodeURIComponent(win.document.title),description=encodeURIComponent($('meta[property="og:description"]').attr('content'));$('#PageShareContainer').html(data.socialIcons.replace(/\$url/g,url).replace(/\$title/g,title).replace(/\$description/g,description)).on('click','.page-share a',shareLinkClick);}}
function loadShareIcons(){var mCacheQueryStringParam=$.getUrlVar('mcache'),requestData={lang:getShareLang($.getUrlVar('uselang')),isTouchScreen:win.Wikia.isTouchScreen()?1:0};if(mCacheQueryStringParam){requestData.mcache=mCacheQueryStringParam;}
$.nirvana.sendRequest({type:'GET',controller:'PageShare',method:'getShareIcons',data:requestData,callback:appendShareIcons});}
function getShareLang(useLangQueryStringParam){if(useLangQueryStringParam){return useLangQueryStringParam;}else if(win.wgUserName){return win.wgUserLanguage;}else if(win.navigator.languages){return win.navigator.languages[0].substr(0,2);}else if(win.navigator.language){return win.navigator.language.substr(0,2);}else if(win.navigator.userLanguage){return win.navigator.userLanguage.substr(0,2);}else{log('Couldn\'t pick a language for Page Share extension.',log.levels.debug,'PageShare');return null;}}
return{loadShareIcons:loadShareIcons,getShareLang:getShareLang};});;require(['wikia.pageShare','jquery'],function(pageShare,$){'use strict';$(function(){pageShare.loadShareIcons();});});;