Skip to content

Commit 59fc2cb

Browse files
authored
Merge pull request #1981 from RogerHaase/1976-csp-roland
CSP warning on items containing TOC macro fixes #1976
2 parents dfb4df7 + 9049d4c commit 59fc2cb

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/moin/converters/html_out.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,7 @@ def __call__(self, element):
751751
headings_list = [h[1] for h in headings]
752752
if headings_list:
753753
maxlevel = max(headings_list)
754-
headtogglelink = html.a(
755-
attrib={
756-
html.class_: "moin-showhide",
757-
html.href_: "#",
758-
html.onclick_: "$('.moin-table-of-contents ol').toggle();return false;",
759-
},
760-
children=["[+]"],
761-
)
754+
headtogglelink = html.a(attrib={html.class_: "moin-showhide", html.href_: "#"}, children=["[+]"])
762755
elem_h = html.div(
763756
attrib={html.class_: "moin-table-of-contents-heading"}, children=[_("Contents"), headtogglelink]
764757
)
@@ -790,14 +783,7 @@ def stack_top_append(elem):
790783
if need_item:
791784
stack.pop()
792785
stack_push(html.li({html.id_: f"li{id}"}))
793-
togglelink = html.a(
794-
attrib={
795-
html.href_: "#",
796-
html.onclick_: f"$('#li{id} ol').toggle();return false;",
797-
html.class_: "moin-showhide",
798-
},
799-
children=["[+]"],
800-
)
786+
togglelink = html.a(attrib={html.href_: "#", html.class_: "moin-showhide"}, children=["[+]"])
801787
elem_a = html.a(attrib={html.href: "#" + id}, children=[text])
802788
stack_top_append(elem_a)
803789
old_toggle = togglelink

src/moin/static/js/common.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,14 @@ $(document).ready(function () {
919919

920920
// placing initToggleComments after enhanceEdit prevents odd autoscroll issue when editing hidden comments
921921
moin.initToggleComments();
922+
$('.moin-table-of-contents .moin-showhide').on('click', function (event) {
923+
event.preventDefault();
924+
var parent = $(this).parent();
925+
if ($(parent).is('.moin-table-of-contents-heading')) {
926+
parent = $(parent).parent();
927+
}
928+
$(parent).find('ol:first-of-type').toggle();
929+
});
922930

923931
moin.restoreFlashMessages();
924932
});

0 commit comments

Comments
 (0)