mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
src: hide commandline after exec
This commit is contained in:
parent
24fbd85a75
commit
50241c91d2
4 changed files with 25 additions and 15 deletions
|
@ -11,22 +11,26 @@
|
|||
|
||||
// inject the commandline iframe into a content page
|
||||
|
||||
export let COMMANDLINE = null
|
||||
let cmdline_iframe: HTMLIFrameElement = undefined
|
||||
|
||||
function init(){
|
||||
cmdline_iframe = window.document.createElement("iframe")
|
||||
cmdline_iframe.setAttribute("src", browser.extension.getURL("static/commandline.html"))
|
||||
window.document.body.appendChild(cmdline_iframe)
|
||||
}
|
||||
|
||||
export function show(){
|
||||
COMMANDLINE = window.document.createElement("iframe")
|
||||
COMMANDLINE.setAttribute("src", browser.extension.getURL("static/commandline.html"))
|
||||
COMMANDLINE.setAttribute("style", "position: fixed; top: 0; left: 0; z-index: 10000; width: 100%; height: 36px; border: 0; padding: 0; margin: 0;");
|
||||
window.document.body.appendChild(COMMANDLINE)
|
||||
if (cmdline_iframe === undefined) {
|
||||
init()
|
||||
}
|
||||
cmdline_iframe.setAttribute("style", "position: fixed; top: 0; left: 0; z-index: 10000; width: 100%; height: 36px; border: 0; padding: 0; margin: 0;");
|
||||
}
|
||||
|
||||
/** Focus the commandline input: not required **/
|
||||
// let focus = ():void => COMMANDLINE.focus()
|
||||
// line below doesn't work
|
||||
COMMANDLINE.addEventListener("blur",COMMANDLINE.remove)
|
||||
// Why were we returning focus? It's a void, surely?
|
||||
// return focus
|
||||
export function hide(){
|
||||
cmdline_iframe.setAttribute("style", "display: none")
|
||||
}
|
||||
|
||||
export function focus(){
|
||||
COMMANDLINE.focus()
|
||||
show()
|
||||
cmdline_iframe.focus()
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ clInput.addEventListener("keydown", function (keyevent) {
|
|||
|
||||
/* Send the commandline to the background script and await response. */
|
||||
function process() {
|
||||
// TODO.
|
||||
console.log(clInput.value)
|
||||
browser.runtime.sendMessage({type: "commandline", exStr: clInput.value})
|
||||
browser.runtime.sendMessage({type: "commandline", exStr: "hidecommandline"})
|
||||
clInput.value = ""
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,10 @@ export function showcommandline(){
|
|||
messageActiveTab("showcommandline")
|
||||
}
|
||||
|
||||
export function hidecommandline(){
|
||||
messageActiveTab("hidecommandline")
|
||||
}
|
||||
|
||||
// TODO: address should default to some page to which we have access
|
||||
// and focus the location bar
|
||||
export async function tabopen(address?: string){
|
||||
|
|
|
@ -24,9 +24,11 @@ const commands = new Map<string, ContentCommand>([
|
|||
window.history.go(n)
|
||||
},
|
||||
function showcommandline() {
|
||||
CommandLineContent.show()
|
||||
CommandLineContent.focus()
|
||||
}
|
||||
},
|
||||
function hidecommandline() {
|
||||
CommandLineContent.hide()
|
||||
},
|
||||
].map((command):any => [command.name, command]))
|
||||
|
||||
function messageReceiver(message) {
|
||||
|
|
Loading…
Add table
Reference in a new issue