MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
counter++; | counter++; | ||
var text = $(this); | var text = $(this); | ||
/* | |||
if (counter % 2 === 0) { | if (counter % 2 === 0) { | ||
text.text('[Скрыть]'); | text.text('[Скрыть]'); | ||
} else { | } else { | ||
text.text('[Показать]'); | text.text('[Показать]'); | ||
} | |||
*/ | |||
if (text.text() == '[Показать]') { | |||
this.text('[Скрыть]'); | |||
} | } | ||
Revision as of 07:10, 25 October 2014
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
(function($) {
$('.mw-allpages-table-chunk a').filter(function() {
var $text = $(this).text();
return $text.match(/^\d{1,3}:\d{1,3}/);
}).closest('tr').css({'display': 'none'});
/* infoboxes */
$('<a class="infoboxtoggle" href="#">[Показать]</a>').appendTo(
$('.infobox tr.header').filter(function(){ return $(this).attr('class').split(" ").length > 1 }).find("th")
);
// toggle text on click
var counter = 1;
$('.infoboxtoggle').on('click', function() {
counter++;
var text = $(this);
/*
if (counter % 2 === 0) {
text.text('[Скрыть]');
} else {
text.text('[Показать]');
}
*/
if (text.text() == '[Показать]') {
this.text('[Скрыть]');
}
});
$(".infobox tr.header").each(function(){
var $this = $(this);
if( $this.hasClass("hidden") ){
var firstclass = $this.attr("class").split(" ")[0];
$this.siblings("." + firstclass).addClass("hidden");
}
});
$('a.infoboxtoggle').click (
function (infoboxtoggle)
{
var parent = $(this).parent ();
var grandparent = parent.parent ();
var firstclass = grandparent.attr ('class').split(" ")[0];
infoboxtoggle.preventDefault();
grandparent.siblings ('.' + firstclass).has ('td').toggleClass ('hidden');
}
);
})(jQuery);