Bug 1026560 - Make clicking the [docs] link in the type information popup in Scratchpad open the MDN page in a new window. r=past, a=lmandel
☠☠ backed out by 7003d83dec14 ☠ ☠
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 18 Jun 2014 07:14:00 -0400
changeset 207419 6c738b09cda1ffd5f6188b8e9e83fe5d32b375ba
parent 207418 c90e69bc6c7de85a0efbbb44dc7adacc2574569b
child 207420 b124230d0fa9a7d2f7ebdaef99f4921b4e141676
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast, lmandel
bugs1026560
milestone32.0a2
Bug 1026560 - Make clicking the [docs] link in the type information popup in Scratchpad open the MDN page in a new window. r=past, a=lmandel
browser/devtools/sourceeditor/autocomplete.js
browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
--- a/browser/devtools/sourceeditor/autocomplete.js
+++ b/browser/devtools/sourceeditor/autocomplete.js
@@ -15,30 +15,55 @@ const privates = new WeakMap();
 
 /**
  * Prepares an editor instance for autocompletion.
  */
 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-" +
                         Editor.keyFor("autocompletion", { noaccel: true });
   if (ed.config.mode == Editor.modes.js) {
     let defs = [
       "tern/browser",
       "tern/ecma5",
     ].map(require);
 
     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);
     });
 
     let keyMap = {};
 
     keyMap[autocompleteKey] = (cm) => {
       cm.tern.getHint(cm, (data) => {
--- a/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
@@ -13,17 +13,17 @@
 # A good criteria is the language in which you'd find the best documentation
 # on web development on the web.
 
 # LOCALIZATION NOTE  (findCmd.promptTitle): This is the dialog title used
 # 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.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:
 
 # LOCALIZATION NOTE  (gotoLineCmd.promptTitle): This is the dialog title used
 # when the user wants to jump to a specific line number in the code. You can
 # access this feature by pressing Ctrl-J on Windows/Linux or Cmd-J on Mac.
 gotoLineCmd.promptTitle=Go to line…
@@ -44,16 +44,25 @@ annotation.breakpoint.title=Breakpoint: 
 annotation.currentLine=Current line
 
 # LOCALIZATION NOTE  (annotation.debugLocation.title): This is the text shown in
 # a tooltip displayed in any of the editor gutters when the user hovers the
 # current debugger location. The debugger can pause the JavaScript execution at
 # 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.
 jumpToLine.commandkey=J
 
 # LOCALIZATION NOTE  (toggleComment.commandkey): This is the key to use in
 # conjunction with accel (Command on Mac or Ctrl on other platforms) to either
 # comment or uncomment selected lines in the editor.