mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 07:57:59 +01:00
More bootstrap work.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -75,7 +75,7 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
onblur={_commandline + ".onMultilineInputEvent(event);"}/>
|
onblur={_commandline + ".onMultilineInputEvent(event);"}/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
</e4x>.*
|
</e4x>.elements()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.elements = {};
|
this.elements = {};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
const Events = Module("events", {
|
const Events = Module("events", {
|
||||||
init: function () {
|
init: function () {
|
||||||
let _events = "if (window.dactyl ∧ dactyl.modules.loaded.events) return dactyl.modules.events"
|
let _events = "if (window.dactyl && dactyl.modules.loaded.events) return dactyl.modules.events"
|
||||||
util.overlayWindow(window, {
|
util.overlayWindow(window, {
|
||||||
append: <e4x xmlns={XUL}>
|
append: <e4x xmlns={XUL}>
|
||||||
<window id={document.documentElement.id}>
|
<window id={document.documentElement.id}>
|
||||||
@@ -21,11 +21,11 @@ const Events = Module("events", {
|
|||||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||||
<!-- I don't think we really need this. ––Kris -->
|
<!-- I don't think we really need this. ––Kris -->
|
||||||
<commandset id="onPentadactylFocus" commandupdater="true" events="focus"
|
<commandset id="onPentadactylFocus" commandupdater="true" events="focus"
|
||||||
oncommandupdate="{_events}.onFocusChange(event);"/>
|
oncommandupdate={_events + ".onFocusChange(event);"}/>
|
||||||
<commandset id="onPentadactylSelect" commandupdater="true" events="select"
|
<commandset id="onPentadactylSelect" commandupdater="true" events="select"
|
||||||
oncommandupdate="{_events}.onSelectionChange(event);"/>
|
oncommandupdate={_events + ".onSelectionChange(event);"}/>
|
||||||
</window>
|
</window>
|
||||||
</e4x>.*
|
</e4x>.elements()
|
||||||
});
|
});
|
||||||
|
|
||||||
this._fullscreen = window.fullScreen;
|
this._fullscreen = window.fullScreen;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const StatusLine = Module("statusline", {
|
|||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
|
let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
|
||||||
let append = <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
let prepend = <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
||||||
<statusbar id="status-bar" dactyl:highlight="StatusLine StatusNormal">
|
<statusbar id="status-bar" dactyl:highlight="StatusLine StatusNormal">
|
||||||
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
|
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
|
||||||
<hbox
|
<hbox
|
||||||
@@ -45,12 +45,12 @@ const StatusLine = Module("statusline", {
|
|||||||
</statusbar>
|
</statusbar>
|
||||||
</e4x>;
|
</e4x>;
|
||||||
|
|
||||||
for each (let attr in append..@key)
|
for each (let attr in prepend..@key)
|
||||||
attr.parent().@id = "dactyl-statusline-field-" + attr;
|
attr.parent().@id = "dactyl-statusline-field-" + attr;
|
||||||
|
|
||||||
util.overlayWindow(window, {
|
util.overlayWindow(window, {
|
||||||
objects: this.widgets = { get status() this.container },
|
objects: this.widgets = { get status() this.container },
|
||||||
append: append.*
|
prepend: prepend.elements()
|
||||||
});
|
});
|
||||||
|
|
||||||
this._statusLine = document.getElementById("status-bar");
|
this._statusLine = document.getElementById("status-bar");
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ const Hive = Class("Hive", {
|
|||||||
this.names = {};
|
this.names = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function cleanup() {
|
||||||
|
for (let sheet in values(this.sheets))
|
||||||
|
sheet.enabled = false;
|
||||||
|
},
|
||||||
|
|
||||||
__iterator__: function () Iterator(this.sheets),
|
__iterator__: function () Iterator(this.sheets),
|
||||||
|
|
||||||
get sites() array(this.sheets).map(function (s) s.sites).flatten().uniq().array,
|
get sites() array(this.sheets).map(function (s) s.sites).flatten().uniq().array,
|
||||||
@@ -214,6 +219,11 @@ const Styles = Module("Styles", {
|
|||||||
this.system = Hive();
|
this.system = Hive();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function cleanup() {
|
||||||
|
for each (let hive in [this.user, this.system])
|
||||||
|
hive.cleanup();
|
||||||
|
},
|
||||||
|
|
||||||
__iterator__: function () Iterator(this.user.sheets.concat(this.system.sheets)),
|
__iterator__: function () Iterator(this.user.sheets.concat(this.system.sheets)),
|
||||||
|
|
||||||
_proxy: function (name, args)
|
_proxy: function (name, args)
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
this.overlays = {};
|
this.overlays = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function cleanup() {
|
||||||
|
for (let win in iter(services.windowMediator.getEnumerator(null)))
|
||||||
|
for (let elem in values(win.document.dactylOverlayElements))
|
||||||
|
if (elem.get() && elem.get().parentNode)
|
||||||
|
elem.get().parentNode.removeChild(elem.get());
|
||||||
|
},
|
||||||
|
|
||||||
// FIXME: Only works for Pentadactyl
|
// FIXME: Only works for Pentadactyl
|
||||||
get activeWindow() services.windowMediator.getMostRecentWindow("navigator:browser"),
|
get activeWindow() services.windowMediator.getMostRecentWindow("navigator:browser"),
|
||||||
dactyl: update(function dactyl(obj) {
|
dactyl: update(function dactyl(obj) {
|
||||||
@@ -90,12 +97,13 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
let observers = obj.observe;
|
let observers = obj.observe;
|
||||||
function register(meth) {
|
function register(meth) {
|
||||||
services.observer[meth](obj, "quit-application", true);
|
services.observer[meth](obj, "quit-application", true);
|
||||||
|
services.observer[meth](obj, "dactyl-unload", true);
|
||||||
for (let target in keys(observers))
|
for (let target in keys(observers))
|
||||||
services.observer[meth](obj, target, true);
|
services.observer[meth](obj, target, true);
|
||||||
}
|
}
|
||||||
Class.replaceProperty(obj, "observe",
|
Class.replaceProperty(obj, "observe",
|
||||||
function (subject, target, data) {
|
function (subject, target, data) {
|
||||||
if (target == "quit-application")
|
if (target == "quit-application" || target == "dactyl-unload")
|
||||||
register("removeObserver");
|
register("removeObserver");
|
||||||
if (observers[target])
|
if (observers[target])
|
||||||
observers[target].call(obj, subject, data);
|
observers[target].call(obj, subject, data);
|
||||||
@@ -908,6 +916,10 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_loadOverlay: function _loadOverlay(window, obj) {
|
_loadOverlay: function _loadOverlay(window, obj) {
|
||||||
|
let doc = window.document;
|
||||||
|
if (!doc.dactylOverlayElements)
|
||||||
|
doc.dactylOverlayElements = [];
|
||||||
|
|
||||||
function overlay(key, fn) {
|
function overlay(key, fn) {
|
||||||
if (obj[key]) {
|
if (obj[key]) {
|
||||||
let iterator = Iterator(obj[key]);
|
let iterator = Iterator(obj[key]);
|
||||||
@@ -915,9 +927,12 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
iterator = ([elem.@id, elem.*, elem.@*::*] for each (elem in obj[key]));
|
iterator = ([elem.@id, elem.*, elem.@*::*] for each (elem in obj[key]));
|
||||||
|
|
||||||
for (let [elem, xml, attr] in iterator) {
|
for (let [elem, xml, attr] in iterator) {
|
||||||
if (elem = window.document.getElementById(elem)) {
|
if (elem = doc.getElementById(elem)) {
|
||||||
fn(elem, util.xmlToDom(xml, window.document, obj.objects));
|
let node = util.xmlToDom(xml, doc, obj.objects);
|
||||||
for each (let attr in attr || [])
|
for (let n in array.iterValues(node.childNodes))
|
||||||
|
doc.dactylOverlayElements.push(Cu.getWeakReference(n));
|
||||||
|
fn(elem, node);
|
||||||
|
for each (let attr in attr || []) // FIXME: Cleanup...
|
||||||
elem.setAttributeNS(attr.namespace(), attr.localName(), attr);
|
elem.setAttributeNS(attr.namespace(), attr.localName(), attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -929,22 +944,27 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
overlay("append", function (elem, dom) elem.appendChild(dom));
|
overlay("append", function (elem, dom) elem.appendChild(dom));
|
||||||
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
||||||
if (obj.init)
|
if (obj.init)
|
||||||
obj.init(window, window.dactylDOMLoaded);
|
obj.init(window, window.document.dactylDOMLoaded);
|
||||||
|
|
||||||
if (obj.load)
|
if (obj.load)
|
||||||
if (window.document.dactylLoaded)
|
if (doc.dactylLoaded)
|
||||||
obj.load(window, window.document.dactylLoaded);
|
obj.load(window, doc.dactylLoaded);
|
||||||
else
|
else
|
||||||
window.document.addEventListener("load", wrapCallback(function load(event) {
|
doc.addEventListener("load", wrapCallback(function load(event) {
|
||||||
if (event.originalTarget === event.target) {
|
if (event.originalTarget === event.target) {
|
||||||
window.document.removeEventListener("load", load.wrapper, true);
|
doc.removeEventListener("load", load.wrapper, true);
|
||||||
window.document.dactylLoaded = event;
|
doc.dactylLoaded = event;
|
||||||
obj.load(window, event);
|
obj.load(window, event);
|
||||||
}
|
}
|
||||||
}), true);
|
}), true);
|
||||||
},
|
},
|
||||||
|
|
||||||
observe: {
|
observe: {
|
||||||
|
"dactyl-cleanup": function () {
|
||||||
|
for (let module in values(defineModule.modules))
|
||||||
|
if (module.cleanup)
|
||||||
|
module.cleanup();
|
||||||
|
},
|
||||||
"toplevel-window-ready": function (window, data) {
|
"toplevel-window-ready": function (window, data) {
|
||||||
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
|
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
|
||||||
if (event.originalTarget === window.document) {
|
if (event.originalTarget === window.document) {
|
||||||
@@ -965,8 +985,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
this.overlays[url] = [];
|
this.overlays[url] = [];
|
||||||
this.overlays[url].push(fn);
|
this.overlays[url].push(fn);
|
||||||
}, this);
|
}, this);
|
||||||
for (let win in services.windowMediator.getEnumerator(null))
|
|
||||||
if (win.dactylDOMLoaded)
|
for (let win in iter(services.windowMediator.getEnumerator(null)))
|
||||||
|
if (win.document.dactylDOMLoaded)
|
||||||
this._loadOverlays(win);
|
this._loadOverlays(win);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user