]> _ Git - fluidbook-html5.git/commitdiff
wip #3775 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Jul 2020 17:16:14 +0000 (19:16 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Jul 2020 17:16:14 +0000 (19:16 +0200)
js/libs/fluidbook/fluidbook.tooltip.js
style/00-import.less
style/accessibility.less [new file with mode: 0644]

index 356eb694e5da5a130d99500193bc3199b15f44c4..4a47a970ca0054675dd11bd7421db601c01a0f7f 100644 (file)
@@ -3,6 +3,7 @@ function FluidbookTooltip(fluidbook) {
     this.displaying = false;
     this.mouseX = 0;
     this.mouseY = 0;
+    this.type = 'mouse';
     this.init();
 }
 
@@ -11,6 +12,10 @@ FluidbookTooltip.prototype = {
         var $this = this;
 
         $(window).on('mousemove', function (e) {
+            if ($this.type === 'keyboard') {
+                $this.type = 'mouse';
+                $this.hideTooltip();
+            }
             $this.updateMousePosition(e);
         });
 
@@ -20,11 +25,21 @@ FluidbookTooltip.prototype = {
 
 
         $(document).on('mouseover', 'a[data-tooltip]', function (e) {
+            $this.type = 'mouse';
             $this.updateMousePosition(e);
             $this.eventTriggered(this);
         });
+        $(document).on('focus', 'a[data-tooltip]', function (e) {
+            $this.type = 'keyboard';
+            var rect = this.getBoundingClientRect();
+            $this.updateMousePosition({pageX: rect.x + rect.width / 2, pageY: rect.y + rect.height / 2});
+            $this.eventTriggered(this);
+        });
+        $(document).on('blur', 'a[data-tooltip]', function (e) {
+            $this.hideTooltip();
+        });
 
-        $("body").append('<div id="tooltip" aria-hidden="true"></div>');
+        $("body").append('<div id="tooltip" role="tooltip"></div>');
     },
 
     updateMousePosition: function (e) {
index 29824c56004cb1a31e3b7a261f46378dd60291cb..bede759d3d64523fdd6dfbe035dab685daa36823 100644 (file)
@@ -1,4 +1,5 @@
 @import "variables";
 @import "mixins";
 @import "mmenu/mmenu";
-@import "nav-horizontal";
\ No newline at end of file
+@import "nav-horizontal";
+@import "accessibility";
\ No newline at end of file
diff --git a/style/accessibility.less b/style/accessibility.less
new file mode 100644 (file)
index 0000000..ad8b373
--- /dev/null
@@ -0,0 +1,9 @@
+.visually-hidden, #accessible-contents {
+  clip-path: inset(100%);
+  clip: rect(1px, 1px, 1px, 1px);
+  height: 1px;
+  overflow: hidden;
+  position: absolute;
+  white-space: nowrap;
+  width: 1px;
+}
\ No newline at end of file