浏览代码

HUE-6852 [editor] Scroll left does not disappear when going to metastore from editor

Enrico Berti 8 年之前
父节点
当前提交
99300ff

+ 19 - 3
desktop/core/src/desktop/static/desktop/js/jquery.scrollleft.js

@@ -47,7 +47,8 @@
 
   Plugin.prototype.setupScrollLeft = function () {
     var _this = this,
-      link = null;
+      link = null,
+      isActive = true;
 
     if ($("#jHueScrollLeftAnchor").length > 0) { // just one scroll up per page
       link = $("#jHueScrollLeftAnchor");
@@ -86,7 +87,9 @@
         if (scrolled.scrollLeft() > _this.options.threshold) {
           if (link.is(":hidden")) {
             positionOtherAnchors();
-            link.fadeIn(200, positionOtherAnchors);
+            if (isActive) {
+              link.fadeIn(200, positionOtherAnchors);
+            }
           }
           if ($(_this.element).data("lastScrollLeft") == null || $(_this.element).data("lastScrollLeft") < scrolled.scrollLeft()) {
             $("#jHueScrollLeftAnchor").data("caller", scrollable);
@@ -116,7 +119,9 @@
         }
       });
       if (_allOk) {
-        link.fadeOut(200, positionOtherAnchors);
+        if (isActive) {
+          link.fadeOut(200, positionOtherAnchors);
+        }
         $("#jHueScrollLeftAnchor").data("caller", null);
       }
     }
@@ -135,6 +140,17 @@
       }
       return false;
     });
+
+    huePubSub.subscribe('hue.scrollleft.show', function () {
+      isActive = true;
+    });
+
+    huePubSub.subscribe('hue.scrollleft.hide', function () {
+      isActive = false;
+      if (link.is(":visible")) {
+        link.hide();
+      }
+    });
   };
 
   $.fn[pluginName] = function (options) {

+ 1 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -791,6 +791,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           $('.tooltip').hide();
           huePubSub.publish('hue.datatable.search.hide');
           huePubSub.publish('nicescroll.resize');
+          huePubSub.publish('hue.scrollleft.hide');
           huePubSub.publish('context.panel.visible.editor', false);
           if (app === 'filebrowser') {
             $(window).unbind('hashchange.fblist');

+ 1 - 0
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -2845,6 +2845,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
     huePubSub.subscribe('app.gained.focus', function (app) {
       if (app === 'editor') {
         huePubSub.publish('redraw.fixed.headers');
+        huePubSub.publish('hue.scrollleft.show');
       }
     }, HUE_PUB_SUB_EDITOR_ID);