Преглед изворни кода

HUE-1411 [pig] Autocomplete doesn't work on the recent Firefox versions

Added jQuery specific code
Removed displaying of context menu while editing on CodeMirror
Enrico Berti пре 12 година
родитељ
комит
3e5b99d

+ 7 - 0
apps/beeswax/src/beeswax/templates/execute.mako

@@ -751,6 +751,9 @@ ${layout.menubar(section='query')}
       };
 
       CodeMirror.commands.autocomplete = function (cm) {
+        $(document.body).on("contextmenu", function (e) {
+          e.preventDefault(); // prevents native menu on FF for Mac from being shown
+        });
         if ($.totalStorage('tables_' + $("#id_query-database").val()) == null) {
           CodeMirror.showHint(cm, AUTOCOMPLETE_SET);
           getTables(function () {}); // if preload didn't work, tries again
@@ -878,6 +881,10 @@ ${layout.menubar(section='query')}
         $("#validationResults").empty();
       });
 
+      codeMirror.on("blur", function () {
+        $(document.body).off("contextmenu");
+      });
+
       codeMirror.on("change", function () {
         $(".query").val(codeMirror.getValue());
       });

+ 7 - 0
apps/pig/src/pig/templates/app.mako

@@ -652,6 +652,9 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
     }
 
     CodeMirror.commands.autocomplete = function (cm) {
+      $(document.body).on("contextmenu", function (e) {
+        e.preventDefault(); // prevents native menu on FF for Mac from being shown
+      });
       storeVariables();
       var _line = codeMirror.getLine(codeMirror.getCursor().line);
       var _partial = _line.substring(0, codeMirror.getCursor().ch);
@@ -744,6 +747,10 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
       }
     });
 
+    codeMirror.on("blur", function () {
+      $(document.body).off("contextmenu");
+    });
+
     codeMirror.on("change", function () {
       if (viewModel.currentScript().script() != codeMirror.getValue()) {
         viewModel.currentScript().script(codeMirror.getValue());

+ 8 - 3
desktop/core/static/js/Source/jHue/codemirror-pig-hint.js

@@ -97,9 +97,14 @@
     }
 
     function strip(html){
-      var tmp = document.createElement("DIV");
-      tmp.innerHTML = html;
-      return tmp.textContent||tmp.innerText;
+      if (jQuery) {
+        return $("<div>").html(html).text();
+      }
+      else {
+        var tmp = document.createElement("DIV");
+        tmp.innerHTML = html;
+        return tmp.textContent || tmp.innerText;
+      }
     }
 
     function gatherCompletions(obj) {