function LinkeditorAccessibility(linkeditor) {
this.linkeditor = linkeditor;
+ this.interactiveThreshold = 6;
+ this.nonInteractiveTypes = [14, 15, 39];
}
LinkeditorAccessibility.prototype = {
moveSelectionOrder: function (way) {
let start;
let selection = this.getCurrentOrderableSelection();
- console.log(selection);
let num = selection.length;
if (num <= 0) {
return;
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) {
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) {
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;
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>';
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');