mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-04 20:45:45 +01:00
Steps towards bootstrapped addon.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -10,6 +10,74 @@
|
||||
|
||||
const CommandWidgets = Class("CommandWidgets", {
|
||||
init: function () {
|
||||
let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
|
||||
let _status = "dactyl-statusline-field-";
|
||||
|
||||
util.overlayWindow(window, {
|
||||
append: <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
||||
<window id={document.documentElement.id}>
|
||||
<popupset>
|
||||
<menupopup id="dactyl-contextmenu"
|
||||
onpopupshowing="return (event.target != this || dactyl.modules.commandline.onContext(event));">
|
||||
<menuitem id="dactyl-context-copylink"
|
||||
label="Copy Link Location" dactyl:group="link"
|
||||
oncommand="goDoCommand('cmd_copyLink');"/>
|
||||
<menuitem id="dactyl-context-copy"
|
||||
label="Copy" dactyl:group="selection"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="dactyl-context-selectall"
|
||||
label="Select All"
|
||||
command="cmd_selectAll"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
</window>
|
||||
|
||||
<vbox id={config.commandContainer}>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe id="dactyl-multiline-output" src="chrome://dactyl/content/buffer.xhtml"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
onclick={_commandline + ".onMultilineOutputEvent(event)"}/>
|
||||
</vbox>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe class="dactyl-completions" id="dactyl-completions-dactyl-commandline" src="chrome://dactyl/content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick={_commandline + ".onMultilineOutputEvent(event)"}/>
|
||||
</vbox>
|
||||
|
||||
<vbox id={"dactyl-completions-" + _status + "commandline-container"} class="dactyl-container" hidden="false" collapsed="true" insertbefore="addon-bar,status-bar">
|
||||
<iframe class="dactyl-completions" id={"dactyl-completions-" + _status + "commandline"} src="chrome://dactyl/content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick={_commandline + ".onMultilineOutputEvent(event)"}/>
|
||||
</vbox>
|
||||
|
||||
<stack orient="horizontal" align="stretch" class="dactyl-container" id="dactyl-container" dactyl:highlight="CmdLine CmdCmdLine">
|
||||
<textbox class="plain" id="dactyl-strut" flex="1" crop="end" collapsed="true"/>
|
||||
<textbox class="plain" id="dactyl-mode" flex="1" crop="end"/>
|
||||
<textbox class="plain" id="dactyl-message" flex="1" readonly="true"/>
|
||||
|
||||
<hbox id="dactyl-commandline" hidden="false" class="dactyl-container" dactyl:highlight="Normal CmdNormal" collapsed="true">
|
||||
<label id="dactyl-commandline-prompt" class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox id="dactyl-commandline-command" class="dactyl-commandline-command plain" flex="1" type="input" timeout="100"
|
||||
oninput={_commandline + ".onEvent(event);"} onkeyup={_commandline + ".onEvent(event);"}
|
||||
onfocus={_commandline + ".onEvent(event);"} onblur={_commandline + ".onEvent(event);"}/>
|
||||
</hbox>
|
||||
</stack>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="false" dactyl:highlight="CmdLine">
|
||||
<textbox id="dactyl-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
dactyl:highlight="Normal"
|
||||
onkeypress={_commandline + ".onMultilineInputEvent(event);"} oninput={_commandline + ".onMultilineInputEvent(event);"}
|
||||
onblur={_commandline + ".onMultilineInputEvent(event);"}/>
|
||||
</vbox>
|
||||
</vbox>
|
||||
</e4x>.*
|
||||
});
|
||||
|
||||
this.elements = {};
|
||||
this.addElement({
|
||||
name: "container",
|
||||
|
||||
@@ -57,6 +57,8 @@ const ConfigBase = Class(ModuleBase, {
|
||||
|
||||
get browserModes() [modes.NORMAL],
|
||||
|
||||
commandContainer: "browser-bottombox",
|
||||
|
||||
/**
|
||||
* @property {Object} Application specific defaults for option values. The
|
||||
* property names must be the options' canonical names, and the values
|
||||
|
||||
@@ -18,113 +18,9 @@
|
||||
]>
|
||||
|
||||
<overlay id="dactyl"
|
||||
xmlns:dactyl="http://vimperator.org/namespaces/liberator"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript;version=1.8" src="&dactyl.content;dactyl-overlay.js"/>
|
||||
|
||||
<window id="&dactyl.mainWindow;">
|
||||
|
||||
<popupset>
|
||||
<menupopup id="dactyl-contextmenu"
|
||||
onpopupshowing="return (event.target != this || dactyl.modules.commandline.onContext(event));">
|
||||
<menuitem id="dactyl-context-copylink"
|
||||
label="Copy Link Location" dactyl:group="link"
|
||||
oncommand="goDoCommand('cmd_copyLink');"/>
|
||||
<menuitem id="dactyl-context-copy"
|
||||
label="Copy" dactyl:group="selection"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="dactyl-context-selectall"
|
||||
label="Select All"
|
||||
command="cmd_selectAll"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
<!--this notifies us also of focus events in the XUL
|
||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||
<!-- I don't think we really need this. ––Kris -->
|
||||
<commandset id="onPentadactylFocus" commandupdater="true" events="focus"
|
||||
oncommandupdate="&events;.onFocusChange(event);"/>
|
||||
<commandset id="onPentadactylSelect" commandupdater="true" events="select"
|
||||
oncommandupdate="&events;.onSelectionChange(event);"/>
|
||||
</window>
|
||||
|
||||
<vbox id="&dactyl.commandContainer;">
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe id="dactyl-multiline-output" src="chrome://dactyl/content/buffer.xhtml"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
onclick="&commandline;.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe class="dactyl-completions" id="dactyl-completions-dactyl-commandline" src="chrome://dactyl/content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="&commandline;.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="dactyl-completions-&status;commandline-container" class="dactyl-container" hidden="false" collapsed="true" insertbefore="addon-bar,status-bar">
|
||||
<iframe class="dactyl-completions" id="dactyl-completions-&status;commandline" src="chrome://dactyl/content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="&commandline;.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<stack orient="horizontal" align="stretch" class="dactyl-container" id="dactyl-container" dactyl:highlight="CmdLine CmdCmdLine">
|
||||
<textbox class="plain" id="dactyl-strut" flex="1" crop="end" collapsed="true"/>
|
||||
<textbox class="plain" id="dactyl-mode" flex="1" crop="end"/>
|
||||
<textbox class="plain" id="dactyl-message" flex="1" readonly="true"/>
|
||||
|
||||
<hbox id="dactyl-commandline" hidden="false" class="dactyl-container" dactyl:highlight="Normal CmdNormal" collapsed="true">
|
||||
<label id="dactyl-commandline-prompt" class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox id="dactyl-commandline-command" class="dactyl-commandline-command plain" flex="1" type="input" timeout="100"
|
||||
oninput="&commandline;.onEvent(event);" onkeyup="&commandline;.onEvent(event);"
|
||||
onfocus="&commandline;.onEvent(event);" onblur="&commandline;.onEvent(event);"/>
|
||||
</hbox>
|
||||
</stack>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="false" dactyl:highlight="CmdLine">
|
||||
<textbox id="dactyl-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
dactyl:highlight="Normal"
|
||||
onkeypress="&commandline;.onMultilineInputEvent(event);" oninput="&commandline;.onMultilineInputEvent(event);"
|
||||
onblur="&commandline;.onMultilineInputEvent(event);"/>
|
||||
</vbox>
|
||||
</vbox>
|
||||
|
||||
<statusbar id="status-bar" dactyl:highlight="StatusLine StatusNormal">
|
||||
<hbox insertbefore="&dactyl.statusBefore;" insertafter="&dactyl.statusAfter;"
|
||||
style="background: inherit;" id="&status;container" flex="1" hidden="false" align="center">
|
||||
<stack orient="horizontal" align="stretch" flex="1" class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<hbox class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<label class="plain" id="&status;mode" crop="end" collapsed="true"/>
|
||||
<stack flex="1" class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<textbox class="plain" id="&status;url" crop="end" flex="1" readonly="true"/>
|
||||
<textbox class="plain" id="&status;message" crop="end" flex="1" readonly="true" dactyl:highlight="Normal StatusNormal"/>
|
||||
</stack>
|
||||
</hbox>
|
||||
|
||||
<hbox id="&status;commandline" hidden="false" class="dactyl-container" dactyl:highlight="Normal StatusNormal" collapsed="true">
|
||||
<label id="&status;commandline-prompt" class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox id="&status;commandline-command" class="dactyl-commandline-command plain" flex="1" type="text" timeout="100"
|
||||
oninput="&commandline;.onEvent(event);" onkeyup="&commandline;.onEvent(event);"
|
||||
onfocus="&commandline;.onEvent(event);" onblur="&commandline;.onEvent(event);"/>
|
||||
</hbox>
|
||||
</stack>
|
||||
<label class="plain" id="&status;inputbuffer" flex="0"/>
|
||||
<label class="plain" id="&status;progress" flex="0"/>
|
||||
<label class="plain" id="&status;tabcount" flex="0"/>
|
||||
<label class="plain" id="&status;bufferposition" flex="0"/>
|
||||
<label class="plain" id="&status;zoomlevel" flex="0"/>
|
||||
</hbox>
|
||||
<!-- just hide them since other elements expect them -->
|
||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
||||
<statusbarpanel id="statusbar-progresspanel" hidden="true"/>
|
||||
</statusbar>
|
||||
</overlay>
|
||||
|
||||
<!-- vim: set fdm=marker sw=4 ts=4 et: -->
|
||||
|
||||
@@ -13,6 +13,21 @@
|
||||
*/
|
||||
const Events = Module("events", {
|
||||
init: function () {
|
||||
let _events = "if (window.dactyl ∧ dactyl.modules.loaded.events) return dactyl.modules.events"
|
||||
util.overlayWindow(window, {
|
||||
append: <e4x xmlns={XUL}>
|
||||
<window id={document.documentElement.id}>
|
||||
<!--this notifies us also of focus events in the XUL
|
||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||
<!-- I don't think we really need this. ––Kris -->
|
||||
<commandset id="onPentadactylFocus" commandupdater="true" events="focus"
|
||||
oncommandupdate="{_events}.onFocusChange(event);"/>
|
||||
<commandset id="onPentadactylSelect" commandupdater="true" events="select"
|
||||
oncommandupdate="{_events}.onSelectionChange(event);"/>
|
||||
</window>
|
||||
</e4x>.*
|
||||
});
|
||||
|
||||
this._fullscreen = window.fullScreen;
|
||||
this._lastFocus = null;
|
||||
this._currentMacro = "";
|
||||
|
||||
@@ -10,6 +10,45 @@
|
||||
|
||||
const StatusLine = Module("statusline", {
|
||||
init: function () {
|
||||
|
||||
let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
|
||||
let _status = "dactyl-statusline-field-";
|
||||
|
||||
util.overlayWindow(window, {
|
||||
append: <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
||||
<statusbar id="status-bar" dactyl:highlight="StatusLine StatusNormal">
|
||||
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
|
||||
<hbox
|
||||
style="background: inherit;" id={_status + "container"} flex="1" hidden="false" align="center">
|
||||
<stack orient="horizontal" align="stretch" flex="1" class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<hbox class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<label class="plain" id={_status + "mode"} crop="end" collapsed="true"/>
|
||||
<stack flex="1" class="dactyl-container" dactyl:highlight="CmdLine StatusCmdLine">
|
||||
<textbox class="plain" id={_status + "url"} crop="end" flex="1" readonly="true"/>
|
||||
<textbox class="plain" id={_status + "message"} crop="end" flex="1" readonly="true" dactyl:highlight="Normal StatusNormal"/>
|
||||
</stack>
|
||||
</hbox>
|
||||
|
||||
<hbox id={_status + "commandline"} hidden="false" class="dactyl-container" dactyl:highlight="Normal StatusNormal" collapsed="true">
|
||||
<label id={_status + "commandline-prompt"} class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox id={_status + "commandline-command"} class="dactyl-commandline-command plain" flex="1" type="text" timeout="100"
|
||||
oninput={_commandline + ".onEvent(event);"} onkeyup={_commandline + ".onEvent(event);"}
|
||||
onfocus={_commandline + ".onEvent(event);"} onblur={_commandline + ".onEvent(event);"}/>
|
||||
</hbox>
|
||||
</stack>
|
||||
<label class="plain" id={_status + "inputbuffer"} flex="0"/>
|
||||
<label class="plain" id={_status + "progress"} flex="0"/>
|
||||
<label class="plain" id={_status + "tabcount"} flex="0"/>
|
||||
<label class="plain" id={_status + "bufferposition"} flex="0"/>
|
||||
<label class="plain" id={_status + "zoomlevel"} flex="0"/>
|
||||
</hbox>
|
||||
<!-- just hide them since other elements expect them -->
|
||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
||||
<statusbarpanel id="statusbar-progresspanel" hidden="true"/>
|
||||
</statusbar>
|
||||
</e4x>.*
|
||||
});
|
||||
|
||||
this._statusLine = document.getElementById("status-bar");
|
||||
this.statusBar = document.getElementById("addon-bar") || this._statusLine;
|
||||
this.statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0
|
||||
|
||||
@@ -896,45 +896,79 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
return color ? string : [s for each (s in string)].join("");
|
||||
},
|
||||
|
||||
_loadOverlays: function _loadOverlays(window) {
|
||||
if (!window.dactylOverlays)
|
||||
window.dactylOverlays = [];
|
||||
|
||||
for each (let obj in util.overlays[window.document.documentURI] || []) {
|
||||
if (window.dactylOverlays.indexOf(obj) >= 0)
|
||||
continue;
|
||||
window.dactylOverlays.push(obj);
|
||||
this._loadOverlay(window, obj(window));
|
||||
}
|
||||
},
|
||||
_loadOverlay: function _loadOverlay(window, obj) {
|
||||
function overlay(key, fn) {
|
||||
if (obj[key]) {
|
||||
let iterator = Iterator(obj[key]);
|
||||
if (!isObject(obj[key]))
|
||||
iterator = ([elem.@id, elem.*, elem.@*::*] for each (elem in obj[key]));
|
||||
|
||||
for (let [elem, xml, attr] in iterator) {
|
||||
if (elem = window.document.getElementById(elem)) {
|
||||
fn(elem, util.xmlToDom(xml, window.document));
|
||||
for each (let attr in attr || [])
|
||||
elem.setAttributeNS(attr.namespace(), attr.localName(), attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
overlay("before", function (elem, dom) elem.parentNode.insertBefore(dom, elem));
|
||||
overlay("after", function (elem, dom) elem.parentNode.insertBefore(dom, elem.nextSibling));
|
||||
overlay("append", function (elem, dom) elem.appendChild(dom));
|
||||
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
||||
if (obj.init)
|
||||
obj.init(window, window.dactylDOMLoaded);
|
||||
|
||||
if (obj.load)
|
||||
if (window.document.dactylLoaded)
|
||||
obj.load(window, window.document.dactylLoaded);
|
||||
else
|
||||
window.document.addEventListener("load", wrapCallback(function load(event) {
|
||||
if (event.originalTarget === event.target) {
|
||||
window.document.removeEventListener("load", load.wrapper, true);
|
||||
window.document.dactylLoaded = event;
|
||||
obj.load(window, event);
|
||||
}
|
||||
}), true);
|
||||
},
|
||||
|
||||
observe: {
|
||||
"toplevel-window-ready": function (window, data) {
|
||||
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
|
||||
window.removeEventListener("DOMContentLoaded", listener.wrapper, true);
|
||||
|
||||
if (event.originalTarget !== window.document)
|
||||
return;
|
||||
|
||||
let obj = util.overlays[window.document.documentURI];
|
||||
if (obj) {
|
||||
obj = obj(window);
|
||||
|
||||
function overlay(key, fn) {
|
||||
for (let [elem, xml] in Iterator(obj[key] || {}))
|
||||
if (elem = window.document.getElementById(elem))
|
||||
fn(elem, util.xmlToDom(xml, window.document));
|
||||
}
|
||||
|
||||
overlay("before", function (elem, dom) elem.parentNode.insertBefore(dom, elem));
|
||||
overlay("after", function (elem, dom) elem.parentNode.insertBefore(dom, elem.nextSibling));
|
||||
overlay("append", function (elem, dom) elem.appendChild(dom));
|
||||
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
||||
if (obj.init)
|
||||
obj.init(window, event);
|
||||
|
||||
if (obj.load)
|
||||
window.document.addEventListener("load", function (event) {
|
||||
if (event.originalTarget === event.target)
|
||||
obj.load(window, event);
|
||||
}, true);
|
||||
if (event.originalTarget === window.document) {
|
||||
window.removeEventListener("DOMContentLoaded", listener.wrapper, true);
|
||||
window.document.dactylDOMLoaded = event;
|
||||
util._loadOverlays(window);
|
||||
}
|
||||
}), true)
|
||||
}
|
||||
},
|
||||
|
||||
overlayWindow: function (url, fn) {
|
||||
Array.concat(url).forEach(function (url) {
|
||||
this.overlays[url] = fn;
|
||||
}, this);
|
||||
if (url instanceof Ci.nsIDOMWindow)
|
||||
util._loadOverlay(url, fn);
|
||||
else {
|
||||
Array.concat(url).forEach(function (url) {
|
||||
if (!this.overlays[url])
|
||||
this.overlays[url] = [];
|
||||
this.overlays[url].push(fn);
|
||||
}, this);
|
||||
for (let win in services.windowMediator.getEnumerator(null))
|
||||
if (win.dactylDOMLoaded)
|
||||
this._loadOverlays(win);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user