MediaWiki:Mobile.js: Difference between revisions

remove leading space for Adobe Analytics; Add gratuitous amounts of prototype Main Page code that may not all apply to mobile version
(Add Adobe Analytics for Mobile site)
 
(remove leading space for Adobe Analytics; Add gratuitous amounts of prototype Main Page code that may not all apply to mobile version)
Line 1: Line 1:
/* Any JavaScript here will be loaded for users using the mobile site */
/* Any JavaScript here will be loaded for users using the mobile site */
/* Adobe Analytics added 2019-05-16 */
/* Adobe Analytics added 2019-05-16 */
        window.utag_data={
window.utag_data={
            'site_id': 'FamilySearch',
    'site_id': 'FamilySearch',
'page_channel': 'Wiki',
    'page_channel': 'Wiki',
            'page_detail': document.location.pathname, //'Home' for the homepage or a unique page title for other pages
    'page_detail': document.location.pathname, //'Home' for the homepage or a unique page title for other pages
};
};


        (function(a,b,c,d){
(function(a,b,c,d){
            a='//tags.tiqcdn.com/utag/lds/familysearch/prod/utag.js';
    a='//tags.tiqcdn.com/utag/lds/familysearch/prod/utag.js';
            b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
    b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
            a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a);
    a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a);
         })();
})();
       
/* Any JavaScript here will be loaded for users using the mobile site */
// test if we're on the home page
if (/Main_Page/.test(document.location.href)) {
    var el = document.querySelector('#firstHeading');
    el.style.border = "0";
    el.style.textAlign = "center";
 
 
    // By wrapping the code block in $() we get the same behavior as using
    // document).ready(function () { }
    $(function () {
        // start off with hiding Countries and States
        hideCountries();
        hideStates();
 
        // https://api.jquery.com/category/selectors/
        // attach to elements ending with _list
        $('[id$=_list]').click(function () {
            hideCountries();
            $("#countries_list").hide();
            hideStates();
            // show the corresponding country
            var position = this.id.indexOf('_list');
            var target = this.id.substring(0, position);
            var myId = '#' + target + '_countries';
            $(myId).show(200);
            var thisExitMenu = "#exit_menu_" + target + '_countries';
            //console.log("showing exit menu " + thisExitMenu);
            $(thisExitMenu).show();
         });
 
        // attach to elements ending with _list2
        $('[id$=_list2]').click(function (e) {
            // show the corresponding states
            var position = this.id.indexOf('_list2');
            var target = this.id.substring(0, position);
            var myId = '#' + target + '_states';
            //console.log("You clicked a list2; showing " + myId)
            $(myId).show(200);
            // stop the bubble which would hide all states
            e.stopPropagation();
            // since we stop the bubble, make sure countries_list is hidden
            $("#countries_list").hide();
        });
 
        // clicking any class="exit_menu" hides all states
        // and hides the all_countries_countries div
        // and hides any open _countries div
        // and shows the primary countries_list
        $('.exit_menu').click(function () {
            hideStates();
            $("#all_countries_countries").hide();
            // hide any open countries list
            $( '[id$=_countries]' ).map( function( index, element ) {
                if (element.style.display == "block") {
                    $(element).hide();
                }
            });
            $("#countries_list").show();
        });
       
        // attach to any id with exit_menu at the start
        $('[id^=exit_menu]').click(function () {
            // hide the corresponding _countries
            var target = this.id.substring(10);
            var myId = '#' + target;
            //console.log("You clicked an exit_menu for " + this.id);
            //console.log("Hiding " + myId + " and showing the countries_list");
            $(myId).hide();
            // show the countries_list
            $("#countries_list").show(200);
        });
    });
 
}
function hideCountries() {
    $('[id$=_countries]').hide();
}
 
function hideStates() {
    $('[id$=_states]').hide();
}
53,890

edits