Skip to content

Commit

Permalink
Enter时,如果没有选中内容,$input请求焦点
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneXuan committed Jan 9, 2016
1 parent 7a47c24 commit 1b1ca1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/javascript/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,14 @@ toggleKey.onchange = function (event) {
// updateSetting("duration", event.target.value);
// })

//在popup页内 Enter键 查询选中部分
//在popup页内 Enter键 查询选中部分 如果没有选中部分,$input请求焦点
document.addEventListener('keyup',function(e){
if(document.activeElement.tagName=="BODY" && e.which==13){
queryInPopup(window.getSelection().toString());
var selection=window.getSelection().toString();
if(selection.length>0) {
queryInPopup(selection);
}else{
$input.focus();
}
}
});

0 comments on commit 1b1ca1d

Please sign in to comment.