Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
up and down keys for visible but not selected subs
Browse files Browse the repository at this point in the history
  • Loading branch information
mustardamus committed Feb 1, 2010
1 parent 14c1c8d commit 3ba6b09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -113,7 +113,6 @@ <h2><span class="name">To Do</span><span class="returns">What is still on the li
<ol>
<li>Fix links to other pages.</li>
<li>Make a page for the different return types and fix the links.</li>
<li>Get history (back button) working.</li>
<li>Auto scroll the navigation when keys are used.</li>
</ol>
</p>
Expand All @@ -126,6 +125,7 @@ <h2><span class="name">Changelog</span><span class="returns">jQAPI history.</spa
<p>
<pre><code>[02/01/10] Pages are now bookmark-able. <a href="http://benalman.com/projects/jquery-bbq-plugin/">BBQ Plugin</a> doing 99% of the work.
Fixed images.
History is working.
[01/31/10] Complete rewrite with Ajax magic, better keyboard support and faster search.
[01/29/10] Released hacked together version with good ol' iframes. (<a href="http://github.com/mustardamus/jquery-api-self">repo</a>)</code></pre>
</p>
Expand Down
15 changes: 11 additions & 4 deletions js/main.js
Expand Up @@ -56,9 +56,9 @@ $(document).ready(function() {
function handleKey(key) {
if(isOverNavigation()) {
search_field.focus();
var sel = 'selected';

if($('.selected:visible').length) {
var sel = 'selected';
var selel = $('.'+sel);

if(key == 'up' && selel.prev().length) selel.removeClass(sel).prev().addClass(sel);
Expand All @@ -72,10 +72,17 @@ $(document).ready(function() {
if(cats.length) { //a category is already selected
if(key == 'up') cats.removeClass(catsel).prev().addClass(catsel);
if(key == 'down') cats.removeClass(catsel).next().addClass(catsel);
if(key == 'enter') cats.removeClass(catsel).children('span').trigger('click').parent().find('.sub:first').addClass('selected');
if(key == 'enter') cats.removeClass(catsel).children('span').trigger('click');
} else { //no category selected
if(key == 'up') cat.last().addClass(catsel);
if(key == 'down') cat.first().addClass(catsel);
var subvis = $('.sub:visible', static_el);

if(subvis.length) {
if(key == 'up') subvis.filter(':last').addClass(sel);
if(key == 'down') subvis.filter(':first').addClass(sel);
} else {
if(key == 'up') cat.last().addClass(catsel);
if(key == 'down') cat.first().addClass(catsel);
}
}
}
}
Expand Down

0 comments on commit 3ba6b09

Please sign in to comment.