gregrgay

suggest.aria.3

Jun 14th, 2018
5,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. switch (event.keyCode) {
  2.     case ik_utils.keys.down: // select next suggestion from list   
  3.                 selected = plugin.list.find('.selected');  
  4.                 if(selected.length) {
  5.                     msg = selected.removeClass('selected').next().addClass('selected').text();
  6.                 } else {
  7.                     msg = plugin.list.find('li:first').addClass('selected').text();
  8.                 }
  9.                 plugin.notify.text(msg); // add suggestion text to live region to be read by screen reader
  10.                 break;
  11.             case ik_utils.keys.up: // select previous suggestion from list
  12.                 selected = plugin.list.find('.selected');
  13.                 if(selected.length) {
  14.                     msg = selected.removeClass('selected').prev().addClass('selected').text();
  15.                 }
  16.                 plugin.notify.text(msg);  // add suggestion text to live region to be read by screen reader    
  17.                 break;
  18.            
  19.             default: // get suggestions based on user input
  20.                 plugin.list.empty();
  21.                 suggestions = plugin.getSuggestions(plugin.options.source, $me.val());
  22.                 if (suggestions.length > 1) {
  23.                     for(var i = 0, l = suggestions.length; i < l; i++) {
  24.                         $('<li/>').html(suggestions[i])
  25.                         .on('click', {'plugin': plugin}, plugin.onOptionClick) // add click event handler
  26.                         .appendTo(plugin.list);
  27.                     }
  28.                     plugin.list.show();
  29.                 } else {
  30.                     plugin.list.hide();
  31.                 }
  32.                
  33.         break;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment