Bug 1026560 - Make clicking the [docs] link in the type information popup in Scratchpad open the MDN page in a new window. r=past

This commit is contained in:
Brian Grinstead 2014-06-18 07:14:00 -04:00
Родитель 02b9c20dcb
Коммит 5ffac867f9
2 изменённых файлов: 37 добавлений и 3 удалений

Просмотреть файл

@ -20,7 +20,7 @@ function setupAutoCompletion(ctx, options) {
let { cm, ed, Editor } = ctx;
let win = ed.container.contentWindow.wrappedJSObject;
let {CodeMirror} = win;
let { CodeMirror, document } = win;
let completer = null;
let autocompleteKey = "Ctrl-" +
@ -33,7 +33,32 @@ function setupAutoCompletion(ctx, options) {
CM_TERN_SCRIPTS.forEach(ed.loadScript, ed);
win.tern = require("tern/tern");
cm.tern = new CodeMirror.TernServer({ defs: defs });
cm.tern = new CodeMirror.TernServer({
defs: defs,
typeTip: function(data) {
let tip = document.createElement("span");
tip.className = "CodeMirror-Tern-information";
let tipType = document.createElement("strong");
tipType.appendChild(document.createTextNode(data.type || cm.l10n("autocompletion.notFound")));
tip.appendChild(tipType);
if (data.doc) {
tip.appendChild(document.createTextNode(" — " + data.doc));
}
if (data.url) {
tip.appendChild(document.createTextNode(" "));
let docLink = document.createElement("a");
docLink.textContent = "[" + cm.l10n("autocompletion.docsLink") + "]";
docLink.href = data.url;
docLink.className = "theme-link";
docLink.setAttribute("target", "_blank");
tip.appendChild(docLink);
}
return tip;
}
});
cm.on("cursorActivity", (cm) => {
cm.tern.updateArgHints(cm);
});

Просмотреть файл

@ -18,7 +18,7 @@
# access this feature by pressing Ctrl-F on Windows/Linux or Cmd-F on Mac.
findCmd.promptTitle=Find…
# LOCALIZATION NOTE (gotoLineCmd.promptMessage): This is the message shown when
# LOCALIZATION NOTE (findCmd.promptMessage): This is the message shown when
# the user wants to search for a string in the code. You can
# access this feature by pressing Ctrl-F on Windows/Linux or Cmd-F on Mac.
findCmd.promptMessage=Search for:
@ -49,6 +49,15 @@ annotation.currentLine=Current line
# user-defined lines.
annotation.debugLocation.title=Current step: %S
# LOCALIZATION NOTE (autocompletion.docsLink): This is the text shown on
# the link inside of the documentation popup. If you type 'document' in Scratchpad
# then press Shift+Space you can see the popup.
autocompletion.docsLink=docs
# LOCALIZATION NOTE (autocompletion.notFound): This is the text shown in
# the documentation popup if Tern fails to find a type for the object.
autocompletion.notFound=not found
# LOCALIZATION NOTE (jumpToLine.commandkey): This is the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to jump to
# a specific line in the editor.