MediaWiki:Common.js

From BASAbaliWiki

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */

$(function(){
	
	var $backDrop = $('.notice-alert-panel--backdrop');
	if ( $backDrop.length ) {
		var $modalWhatsup = $('.notice-alert-panel');
		var cookieTest = $.cookie("notice-alert-panel");
		var $dismissSpan = $('.notice-alert-panel--dismiss');
		if (!cookieTest) {
			$.cookie("notice-alert-panel", 1, { expires: 1 });
			$backDrop.addClass('notice-alert-panel--backdrop--active');
			$modalWhatsup.addClass('notice-alert-panel--modal');
			$dismissSpan.click(function(e){
				$backDrop.removeClass('notice-alert-panel--backdrop--active');
				$modalWhatsup.removeClass('notice-alert-panel--modal');
			});
		}
	}
	
	
	var wordleBanner = $('#wordle-banner');
	if( wordleBanner.length ) {
		wordleBanner.wrap($('<a id="wordle-banner-container" target="_blank" href="https://wordle.basabali.org/" />'));
	}
	
	var wikithonPageLinks = $('#wikithon-page-links-block a');
	if(wikithonPageLinks.length) {
		wikithonPageLinks.each(function(){
			$(this).prop('target', '');
		});
	}
	
	var puzzleAnswersToggle = $('.puzzle-page-answers-switch');
	if(puzzleAnswersToggle.length) {
		puzzleAnswersToggle.click(function(){
			$('.puzzle-page-answers').toggleClass('answers-hidden');
			$(this).hide();
		});
	}
	
	var puzzleAnswersList = $('.puzzle-page-answers');
	if(puzzleAnswersList.find('.answers-list img').length) {
		puzzleAnswersList.find('.answers-list a').click(function(e){
			if(puzzleAnswersList.hasClass('answers-hidden')) {
				e.preventDefault();
				return false;
			}
		});
	}
	
	var wikithonList = $('.wikithon-random-list');
	if( wikithonList.length ) {
		wikithonList.find('li > a').click(function() {
			$(this).attr('target', '_blank');
			$(this).parent().fadeOut(function() { $(this).remove(); });	
		});
	}
	
	var audios = $('.html5-audio-mini-player');
	if( audios.length ) {
		audios.click(function(e){
			$(this).find('audio').get(0).play();
		});
	}
	
	/*$('input,textarea').on('keyup change blur', function(e) {
		var text = $(this).val();
		if( text ) {
			text = text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
			$(this).val(text );
		}
	});*/
	
	if ( window.innerWidth <= 800 ) {
		$commentsBody = $('.comments-body');
		if ( $commentsBody.length ) {
			$commentsBody.appendTo($('div.bio-text'));
		}
	}
	
});