Skip to content

Commit

Permalink
Changed enter action to deferred
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenzie committed Feb 7, 2017
1 parent d13c905 commit 663866e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ $(
$styleSwitcher.setStyle(styleTitle, $content.contents()[0]);
});

var doLookup = function(dontClearContent, key) {
var doLookup = function(dontClearContent) {
var deferred = $.Deferred();
var word = $word.val();
console.log(word);
$lookupResult.empty();
Expand Down Expand Up @@ -117,11 +118,9 @@ $(
return true;
});
$lookupResult.append($ul);
// 13 is 'Enter'
if (key === 13) {
$($lookupResult).find('a:first-of-type')[0].click();
}
deferred.resolve();
});
return deferred.promise();
};

var onLinkUpDown = function(e) {
Expand Down Expand Up @@ -160,7 +159,12 @@ $(
clearTimeout(scheduledLookupID);
}
scheduledLookupID = setTimeout(function() {
doLookup(true, key);
doLookup(true).done(function(){
// 13 is 'Enter'
if (key === 13) {
$($lookupResult).find('a:first-of-type')[0].click();
}
});
}, 500);
}
};
Expand Down

0 comments on commit 663866e

Please sign in to comment.