]> _ Git - fluidbook-toolbox.git/commitdiff
wait #7467 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 8 Sep 2025 14:40:15 +0000 (16:40 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 8 Sep 2025 14:40:15 +0000 (16:40 +0200)
resources/linkeditor-stable/js/linkeditor.accessibility.js

index a5beef42ca8fa978ca8672bbe3d6d0d3009b42cb..ad01a78184ec82874bf8c45b232d63aa39fc0abd 100644 (file)
@@ -2,6 +2,8 @@ import Sortable from 'sortablejs';
 
 function LinkeditorAccessibility(linkeditor) {
     this.linkeditor = linkeditor;
+    this.interactiveThreshold = 6;
+    this.nonInteractiveTypes = [14, 15, 39];
 }
 
 LinkeditorAccessibility.prototype = {
@@ -63,7 +65,6 @@ LinkeditorAccessibility.prototype = {
     moveSelectionOrder: function (way) {
         let start;
         let selection = this.getCurrentOrderableSelection();
-        console.log(selection);
         let num = selection.length;
         if (num <= 0) {
             return;
@@ -112,17 +113,39 @@ LinkeditorAccessibility.prototype = {
 
 
     filterOrderableLinks: function (links) {
+        let $this = this;
         let res = [];
         $.each(links, function () {
-            if ($(this).attr('fb-calc-depth') < 50) {
-                return;
+            if ($this.isInteractive(this)) {
+                res.push(this);
             }
-            res.push(this);
         });
 
         return this.orderLinks(res);
     },
 
+    isInteractive: function (link) {
+        link = $(link);
+        if (link.attr('fb-calc-depth') < this.interactiveThreshold * 10) {
+            return false;
+        }
+        if (this.nonInteractiveTypes.indexOf(parseInt(link.attr('fb-type'))) > -1) {
+            return false;
+        }
+        let x = parseFloat(link.attr('fb-left'));
+        let y = parseFloat(link.attr('fb-top'));
+        let w = parseFloat(link.attr('fb-width'));
+        let h = parseFloat(link.attr('fb-height'));
+        if (x > this.linkeditor.fw || y > this.linkeditor.fh) {
+            return false;
+        }
+        if (x + w < 0 || y + h < 0) {
+            return false;
+        }
+        return true;
+
+    },
+
     orderLinks: function (links) {
         let arr = links;
         if (links instanceof jQuery) {
@@ -219,8 +242,11 @@ LinkeditorAccessibility.prototype = {
         let $this = this;
         let links = [];
         $('#linkeditor-links .link:not(.pendingCreate)').each(function () {
-            let level = $this.getLinkLevel($(this));
-            links.push({link: $(this), interactive: level >= 5, order: parseFloat($(this).attr('fb-order'),)});
+            links.push({
+                link: $(this),
+                interactive: $this.isInteractive($(this)),
+                order: parseFloat($(this).attr('fb-order'),)
+            });
         });
 
         links.sort(function (a, b) {
@@ -248,7 +274,7 @@ LinkeditorAccessibility.prototype = {
     getLinkLevel: function (link) {
         let d = parseInt($(link).attr('fb-calc-depth'));
         var m = 1;
-        if (d >= 30 && d < 50) {
+        if (d >= 30 && d < this.interactiveThreshold * 10) {
             m = 10;
         }
         return Math.floor((m * d) / 10) / m;
@@ -271,8 +297,7 @@ LinkeditorAccessibility.prototype = {
             let type = $(this).attr('fb-type');
             let dest = $(this).attr('fb-to');
             let uid = $(this).attr('fb-uid');
-            let level = $this.getLinkLevel($(this));
-            let interactive = level >= 5;
+            let interactive = $this.isInteractive($(this));
 
             if (dest === '') {
                 dest = '<em>' + TRANSLATIONS.empty + '</em>';
@@ -365,8 +390,8 @@ LinkeditorAccessibility.prototype = {
 
     updateSelection() {
         this.linkeditor.panels.updatePanelSelection(this);
-        let l=this.getCurrentOrderableSelection().length;
-        if(l<1){
+        let l = this.getCurrentOrderableSelection().length;
+        if (l < 1) {
             $('[data-action="accessibility.moveSelectionOrder"]').addClass('disabled');
         } else {
             $('[data-action="accessibility.moveSelectionOrder"]').removeClass('disabled');