Make commandline show only after : is pressed

I have also attempted to make the commmand line hide when it is not in
focus, but had no luck.
This commit is contained in:
Oliver Blanthorn 2017-10-04 21:35:52 +01:00
parent 38923d8876
commit b7b4b940ae
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
3 changed files with 20 additions and 7 deletions

View file

@ -10,10 +10,16 @@
*/
// inject the commandline iframe into a content page
let clFrame = window.document.createElement("iframe")
clFrame.setAttribute("src", browser.extension.getURL("static/commandline.html"))
clFrame.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(clFrame)
export function showcommandline(){
let clFrame = window.document.createElement("iframe")
clFrame.setAttribute("src", browser.extension.getURL("static/commandline.html"))
clFrame.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(clFrame)
/** Focus the commandline input */
export let focus = ():void => clFrame.focus()
/** Focus the commandline input: not required **/
// let focus = ():void => clFrame.focus()
// line below doesn't work
clFrame.addEventListener("blur",clFrame.remove)
// Why were we returning focus? It's a void, surely?
// return focus
}

View file

@ -1,4 +1,5 @@
/** Conventional definition of modulo that never gives a -ve result. */
Number.prototype.mod = function (n: number): number {
return Math.abs(this % n)
}
@ -89,6 +90,12 @@ export async function reload(n = 1, hard = false){
)
}
// Commandline function
export function showcommandline(){
messageActiveTab("showcommandline")
}
// TODO: address should default to some page to which we have access
// and focus the location bar
export async function tabopen(address?: string){

View file

@ -24,7 +24,7 @@ const commands = new Map<string, ContentCommand>([
window.history.go(n)
},
function focuscmdline() {
CommandLineContent.focus()
CommandLineContent.showcommandline()
}
].map((command):any => [command.name, command]))