mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 07:57:59 +01:00
Add 'Copy File Path' MOW context menu item. Fix some bugs.
This commit is contained in:
@@ -21,6 +21,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
<menuitem id="dactyl-context-copylink"
|
||||
label="Copy Link Location" dactyl:group="link"
|
||||
oncommand="goDoCommand('cmd_copyLink');"/>
|
||||
<menuitem id="dactyl-context-copypath"
|
||||
label="Copy File Path" dactyl:group="link path"
|
||||
oncommand="dactyl.clipboardWrite(document.popupNode.getAttribute('path'));"/>
|
||||
<menuitem id="dactyl-context-copy"
|
||||
label="Copy" dactyl:group="selection"
|
||||
command="cmd_copy"/>
|
||||
@@ -937,14 +940,21 @@ var CommandLine = Module("commandline", {
|
||||
},
|
||||
|
||||
onContext: function onContext(event) {
|
||||
let enabled = {
|
||||
link: window.document.popupNode instanceof HTMLAnchorElement,
|
||||
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
||||
};
|
||||
try {
|
||||
let enabled = {
|
||||
link: window.document.popupNode instanceof HTMLAnchorElement,
|
||||
path: window.document.popupNode.hasAttribute("path"),
|
||||
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
||||
};
|
||||
|
||||
for (let [, node] in iter(event.target.childNodes)) {
|
||||
let group = node.getAttributeNS(NS, "group");
|
||||
node.hidden = group && !group.split(/\s+/).some(function (g) enabled[g]);
|
||||
for (let node in array.iterValues(event.target.children)) {
|
||||
let group = node.getAttributeNS(NS, "group");
|
||||
util.dump(node, group, group && !group.split(/\s+/).every(function (g) enabled[g]));
|
||||
node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -1100,6 +1110,9 @@ var CommandLine = Module("commandline", {
|
||||
event.originalTarget.hasAttributeNS(NS, "command"))) {
|
||||
|
||||
let command = event.originalTarget.getAttributeNS(NS, "command");
|
||||
if (command && event.button == 2)
|
||||
return PASS;
|
||||
|
||||
if (command && dactyl.commands[command]) {
|
||||
event.preventDefault();
|
||||
return dactyl.withSavedValues(["forceNewTab"], function () {
|
||||
|
||||
@@ -363,7 +363,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
userEval: function (str, context, fileName, lineNumber) {
|
||||
if (jsmodules.__proto__ != window)
|
||||
str = "with (window) { with (modules) { this.eval(" + str.quote() + ") } }";
|
||||
str = "with (window) { with (modules) { (this.eval || eval)(" + str.quote() + ") } }";
|
||||
|
||||
if (fileName == null)
|
||||
if (io.sourcing && io.sourcing.file[0] !== "[")
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
dump(" ======================= bootstrap.jsm " + (typeof JSMLoader) + " ======================= \n");
|
||||
|
||||
var EXPORTED_SYMBOLS = ["JSMLoader"];
|
||||
let global = this;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ var Download = Class("Download", {
|
||||
<li highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
|
||||
<span highlight="DownloadTitle">
|
||||
<span highlight="Link">
|
||||
<a key="title" href={self.target.spec}>{self.displayName}</a>
|
||||
<a key="title" href={self.target.spec} path={self.targetFile.path}>{self.displayName}</a>
|
||||
<span highlight="LinkInfo">{self.targetFile.path}</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -114,10 +114,11 @@ var Services = Module("Services", {
|
||||
}
|
||||
|
||||
["aboutURL", "creator", "description", "developers",
|
||||
"homepageURL", "iconURL", "installDate",
|
||||
"optionsURL", "releaseNotesURI", "updateDate", "version"].forEach(function (item) {
|
||||
addon[item] = getRdfProperty(addon, item);
|
||||
"homepageURL", "installDate", "optionsURL",
|
||||
"releaseNotesURI", "updateDate"].forEach(function (item) {
|
||||
memoize(addon, item, function (item) getRdfProperty(this, item));
|
||||
});
|
||||
|
||||
update(addon, {
|
||||
|
||||
appDisabled: false,
|
||||
@@ -148,7 +149,7 @@ var Services = Module("Services", {
|
||||
for (let [, item] in Iterator(services.extensionManager
|
||||
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
|
||||
res.push(this.getAddonByID(item));
|
||||
callback(res);
|
||||
return (callback || util.identity)(res);
|
||||
},
|
||||
getInstallForFile: function (file, callback, mimetype) {
|
||||
callback({
|
||||
@@ -207,14 +208,7 @@ var Services = Module("Services", {
|
||||
const self = this;
|
||||
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
|
||||
throw TypeError();
|
||||
this.__defineGetter__(name, function () {
|
||||
let res = self._create(class_, ifaces, meth);
|
||||
if (!res)
|
||||
return null;
|
||||
|
||||
delete this[name];
|
||||
return this[name] = res;
|
||||
});
|
||||
memoize(this, name, function () self._create(class_, ifaces, meth));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -262,12 +262,13 @@ var Template = Module("Template", {
|
||||
|
||||
sourceLink: function (frame) {
|
||||
let url = (frame.filename || "unknown").replace(/.* -> /, "");
|
||||
let path = util.urlPath(url);
|
||||
|
||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||
return <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource"
|
||||
href={url} line={frame.lineNumber}
|
||||
href={url} path={path} line={frame.lineNumber}
|
||||
highlight="URL">{
|
||||
util.urlPath(url) + ":" + frame.lineNumber
|
||||
path + ":" + frame.lineNumber
|
||||
}</a>
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user