mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-09 04:31:11 -06:00
Close menu upon click inside
This commit is contained in:
11
website/assets/script.js
Normal file
11
website/assets/script.js
Normal file
@@ -0,0 +1,11 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var menuItems = document.querySelector('.menu-items');
|
||||
menuItems.addEventListener('click', function(event) {
|
||||
if (event.target.tagName === 'SPAN') {
|
||||
var checkboxes = document.querySelectorAll('#toggle-menu');
|
||||
checkboxes.forEach(function(checkbox) {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -40,6 +40,7 @@ class ModifyBuild
|
||||
text = remove_section_table_of_contents(text)
|
||||
text = mark_menu_as_selected_if_on_page(text, extract_file_from_path(filename))
|
||||
text = add_canonical_for_duplicates(text, extract_file_from_path(filename))
|
||||
text = include_javascript(text)
|
||||
File.open(filename, "w") {|file| file.puts text }
|
||||
end
|
||||
|
||||
@@ -367,6 +368,16 @@ class ModifyBuild
|
||||
doc.to_html
|
||||
end
|
||||
|
||||
def include_javascript(text)
|
||||
doc = build_doc(text)
|
||||
head = doc.css("head")[0]
|
||||
js_tag_html = %Q{
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
}
|
||||
head.inner_html = "#{head.inner_html} #{js_tag_html}"
|
||||
doc.to_html
|
||||
end
|
||||
|
||||
def build_doc(text)
|
||||
Nokogiri::HTML(text)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user