Browse Source

HUE-6199 [core] Global scroll up anchor on Hue 4

Enrico Berti 8 years ago
parent
commit
c1eb4c0397

+ 6 - 0
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -194,6 +194,12 @@
         $('.hue-datatable-search').find('input').focus();
         $('.hue-datatable-search').find('input').focus();
       }
       }
       var right = -30;
       var right = -30;
+      if (IS_HUE_4){
+        var adjustRight = $(window).width() - ($('.page-content').width() + $('.page-content').offset().left);
+        if (adjustRight > 0) {
+          right = adjustRight;
+        }
+      }
       $('.hueAnchorScroller:visible').each(function () {
       $('.hueAnchorScroller:visible').each(function () {
         var visibleRight = $(this).css('right').replace(/px/gi, '') * 1;
         var visibleRight = $(this).css('right').replace(/px/gi, '') * 1;
         if (!isNaN(visibleRight) && visibleRight > right) {
         if (!isNaN(visibleRight) && visibleRight > right) {

+ 6 - 4
desktop/core/src/desktop/static/desktop/js/jquery.scrollup.js

@@ -88,8 +88,8 @@
     huePubSub.subscribe('reposition.scroll.anchor.up', function(){
     huePubSub.subscribe('reposition.scroll.anchor.up', function(){
       $('#jHueScrollUpAnchor').css('right', '20px');
       $('#jHueScrollUpAnchor').css('right', '20px');
       if (!$(_this.element).is('body') && $(_this.element).is(':visible')) {
       if (!$(_this.element).is('body') && $(_this.element).is(':visible')) {
-        var adjustRight = $(window).width() - $(_this.element).offset().left - $(_this.element).width();
-        if (adjustRight > 20) {
+        var adjustRight = $(window).width() - ($(_this.element).width() + $(_this.element).offset().left);
+        if (adjustRight > 0) {
           $('#jHueScrollUpAnchor').css('right', adjustRight + 'px');
           $('#jHueScrollUpAnchor').css('right', adjustRight + 'px');
         }
         }
       }
       }
@@ -101,8 +101,10 @@
       scrolled.scroll(function () {
       scrolled.scroll(function () {
         if (scrolled.scrollTop() > _this.options.threshold) {
         if (scrolled.scrollTop() > _this.options.threshold) {
           if (link.is(":hidden")) {
           if (link.is(":hidden")) {
-            positionOtherAnchors();
-            link.fadeIn(200, positionOtherAnchors);
+            huePubSub.publish('reposition.scroll.anchor.up');
+            link.fadeIn(200, function(){
+              huePubSub.publish('reposition.scroll.anchor.up');
+            });
           }
           }
           if ($(_this.element).data("lastScrollTop") == null || $(_this.element).data("lastScrollTop") < scrolled.scrollTop()) {
           if ($(_this.element).data("lastScrollTop") == null || $(_this.element).data("lastScrollTop") < scrolled.scrollTop()) {
             $("#jHueScrollUpAnchor").data("caller", scrollable);
             $("#jHueScrollUpAnchor").data("caller", scrollable);

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

@@ -1309,6 +1309,8 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
       }, 10);
       }, 10);
     });
     });
 
 
+    $('.page-content').jHueScrollUp();
+
     window.hueDebug = {
     window.hueDebug = {
       viewModel: function (element) {
       viewModel: function (element) {
         return element ? ko.dataFor(element) : window.hueDebug.onePageViewModel;
         return element ? ko.dataFor(element) : window.hueDebug.onePageViewModel;