Add auto-expand for nav, and missing section IDs

This commit is contained in:
Daniel Sinn
2015-12-22 23:47:07 -05:00
parent 8bc4466dbb
commit 467bd4b534
2 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -325,7 +325,7 @@
<ul id="sequenceInstruction"></ul>
</section>
<section>
<section id="venn">
<h2>Venn Diagram</h2>
<ul id="vennOptions">
<li><input type="checkbox" id="vennRed" /> <label for="vennRed">Red</label></li>
@@ -336,7 +336,7 @@
<div id="vennInstruction"></div>
</section>
<section>
<section id="passwords">
<h2>Passwords</h2>
<table id="passwords"></table>
<ul id="passwordOptions">
+9 -2
View File
@@ -7,6 +7,7 @@ $('h2').on('dblclick', function () {
$(this).closest('section').toggleClass('collapsed');
}).attr('title', 'Double-click to expand/collapse');
/** Reset inputs */
ktane.resetInputs = function ($container) {
$container.find('textarea').val('');
@@ -26,9 +27,15 @@ $('.jsResetSection').on('click', function () {
ktane.resetInputs($(this).closest('section')).filter('[type="text"]').first().focus();
});
/** Navigation */
$('section').each(function () {
var $navList = $('#navList');
$navList.append('<li><a href="#' + this.id + '">' + $(this).find('h2').first().text() + '</a></li>');
var $section = $(this),
id = $section.attr('id'),
$a = $('<a href="#' + id + '">' + $(this).find('h2').first().text() + '</a>').on('click', function () {
$section.removeClass('collapsed');
});
id && $('#navList').append($('<li></li>').append($a));
});
(function () {