MediaWiki:Common.js: различия между версиями
Shihov (обсуждение | вклад) Нет описания правки |
Shihov (обсуждение | вклад) Нет описания правки |
||
| Строка 5: | Строка 5: | ||
var $target = $(event.target); | var $target = $(event.target); | ||
var $section = $(this).closest('.CategoryTreeSection'); | var $section = $(this).closest('.CategoryTreeSection'); | ||
var $toggleButton = $section.find('.CategoryTreeToggle').first(); | var $toggleButton = $section.find('.CategoryTreeToggle').first(); | ||
var $ | var $children = $section.find('.CategoryTreeChildren').first(); | ||
// 1. Если клик был на toggle-кнопке, ничего не делаем | // 1. Если клик был на toggle-кнопке, ничего не делаем | ||
| Строка 21: | Строка 20: | ||
} | } | ||
// 3. | // 3. Разворачиваем только если оно ещё не развернуто | ||
if ($toggleButton.length) { | if ($toggleButton.length && !$children.is(':visible')) { | ||
console.log(" | console.log("Раскрываем категорию:", $section.text().trim()); | ||
$toggleButton.click(); | $toggleButton.click(); | ||
} else { | } else { | ||
console.log(" | console.log("Категория уже раскрыта или не имеет вложений:", $section.text().trim()); | ||
} | } | ||
}); | }); | ||
}); | }); | ||