blob: f0aad6ee646e23062e8d1e170cbda2050064c2f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
(function ($, STUDIP) {
'use strict';
$(document).on('click', 'article.studip.toggle header h1 a', function (e) {
e.preventDefault();
const article = $(this).closest('article');
// If the contentbox article is new send an ajax request
if (article.hasClass('new') && article.data('visiturl')) {
$.post(STUDIP.URLHelper.getURL(decodeURIComponent(article.data('visiturl') + $(this).attr('href'))));
}
// Open the contentbox
article.toggleClass('open').removeClass('new');
article.attr('aria-expanded', article.attr('aria-expanded') === 'true' ? 'false' : 'true');
});
// Open closed article contents when location hash matches
$(window).on('hashchange', () => {
const hash = location.hash.split('#').pop();
$(`article.studip.toggle:not(.open) header h1 a[name="${hash}"]`).click();
});
STUDIP.ready(() => {
const hash = location.hash.split('#').pop();
if (hash.length > 0) {
$(`article.studip.toggle:not(.open) header h1 a[name="${hash}"]`).click();
}
});
}(jQuery, STUDIP));
|