-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow a user to focus on the contact searchbox via CMD+K (similar to …
…Slack)
- Loading branch information
Vitaly Belman
committed
Mar 22, 2016
1 parent
a09bda1
commit 70940f9
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(function () { | ||
|
||
console.log("Waiting for DOMContentLoaded"); | ||
document.addEventListener('DOMContentLoaded', function () { | ||
console.log("DOMContentLoaded event"); | ||
|
||
// pass in the target node, as well as the observer options | ||
var observer = new MutationObserver(function (mutations) { | ||
console.log("Mutations occurred: ", mutations.length); | ||
var inputSearch = document.querySelector("input.input-search"); | ||
if (inputSearch) { | ||
console.log("Adding event listeners"); | ||
|
||
document.addEventListener("keydown", function (event) { | ||
if (event.keyCode === 75 && event.metaKey === true) inputSearch.focus() | ||
}); | ||
|
||
console.log("Disconnecting the observer"); | ||
observer.disconnect(); | ||
} | ||
}); | ||
|
||
var config = {childList: true, subtree: true}; | ||
observer.observe(document.querySelector("body"), config); | ||
|
||
}, false); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters