User:Tigerpaw28/monacobook.js: Difference between revisions
From MediaWiki
Jump to navigationJump to searchTigerpaw28 (talk | contribs) m Commenting out my test code to verify that it's causing the observed layout changes. |
Tigerpaw28 (talk | contribs) mNo edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
/*$('h2:contains("Fiction") ~ h3').css('text-align', 'center');*/ | /*$('h2:contains("Fiction") ~ h3').css('text-align', 'center');*/ | ||
// install [[:Wikipedia:User:Cacycle/wikEd]] in-browser text editor | |||
/*(function () | |||
{ | |||
var script = document.createElement('script'); | |||
script.src = 'https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript'; | |||
script.async = 'true'; | |||
document.getElementsByTagName('head')[0].appendChild(script); | |||
} | |||
) ();*/ | |||
// ================== | |||
// tabber.js | |||
// Authors: Eric Fortin, Alexia E. Smith | |||
// ================== | |||
(function($) { | |||
$.fn.tabber = function() { | |||
return this.each(function() { | |||
// create tabs | |||
var $this = $(this), | |||
tabContent = $this.children('.tabbertab'), | |||
nav = $('<ul>').addClass('tabbernav'); | |||
tabContent.each(function() { | |||
var anchor = $('<a>').text(this.title).attr('title', this.title).attr('href', 'javascript:void(0);'); | |||
$('<li>').append(anchor).appendTo(nav); | |||
}); | |||
$this.prepend(nav); | |||
/** | |||
* Internal helper function for showing content | |||
* @param string title to show, matching only 1 tab | |||
* @return true if matching tab could be shown | |||
*/ | |||
function showContent(title) { | |||
var content = tabContent.filter('[title="' + title + '"]'); | |||
if (content.length !== 1) return false; | |||
tabContent.hide(); | |||
content.show(); | |||
nav.find('.tabberactive').removeClass('tabberactive'); | |||
nav.find('a[title="' + title + '"]').parent().addClass('tabberactive'); | |||
return true; | |||
} | |||
// setup initial state | |||
showContent(tabContent.first().attr('title')); | |||
// Repond to clicks on the nav tabs | |||
nav.on('click', 'a', function(e) { | |||
var title = $(this).attr('title'); | |||
e.preventDefault(); | |||
showContent(title); | |||
$(window).scroll(); | |||
}); | |||
$this.addClass('tabberlive'); | |||
}); | |||
}; | |||
})(jQuery); | |||
$(document).ready(function() { | |||
$('.tabber').tabber(); | |||
}); | |||
Latest revision as of 22:52, 19 February 2023
/* KIRED FUNCTIONS - Javascript Includes */
/*document.write('<' + 'script language="javascript" type="text/javascript" src="');
document.write('http://www.emopanda.com/tmp/jquery.js');
document.write('"></' + 'script' + '>');
document.write('<' + 'script language="javascript" type="text/javascript" src="');
document.write('http://www.emopanda.com/tmp/jquery.tooltip.js');
document.write('"></' + 'script' + '>');
document.write('<' + 'script language="javascript" type="text/javascript" src="');
document.write('http://www.emopanda.com/tmp/kired_wikifunctions.js');
document.write('"></' + 'script' + '>');
*/
/*$('h2:contains("Fiction") ~ h3').css('text-align', 'center');*/
// install [[:Wikipedia:User:Cacycle/wikEd]] in-browser text editor
/*(function ()
{
var script = document.createElement('script');
script.src = 'https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript';
script.async = 'true';
document.getElementsByTagName('head')[0].appendChild(script);
}
) ();*/
// ==================
// tabber.js
// Authors: Eric Fortin, Alexia E. Smith
// ==================
(function($) {
$.fn.tabber = function() {
return this.each(function() {
// create tabs
var $this = $(this),
tabContent = $this.children('.tabbertab'),
nav = $('<ul>').addClass('tabbernav');
tabContent.each(function() {
var anchor = $('<a>').text(this.title).attr('title', this.title).attr('href', 'javascript:void(0);');
$('<li>').append(anchor).appendTo(nav);
});
$this.prepend(nav);
/**
* Internal helper function for showing content
* @param string title to show, matching only 1 tab
* @return true if matching tab could be shown
*/
function showContent(title) {
var content = tabContent.filter('[title="' + title + '"]');
if (content.length !== 1) return false;
tabContent.hide();
content.show();
nav.find('.tabberactive').removeClass('tabberactive');
nav.find('a[title="' + title + '"]').parent().addClass('tabberactive');
return true;
}
// setup initial state
showContent(tabContent.first().attr('title'));
// Repond to clicks on the nav tabs
nav.on('click', 'a', function(e) {
var title = $(this).attr('title');
e.preventDefault();
showContent(title);
$(window).scroll();
});
$this.addClass('tabberlive');
});
};
})(jQuery);
$(document).ready(function() {
$('.tabber').tabber();
});

