Fandom

BUSTY RESOURCES

SocialIcons/code.js

240pages on
this wiki
Add New Page
Comments0 Share
//
/* Social Media buttons script */
/* Partially from http://dev.wikia.com/wiki/ShowHide/code.js by Daniel Friesen and others */
// Namespaces the buttons should be loaded on
if (!$.isArray(window.SocialMediaButtonsNamespaces)) {
    window.SocialMediaButtonsNamespaces = [0, 6, 14, 500];
}
 
// Check namespace of article, cross-reference with namespaces entered
if (SocialMediaButtonsNamespaces.indexOf(mediaWiki.config.get('wgNamespaceNumber')) > -1) {
    (function ($, mw, Wikia) {
        "use strict";
        //Configuration
        var config = window.SocialMediaButtons = $.extend(true, {
            position: 'top', //Position of the buttons: "top" or "bottom"
            colorScheme: 'dark', //Color scheme of the buttons: "dark", "light" or "color"
            buttonSize: 'default', //Button size: "default" or "#px"
            wikiTwitterAccount: 'default', //Wiki Twitter account: "default" or "accountname"
            userLang: true, //i18n settings: "true"
            // German
            de: {
                google: "Teile diesen Artikel auf Google+",
                facebook: "Teile diesen Artikel auf Facebook",
                twitter: "Teile diesen Artikel auf Twitter",
                weibo: "Teile diesen Artikel auf Weibo",
                reddit: "Teile diesen Artikel auf reddit",
                via: "via",
                twitterAccount: "Wikia",
                twitterMessage: ""
            },
            // English
            en: {
                google: "Share this on Google+",
                facebook: "Share this on Facebook",
                twitter: "Share this on Twitter",
                weibo: "Share this on Weibo",
                reddit: "Share this on reddit",
                via: "via",
                twitterAccount: "Wikia",
                twitterMessage: ""
            },
            // Spanish
            es: {
                google: "Compártelo en Google+",
                facebook: "Compártelo en Facebook",
                twitter: "Compártelo en Twitter",
                weibo: "Compártelo en Weibo",
                reddit: "Compártelo en reddit",
                via: "vía",
                twitterAccount: "Wikia_es",
                twitterMessage: ""
            },
            // French
            fr: {
                google: "Partager sur Google+",
                facebook: "Partager sur Facebook",
                twitter: "Partager sur Twitter",
                weibo: "Partager sur Weibo",
                reddit: "Partager sur reddit",
                via: "@Wikia_fr",
                twitterAccount: "Wikia_fr",
                twitterMessage: ""
            },
            // Hungarian
            hu: {
                google: "Megosztás a Google+-on",
                facebook: "Megosztás a Facebookon",
                twitter: "Megosztás a Twitteren",
                weibo: "Megosztás a Weibo-on",
                reddit: "Megosztás a reddit",
                via: "via",
                twitterAccount: "Wikia",
                twitterMessage: ""
            },
            // Japanese
            ja: {
                google: "Google+でシェアする",
                facebook: "Facebookでシェアする",
                twitter: "Twitterでシェアする",
                weibo: "Weiboでシェアする",
                reddit: "redditでシェアする",
                via: "を用いて",
                twitterAccount: "Wikia",
                twitterMessage: "+"
            },
            // Dutch
            nl: {
                google: "Deel dit op Google+",
                facebook: "Deel dit op Facebook",
                twitter: "Deel dit op Twitter",
                weibo: "Deel dit op Weibo",
                reddit: "Deel dit op reddit",
                via: "via",
                twitterAccount: "Wikia_nl",
                twitterMessage: ""
            },
            // Polish
            pl: {
                google: "Podziel się na Google+",
                facebook: "Podziel się na Facebooku",
                twitter: "Podziel się na Twitterze",
                weibo: "Podziel się na Weibo",
                reddit: "Podziel się na reddit",
                via: "przez",
                twitterAccount: "Wikia_pl",
                twitterMessage: ""
            },
            // Portuguese
            pt: {
                google: "Compartilhe no Google+",
                facebook: "Compartilhe no Facebook",
                twitter: "Compartilhe no Twitter",
                weibo: "Compartilhe no Weibo",
                reddit: "Compartilhe no reddit",
                via: "via",
                twitterAccount: "Wikia_pt",
                twitterMessage: ""
            },
            // Russian
            ru: {
                google: "Поделиться в Google+",
                facebook: "Поделиться в Facebook",
                twitter: "Поделиться в Twitter",
                weibo: "Поделиться в Weibo",
                vkontakte: "Поделиться ВКонтакте",
                reddit: "Поделиться в reddit",
                via: "с помощью",
                twitterAccount: "wikia_ru",
                twitterMessage: ""
            },
            // Chinese
            zh: {
                google: "在Google+上分享",
                facebook: "在Facebook上分享",
                twitter: "在Twitter上分享",
                weibo: "在Weibo上分享",
                reddit: "在reddit上分享",
                via: "を用いて",
                twitterAccount: "Wikia",
                twitterMessage: ""
            }
        }, window.SocialMediaButtons || {});
 
        // i18n function
        function msg(name) {
            if (config.userLang && mw.config.get('wgUserLanguage') in config && name in config[mw.config.get('wgUserLanguage')]) {
                return config[mw.config.get('wgUserLanguage')][name];
            }
            if (mw.config.get('wgContentLanguage') in config && name in config[mw.config.get('wgContentLanguage')]) {
                return config[mw.config.get('wgContentLanguage')][name];
            }
            return config.en[name];
        }
 
 
        // Image colorscheme
        if (config.colorScheme === 'light') {
            var gInactive = 'http://static.wikia.com/messaging/images/7/7c/Google%2B_Light.png',
                fbInactive = 'http://static.wikia.com/messaging/images/5/56/Facebook_Light.png',
                twitterInactive = 'http://static.wikia.com/messaging/images/b/b8/Twitter_Light.png';
            if (mw.config.get('wgContentLanguage') === "zh") {
                var weiboInactive = 'http://static.wikia.com/messaging/images/1/16/WeiboLight.png';
            }
            if (mw.config.get('wgUserLanguage') === "ru") {
                var vkInactive = 'http://img3.wikia.nocookie.net/__cb20140427110639/dev/images/d/dc/WhiteVK.png';
            }
        } else if (config.colorScheme === 'color') {
            var gInactive = 'http://static.wikia.com/messaging/images/7/74/Google%2B_Hover.png',
                fbInactive = 'http://static.wikia.com/messaging/images/2/22/Facebook_Hover.png',
                twitterInactive = 'http://static.wikia.com/messaging/images/5/5d/Twitter_Hover.png',
                redditInactive = 'https://i.imgur.com/wSwNrLB.png';
            if (mw.config.get('wgContentLanguage') === "zh") {
                var weiboInactive = 'http://static.wikia.com/messaging/images/9/93/WeiboHover.png';
            }
            if (mw.config.get('wgUserLanguage') === "ru") {
                var vkInactive = 'http://img2.wikia.nocookie.net/__cb20140426201829/stardrive/ru/images/2/27/VK_icon_active.png';
            }
        } else {
            var gInactive = 'http://static.wikia.com/messaging/images/4/45/Google%2B_Dark.png',
                fbInactive = 'http://static.wikia.com/messaging/images/8/83/Facebook_Dark.png',
                twitterInactive = 'http://static.wikia.com/messaging/images/d/d1/Twitter_Dark.png';
            if (mw.config.get('wgContentLanguage') === "zh") {
                var weiboInactive = 'http://static.wikia.com/messaging/images/8/8f/WeiboDark.png';
 
            }
            if (mw.config.get('wgUserLanguage') === "ru") {
                var vkInactive = 'http://img4.wikia.nocookie.net/__cb20140426201747/stardrive/ru/images/e/e0/VK_icon.png';
            }
        }
        var gHover = 'http://static.wikia.com/messaging/images/7/74/Google%2B_Hover.png',
            fbHover = 'http://static.wikia.com/messaging/images/2/22/Facebook_Hover.png',
            twitterHover = 'http://static.wikia.com/messaging/images/5/5d/Twitter_Hover.png',
            redditHover = 'https://i.imgur.com/wSwNrLB.png';
 
        // Pre-load the hover images to avoid delay
        var gHoverLoad = new Image(),
            fbHoverLoad = new Image(),
            twitterHoverLoad = new Image();
        gHoverLoad.src = gHover;
        fbHoverLoad.src = fbHover;
        twitterHoverLoad.src = twitterHover;
 
        if (mw.config.get('wgContentLanguage') === "zh") {
            var weiboHover = 'http://static.wikia.com/messaging/images/9/93/WeiboHover.png';
 
            var weiboHoverLoad = new Image();
            weiboHoverLoad.src = weiboHover;
        }
        if (mw.config.get('wgUserLanguage') === "ru") {
            var vkHover = 'http://img3.wikia.nocookie.net/__cb20140427110639/dev/images/2/27/VK_icon_active.png';
 
            var vkHoverLoad = new Image();
            vkHoverLoad.src = vkHover;
        }
 
        // Share URL's
        var currentURL = document.URL;
        var currentSiteName = mw.config.get('wgSiteName').replace(/ /g, "+");
        var currentPageName = mw.config.get('wgPageName').replace(/_/g, "+").replace(/"/g, "%22");
 
        if (mw.config.get('wgContentLanguage') === "zh") {
            var siteName = mw.config.get('wgSiteName');
            var sudaRef = mw.config.get('wgServer').replace(/http\:\/\//g, "");
        }
 
        var gShare = 'https://plus.google.com/share?url=' + currentURL;
        var fbShare = 'https://facebook.com/sharer/sharer.php?u=' + currentURL;
        var redditShare = 'http://www.reddit.com/submit?url=' + currentURL;
 
        if (config.wikiTwitterAccount !== 'default') {
            var twitterAcc = config.wikiTwitterAccount;
        } else {
            var twitterAcc = msg('twitterAccount');
        }
        var twitterShare = 'https://twitter.com/intent/tweet?original_referer=' + currentURL + '&text=' + currentPageName + msg('twitterMessage') + currentSiteName + '&url=' + currentURL + '&via=' + twitterAcc; + '&via=' + twitterAcc;
 
        if (mw.config.get('wgContentLanguage') === "zh") {
            var weiboShare = 'http://service.weibo.com/share/share.php?url=' + currentURL + '&title=' + siteName + '&sudaref=' + sudaRef;
        }
        if (mw.config.get('wgUserLanguage') === 'ru') {
            var vkShare = 'http://vk.com/share.php?url=' + currentURL + '&title=' + currentPageName;
        }
        //Border color, positioning and HTML for the various namespaces
        if (mediaWiki.config.get('wgNamespaceNumber') === 500) {
            var borderColor = $('#WikiaUserPagesHeader').css('border-bottom-color');
            var appendTo = '#WikiaUserPagesHeader';
            var topHTML = 'float: right; margin-top: -24px;';
        } else if (mediaWiki.config.get('wgNamespaceNumber') === 1201) {
            var borderColor = $('#mw-content-text .BreadCrumbs').css('border-bottom-color');
            var appendTo = '#mw-content-text .BreadCrumbs';
            var topHTML = 'float:right;';
        } else {
            var borderColor = $('#WikiaPageHeader').css('border-bottom-color');
            var appendTo = '#WikiaPageHeader';
            if (mediaWiki.config.get('wgPageName') === mediaWiki.config.get('wgMainPageTitle').replace(/ /g, '_')) {
                var topHTML = 'padding-top: 4px; position: absolute; top: 29px; right: 0;';
            } else {
                var topHTML = 'position: absolute; top: 29px; right: 0;';
            }
        }
 
        // Append the buttons
        $(function () {
            if (config.position === 'top') {
                if (config.buttonSize !== 'default') {
                    var buttonSizePX = config.buttonSize;
                } else {
                    var buttonSizePX = "21px";
                }
                var socialHTML = '<div style="' + topHTML + '" class="socialmedia-share top"><a target="_blank" title="' + msg("google") + '" href="' + gShare + '"><img style="cursor: pointer;" class="share-button googleplus ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + gInactive + '" /></a><a target="_blank" title="' + msg("facebook") + '" href="' + fbShare + '"><img style="cursor: pointer; padding-left: 1px;" class="share-button facebook ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + fbInactive + '" /></a><a target="_blank" title="' + msg("twitter") + '" href="' + twitterShare + '"><img style="cursor: pointer; padding-left: 1px;" class="share-button twitter ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + twitterInactive + '" /><a target="_blank" title="' + msg("reddit") + '" href="' + redditShare + '"><img style="cursor: pointer; padding-left: 1px;" class="share-button reddit ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + redditInactive + '" /></a></div>';
 
                $(appendTo).append(socialHTML);
 
                if ($('#WikiaPageHeader').length) {
                    var WikiaPageHeaderHeight = $('#WikiaPageHeader').height();
                    if (mediaWiki.config.get('wgPageName') !== mediaWiki.config.get('wgMainPageTitle').replace(/ /g, '_')) {
                        var paddingBottom = parseInt(buttonSizePX.replace('px', '')) + 5 + 'px';
                        $('#WikiaPageHeader').css('padding-bottom', paddingBottom);
                    } else if (mediaWiki.config.get('wgPageName') === mediaWiki.config.get('wgMainPageTitle').replace(/ /g, '_')) {
                        var paddingBottom = parseInt(buttonSizePX.replace('px', '')) + 8 + 'px';
                        $('#WikiaPageHeader').css('padding-bottom', paddingBottom);
                    }
                }
            } else {
                if (config.buttonSize !== 'default') {
                    var buttonSizePX = config.buttonSize;
                } else {
                    var buttonSizePX = "64px";
                }
                var socialHTML = '<section class="SocialMediaButtons" id="SocialMediaButtons" style="border-top: 1px solid ' + borderColor + '; text-align: center; margin-top: 20px;"><div style="padding-top: 1px; margin-top: 10px; text-align: center;" class="socialmedia-share bottom"><a target="_blank" title="' + msg("google") + '" href="' + gShare + '"><img style="cursor: pointer;" class="share-button googleplus ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + gInactive + '"></a><a target="_blank" title="' + msg("facebook") + '" href="' + fbShare + '"><img style="cursor: pointer; padding-left: 5px;" class="share-button facebook ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + fbInactive + '"></a><a target="_blank" title="' + msg("twitter") + '" href="' + twitterShare + '"><img style="cursor: pointer; padding-left: 5px;" class="share-button twitter ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + twitterInactive + '"></a></div></section>';
 
                $('#mw-content-text').append(socialHTML);
            }
 
            if (mw.config.get('wgContentLanguage') === "zh") {
                if (config.position === 'top') {
                    $('.socialmedia-share').prepend('<a target="_blank" title="' + msg("weibo") + '" href="' + weiboShare + '"><img style="cursor: pointer;" class="share-button weibo ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + weiboInactive + '" /></a>');
                } else {
                    $('.socialmedia-share').prepend('<a target="_blank" title="' + msg("weibo") + '" href="' + weiboShare + '"><img style="cursor: pointer;" class="share-button weibo ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + weiboInactive + '" /></a>');
                    $('.socialmedia-share .googleplus').css('padding-left', '5px');
                }
            }
            if (mw.config.get('wgUserLanguage') === 'ru') {
                if (config.position === 'top') {
                    $('.socialmedia-share').prepend('<a target="_blank" title="' + msg("vkontakte") + '" href="' + vkShare + '"><img style="cursor: pointer;" class="share-button vkontakte ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + vkInactive + '" /></a>');
                } else {
                    $('.socialmedia-share').prepend('<a target="_blank" title="' + msg("vkontakte") + '" href="' + vkShare + '"><img style="cursor: pointer;" class="share-button vkontakte ' + config.colorScheme + '" height="' + buttonSizePX + '" width="' + buttonSizePX + '" src="' + vkInactive + '" /></a>');
                    $('.socialmedia-share .googleplus').css('padding-left', '5px');
                }
            }
 
            // Change the button on hover
            $('.socialmedia-share .googleplus').hover(function () {
                $(this).attr('src', gHover);
            }, function () {
                $(this).attr('src', gInactive);
            });
            $('.socialmedia-share .facebook').hover(function () {
                $(this).attr('src', fbHover);
            }, function () {
                $(this).attr('src', fbInactive);
            });
            $('.socialmedia-share .twitter').hover(function () {
                $(this).attr('src', twitterHover);
            }, function () {
                $(this).attr('src', twitterInactive);
            });
            if (mw.config.get('wgContentLanguage') === "zh") {
                $('.socialmedia-share .weibo').hover(function () {
                    $(this).attr('src', weiboHover);
                }, function () {
                    $(this).attr('src', weiboInactive);
                });
            }
            if (mw.config.get('wgUserLanguage') === 'ru') {
                $('.socialmedia-share .vkontakte').hover(function () {
                    $(this).attr('src', vkHover);
                }, function () {
                    $(this).attr('src', vkInactive);
                });
            }
            // Pop-up instead of new window
            function createPopup(url, windowName) {
                var popupWindow = window.open(url, windowName, 'height=500,width=600,menubar=0,toolbar=0,location=1,scrollbars=1,status=1,resizable=1');
                if (window.focus) {
                    popupWindow.focus();
                }
                return false;
            }
 
            function trackClick(label, event) {
                return Wikia.Tracker.track({
                    action: Wikia.Tracker.ACTIONS.CLICK_LINK_BUTTON,
                    browserEvent: event,
                    category: 'custom-share',
                    label: label,
                    trackingMethod: 'ga'
                });
            }
 
            $('.socialmedia-share img').on('click', function (event) {
                event.preventDefault();
                var socialNetwork = $(this).attr('class');
                var socialNetworkURL = $(this).parent().attr('href');
                if (socialNetwork.indexOf('googleplus') >= 0) {
                    createPopup(socialNetworkURL, 'googleplusPopup');
                    trackClick('googleplus', event);
                } else if (socialNetwork.indexOf('facebook') >= 0) {
                    createPopup(socialNetworkURL, 'facebookPopup');
                    trackClick('facebook', event);
                } else if (socialNetwork.indexOf('twitter') >= 0) {
                    createPopup(socialNetworkURL, 'twitterPopup');
                    trackClick('twitter', event);
                } else if (socialNetwork.indexOf('weibo') >= 0) {
                    createPopup(socialNetworkURL, 'weiboPopup');
                    trackClick('weibo', event);
                } else if (socialNetwork.indexOf('reddit') >= 0) {
                    createPopup(socialNetworkURL, 'redditPopup');
                    trackClick('reddit', event);
                } else if (socialNetwork.indexOf('vkontakte') >= 0) {
                    createPopup(socialNetworkURL, 'vkPopup');
                    trackClick('vk', event);
                }
            });
        });
    }(jQuery, mediaWiki, Wikia));
}
//

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.