MediaWiki:Common.js: различия между версиями
Shihov (обсуждение | вклад) Нет описания правки Метка: отменено |
Shihov (обсуждение | вклад) Нет описания правки Метка: отменено |
||
Строка 1: | Строка 1: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
console.log("Скрипт дерева категорий загружен."); | console.log("Скрипт дерева категорий загружен."); | ||
$('body').on('click', '#p-categorytree-portlet .CategoryTreeItem', function(event) { | $('body').on('click', '#p-categorytree-portlet .CategoryTreeItem', function(event) { | ||
Строка 34: | Строка 18: | ||
var link = $item.find('a').attr('href'); | var link = $item.find('a').attr('href'); | ||
if (link) { | if (link) { | ||
window.location.href = link; | window.location.href = link; | ||
} | } | ||
} | } | ||
}); | }); | ||
Строка 54: | Строка 33: | ||
scrollTop: $categoryItem.position().top - 50 | scrollTop: $categoryItem.position().top - 50 | ||
}, 500, function() { | }, 500, function() { | ||
$('#p-categorytree-portlet .CategoryTreeItem').removeClass('highlighted'); | $('#p-categorytree-portlet .CategoryTreeItem').removeClass('highlighted'); | ||
$categoryItem.addClass('highlighted'); | $categoryItem.addClass('highlighted'); | ||
Строка 66: | Строка 44: | ||
function expandAndFindCategory($parent, callback) { | function expandAndFindCategory($parent, callback) { | ||
var $toggleButton = $parent.find('.CategoryTreeToggle').first(); | var $toggleButton = $parent.find('.CategoryTreeToggle').first(); | ||
if ($toggleButton.length && ! | var isExpanded = $toggleButton.attr('aria-expanded') === 'true'; | ||
if ($toggleButton.length && !isExpanded) { | |||
$toggleButton.click(); | $toggleButton.click(); | ||
Строка 82: | Строка 62: | ||
function recursiveSearchForCategory() { | function recursiveSearchForCategory() { | ||
var currentPageTitle = mw.config.get('wgTitle'); | var currentPageTitle = mw.config.get('wgTitle'); | ||
if (!currentPageTitle) { | if (!currentPageTitle) { | ||
Строка 119: | Строка 98: | ||
recursiveSearchForCategory(); | recursiveSearchForCategory(); | ||
}, 500); | }, 500); | ||
}); | }); |