Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passe à zmarkdown 11 #6276

Merged
merged 3 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions assets/js/spoiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(function($) {
'use strict'

function buildSpoilers($elem) {
function buildOldSpoilers($elem) {
$elem.each(function() {
const $this = $(this)
if (!$this.hasClass('spoiler-build')) {
Expand All @@ -31,13 +31,31 @@
})
}

function buildNewSpoilers() {
for (const spoiler of document.querySelectorAll('details.custom-block-spoiler')) {
let summary = spoiler.querySelector('summary')
if (summary === null) {
summary = document.createElement('summary')
summary.classList.add('custom-block-heading')
summary.textContent = 'Afficher/Masquer le contenu masqué'
const body = spoiler.querySelector('.custom-block-body')
spoiler.insertBefore(summary, body)
}
if (!summary.classList.contains('ico-after')) {
summary.classList.add('ico-after', 'view', 'light')
}
}
}

$(document).ready(function() {
const $content = $('#content')
$('div.spoiler').addClass('custom-block-spoiler') /* for compatibility */
buildSpoilers($content.find('.custom-block-spoiler'))
buildOldSpoilers($content.find('div.custom-block-spoiler'))
buildNewSpoilers()
$content.on('DOMNodeInserted', function(e) {
const $spoilers = $(e.target).find('.custom-block-spoiler')
return buildSpoilers($spoilers)
const $spoilers = $(e.target).find('div.custom-block-spoiler')
buildOldSpoilers($spoilers)
return buildNewSpoilers()
})
})
})(jQuery)
19 changes: 18 additions & 1 deletion assets/scss/base/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,24 @@ h6 {
}
}

.js .spoiler, .custom-block-spoiler {
/* CSS specific for new spoilers using <details> and <summary> */
.custom-block-spoiler summary.custom-block-heading {
cursor: pointer;

&.ico-after {
padding-left: $length-32;

&:after {
margin: $length-8 0 0 $length-10;
}
}

&:hover {
background-color: $grey-800;
}
}

.js .spoiler, div.custom-block-spoiler {
display: none;
}

Expand Down
4 changes: 2 additions & 2 deletions zmd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"zmarkdown": "10.1.3"
"zmarkdown": "11.0.2"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
}
}