1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 18:07:58 +01:00
This commit is contained in:
Kris Maglione
2009-04-22 13:15:56 -04:00
parent 9320c5b1be
commit 2f753b6d27
7 changed files with 46 additions and 21 deletions

View File

@@ -565,7 +565,7 @@ function Buffer() //{{{
}
});
commands.add(["pagest[yle]"],
commands.add(["pagest[yle]", "pas"],
"Select the author style sheet to apply",
function (args)
{

View File

@@ -85,10 +85,7 @@ function Editor() //{{{
// Used in addAbbrevation and expandAbbreviation
var abbrevmatch = full_id + "|" + end_id + "|" + non_id;
function getEditor()
{
return window.document.commandDispatcher.focusedElement;
}
function getEditor() liberator.focus;
function getController()
{
@@ -606,7 +603,7 @@ function Editor() //{{{
unselectText: function ()
{
let elem = window.document.commandDispatcher.focusedElement;
let elem = liberator.focus;
// A error occurs if the element has been removed when "elem.selectionStart" is executed.
try {
if (elem && elem.selectionEnd)
@@ -630,7 +627,7 @@ function Editor() //{{{
}
// FIXME: #93 (<s-insert> in the bottom of a long textarea bounces up)
let elem = window.document.commandDispatcher.focusedElement;
let elem = liberator.focus;
if (elem.setSelectionRange && util.readFromClipboard())
// readFromClipboard would return 'undefined' if not checked
@@ -887,7 +884,7 @@ function Editor() //{{{
let textBox = null;
if (!(config.isComposeWindow))
textBox = document.commandDispatcher.focusedElement;
textBox = liberator.focus;
let text = ""; // XXX
if (textBox)

View File

@@ -501,7 +501,7 @@ function Events() //{{{
function isFormElemFocused()
{
let elem = window.document.commandDispatcher.focusedElement;
let elem = liberator.focus;
if (elem == null)
return false;
@@ -591,7 +591,7 @@ function Events() //{{{
if (options["focuscontent"])
{
setTimeout(function () {
let focused = document.commandDispatcher.focusedElement;
let focused = liberator.focus;
if (focused && (focused.value !== undefined) && focused.value.length == 0)
focused.blur();
}, 100);
@@ -963,7 +963,7 @@ function Events() //{{{
shift = (keys[i] >= "A" && keys[i] <= "Z");
}
let elem = window.document.commandDispatcher.focusedElement;
let elem = liberator.focus;
if (!elem)
elem = window.content;

View File

@@ -217,16 +217,16 @@ const liberator = (function () //{{{
for (let [,item] in Iterator(node.childNodes))
{
if (item.childNodes.length == 0 && item.localName == "menuitem"
&& !/rdf:http:/.test(item.label)) // FIXME
&& !/rdf:http:/.test(item.getAttribute("label"))) // FIXME
{
item.fullMenuPath = parent + item.label;
item.fullMenuPath = parent + item.getAttribute("label");
items.push(item);
}
else
{
let path = parent;
if (item.localName == "menu")
path += item.label + ".";
path += item.getAttribute("label") + ".";
addChildren(item, path);
}
}
@@ -600,6 +600,8 @@ const liberator = (function () //{{{
get menuItems() getMenuItems(),
get focus() document.commandDispatcher.focusedElement,
// Global constants
CURRENT_TAB: 1,
NEW_TAB: 2,
@@ -926,9 +928,9 @@ const liberator = (function () //{{{
}
}
catch (e) {}
if (clearFocusedElement && document.commandDispatcher.focusedElement)
document.commandDispatcher.focusedElement.blur();
if (elem && (elem != document.commandDispatcher.focusedElement))
if (clearFocusedElement && liberator.focus)
liberator.focus.blur();
if (elem && elem != liberator.focus)
elem.focus();
},

View File

@@ -257,7 +257,7 @@ function Styles(name, store, serial)
const ios = services.get("io");
const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
const namespace = '@namespace html "' + XHTML + '";\n' +
'@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' +
'@namespace xul "' + XUL + '";\n' +
'@namespace liberator "' + NS.uri + '";\n';
const Sheet = new Struct("name", "sites", "css", "ref", "agent");

View File

@@ -28,7 +28,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
/** @scope modules */
const XHTML = "http://www.w3.org/1999/xhtml";
const XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
const XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
const NS = Namespace("liberator", "http://vimperator.org/namespaces/liberator");
default xml namespace = XHTML;
@@ -404,6 +405,32 @@ const util = { //{{{
if (typeof object != "object")
return false;
const NAMESPACES = util.Array.toObject([
[NS, 'liberator'],
[XHTML, 'html'],
[XUL, 'xul'],
]);
if (object instanceof Node) {
let elem = object;
if (elem.nodeType == elem.TEXT_NODE)
return elem.data;
function namespaced(node) {
var ns = NAMESPACES[node.namespaceURI];
if (ns)
return ns + ":" + node.localName;
return node.localName.toLowerCase();
}
let tag = "<" + [namespaced(elem)].concat(
[namespaced(a) + "=" + template.highlight(a.value, true)
for ([i, a] in util.Array.iteritems(elem.attributes))]).join(" ");
if (!elem.firstChild || /^\s*$/.test(elem.firstChild) && !elem.firstChild.nextSibling)
tag += '/>';
else
tag += '>...</' + namespaced(elem) + '>';
return tag;
}
try
{ // for window.JSON
var obj = String(object);

View File

@@ -104,8 +104,7 @@ const config = { //{{{
focusChange: function(win) {
// we switch to -- MESSAGE -- mode for Muttator, when the main HTML widget gets focus
let elem = window.document.commandDispatcher.focusedElement;
if ((win && win.document && win.document instanceof HTMLDocument) || elem instanceof HTMLAnchorElement)
if (win && win.document instanceof HTMLDocument || liberator.focus instanceof HTMLAnchorElement)
{
if (config.isComposeWindow)
modes.set(modes.INSERT, modes.TEXTAREA);