blob: fbfc1317e5824f1475cfd091fd2d56cfaa86024f (
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
|
(function ($, STUDIP) {
'use strict';
$(document).on('click', 'article.studip.toggle header h1 a', function (e) {
e.preventDefault();
var 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');
});
// Open closed article contents when location hash matches
$(window).on('hashchange', (event) => {
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));
|