Skip to content

Commit

Permalink
Adding keybinding support
Browse files Browse the repository at this point in the history
  • Loading branch information
nsand committed Nov 9, 2010
1 parent f24e300 commit c6ae6f9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
14 changes: 14 additions & 0 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<script type="text/javascript">
var popupWindow;
function init() {
var count = 0;
// set up the initial tab count
Expand Down Expand Up @@ -42,6 +43,19 @@
}
});*/
}
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.action == "popup") {
if (popupWindow != null) {
popupWindow.close();
}

popupWindow = window.open(chrome.extension.getURL("popup.html"), "Tab Glutton", "width=400,height=530");
sendResponse({response: "open"});
}
else {
sendResponse({});
}
});
</script>
</head>
<body onload="init()">
Expand Down
7 changes: 4 additions & 3 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.tabglutton {
width: 340px;
margin: 0;
width: 100%;
margin: 0 !important;
margin-right: 0px !important;
overflow-x:hidden;
}
.tabglutton .tg_content {
width: 335px;
width: 400px;
font-family: Helvetica, Arial, sans-serif;
background-color: #ebeff9;
-webkit-border-top-left-radius: 5px;
Expand Down
7 changes: 7 additions & 0 deletions lib/keybinding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function() {
window.addEventListener("keyup", function(event) {
if (event.ctrlKey && event.keyCode == 74) {
chrome.extension.sendRequest({action: "popup"});
}
}, false)
})();
6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"default_title": "Tab Glutton",
"default_icon": "tab_glutton_19.png",
"popup": "popup.html"
}
},
"content_scripts": [{
"matches": ["http://*/*"],
"js": ["lib/keybinding.js"]
}]
}
4 changes: 4 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
var list = $("<ul class='tg_tab_list'>");

for (; i < tabs.length ; i++) {
if (tabs[i].url == "chrome-extension://fcbnfpbonnllhepohamfgeokfbnfcjan/popup.html")
continue;
var li = $("<li>");
$.data(li[0], "tabId", tabs[i].id);
li.append(createActions(li));
Expand Down Expand Up @@ -152,6 +154,8 @@
return actionContainer;
}
</script>
<title>Tab Glutton</title>
</head>
<body onload="load()" class="tabglutton">
<div class="tg_content">
<div class="tg_search">
Expand Down

0 comments on commit c6ae6f9

Please sign in to comment.