2,664
edits
(remove conditional load of Adobe A/B testing code to prevent load errors and delays on the Main Page) |
m (Updated to latest version of common.js with new landing page changes in place.) |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// test if we're on the home page | |||
if (/Main_Page/.test(document.location.href)) { | |||
$("#firstHeading").css("textAlign", "center","border", "0"); | |||
} | |||
/* Adobe Analytics added 2019-05-16 */ | /* Adobe Analytics added 2019-05-16 */ | ||
Line 296: | Line 301: | ||
/* code for new landing page */ | /* code for new landing page */ | ||
if (/Main_Page/.test(document.location.href)) { | // test if we're on the home page | ||
if ( /Main_Page/.test(document.location.href) ) { | |||
$("#firstHeading").css("border", "0", "textAlign", "center"); | |||
} | |||
/** | |||
* Conditional include of Map Menus data structure | |||
* and all the Map Menus functionality | |||
* - only for pages with 'Main Page' in the title | |||
*/ | |||
// test if we're on the home page & on beta | |||
if ( /Main_Page/.test(document.location.href) ) { | |||
// console.log('loading menus data'); | |||
mw.loader.load('/wiki/en/index.php?title=MediaWiki:MapMenu.js&action=raw&ctype=text/javascript'); | |||
// | /** | ||
* Attach a click handler to our buttons to show the "countries" menus | |||
*/ | |||
// | $('[id$=_button]').click(function () { | ||
// show the menu in case it's hidden | |||
$("#menu").show(); | |||
var position = this.id.indexOf('_button'); | |||
var name = this.id.substring(0, position); | |||
name += "_countries"; | |||
// console.log ("showing list for " + name); | |||
if (name == 'all_countries_countries') { | |||
showAllCountries(); | |||
} else { | |||
showList(name); | |||
} | |||
}); | |||
/** | |||
* Attach a click handler to "links" (spans with class .menulink) in the menus. | |||
* Because the menus are dynamic, we use a "delegated" event handler | |||
* with jQuery's .on() | |||
* https://api.jquery.com/on/ | |||
*/ | |||
$("#menu").on("click", ".menulink", function () { | |||
// console.log( $( this ).text() ); | |||
// find out what menu to show | |||
var menu = $(this).text().toLowerCase(); | |||
// replace all the blanks | |||
menu = menu.replace(/ /g, "_"); | |||
menu = menu + "_states"; | |||
// console.log("showing menu for " + menu); | |||
showList(menu); | |||
}); | |||
/** | |||
* Add an event listener to state and country menus | |||
* so that clicking the red [x] will close the menu. | |||
*/ | |||
$("#menu").on("click", ".exit", function () { | |||
var menu = $(".exit").parent().attr("parent"); | |||
if (menu) { | |||
showList(menu); | |||
} else { | |||
//showAllCountries(); | |||
$("#menu").hide(); | |||
} | |||
$("# | |||
} | |||
}); | }); | ||
} | } | ||
/* end code for landing page*/ | /* end code for landing page*/ |
edits