Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- switch (event.keyCode) {
- case ik_utils.keys.down: // select next suggestion from list
- selected = plugin.list.find('.selected');
- if(selected.length) {
- msg = selected.removeClass('selected').next().addClass('selected').text();
- } else {
- msg = plugin.list.find('li:first').addClass('selected').text();
- }
- plugin.notify.text(msg); // add suggestion text to live region to be read by screen reader
- break;
- case ik_utils.keys.up: // select previous suggestion from list
- selected = plugin.list.find('.selected');
- if(selected.length) {
- msg = selected.removeClass('selected').prev().addClass('selected').text();
- }
- plugin.notify.text(msg); // add suggestion text to live region to be read by screen reader
- break;
- default: // get suggestions based on user input
- plugin.list.empty();
- suggestions = plugin.getSuggestions(plugin.options.source, $me.val());
- if (suggestions.length > 1) {
- for(var i = 0, l = suggestions.length; i < l; i++) {
- $('<li/>').html(suggestions[i])
- .on('click', {'plugin': plugin}, plugin.onOptionClick) // add click event handler
- .appendTo(plugin.list);
- }
- plugin.list.show();
- } else {
- plugin.list.hide();
- }
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment