-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into remove_some_jquery
- Loading branch information
Showing
43 changed files
with
2,065 additions
and
2,068 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
/* ===== Zeste de Savoir ==================================================== | ||
Accordeon for sidebar | ||
--------------------------------- | ||
Author: Alex-D | ||
Author: Alex-D, firm1 | ||
========================================================================== */ | ||
|
||
(function($) { | ||
'use strict' | ||
(function() { | ||
function accordeon(element) { | ||
const nextSearchElt = ['OL', 'UL'] | ||
|
||
function accordeon($elem) { | ||
$('h4 + ul, h4 + ol', $elem).each(function() { | ||
if (!$(this).hasClass('unfolded')) { | ||
if ($('.current', $(this)).length === 0) { $(this).hide() } | ||
} | ||
}) | ||
Array.from(element.querySelectorAll('h4 + ul:not(.unfolded), h4 + ol:not(.unfolded)')) | ||
.filter(item => item.querySelectorAll('.current').length === 0) | ||
.forEach(item => item.classList.add('hidden')) | ||
|
||
$('h4', $elem).click(function(e) { | ||
$('+ ul, + ol', $(this)).slideToggle(100) | ||
|
||
e.preventDefault() | ||
e.stopPropagation() | ||
}) | ||
Array.from(element.querySelectorAll('h4')) | ||
.filter(item => nextSearchElt.includes(item.nextElementSibling.nodeName)) | ||
.forEach(item => item.addEventListener('click', (e) => { | ||
item.nextElementSibling.classList.toggle('hidden') | ||
|
||
e.preventDefault() | ||
e.stopPropagation() | ||
})) | ||
} | ||
|
||
$(document).ready(function() { | ||
$('.main .sidebar.accordeon, .main .sidebar .accordeon') | ||
.each(function() { | ||
accordeon($(this)) | ||
}) | ||
.on('DOMNodeInserted', function(e) { | ||
accordeon($(e.target)) | ||
}) | ||
window.addEventListener('DOMContentLoaded', () => { | ||
Array.from(document.querySelectorAll('.main .sidebar.accordeon, .main .sidebar .accordeon')).forEach(item => accordeon(item)) | ||
}) | ||
})(jQuery) | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.