this.update();
},
+ reorderSelection: function (way) {
+ let selection = this.getCurrentOrderableSelection();
+ let selectedOrder = parseInt($(selection).eq(0).attr('fb-order'));
+ selection = this.orderLinksByPosition(selection, way);
+ $(selection).each(function () {
+ $(this).attr('fb-order', selectedOrder++);
+ });
+ this.normalizeLinksOrder();
+ },
+
moveSelectionOrder: function (way) {
let start;
let selection = this.getCurrentOrderableSelection();
});
},
+ orderLinksByPosition: function (links, way) {
+ let doublePage = !this.linkeditor.single && !this.linkeditor.utils.isSpecialPage(this.linkeditor.currentPage);
+ let pw = this.linkeditor.pw;
+
+ return $(links).toArray().sort(function (a, b) {
+ let pa = 0;
+ let pb = 0;
+ let xa = parseFloat($(a).attr('fb-left'));
+ let xb = parseFloat($(b).attr('fb-left'));
+ if (doublePage) {
+ if (xa >= pw) {
+ xa -= pw;
+ pa++;
+ }
+ if (xb >= pw) {
+ xb -= pw;
+ pb++;
+ }
+ if (pa !== pb) {
+ return pa - pb;
+ }
+ }
+
+
+ let wa = parseFloat($(a).attr('fb-width'));
+ let wb = parseFloat($(b).attr('fb-width'));
+
+ let xTolerance = Math.min(wa, wb) / 2;
+
+ let ha = parseFloat($(a).attr('fb-height'));
+ let hb = parseFloat($(b).attr('fb-height'));
+
+ let yTolerance = Math.min(ha, hb) / 2;
+
+ xa += wa / 2;
+ xb += wb / 2;
+
+ let ya = parseFloat($(a).attr('fb-top')) + ha / 2;
+ let yb = parseFloat($(b).attr('fb-top')) + hb / 2;
+
+ let xdiff = xa - xb;
+ let ydiff = ya - yb;
+
+ if (way === 'horizontal') {
+ return Math.abs(xdiff) > xTolerance ? xdiff : ydiff;
+ } else if (way === 'vertical') {
+ return Math.abs(ydiff) > yTolerance ? ydiff : xdiff;
+ }
+ });
+ },
+
getCurrentOrderableSelection: function () {
return this.filterOrderableLinks(this.linkeditor.links.getCurrentSelection());
},
let i = 0;
$(links).each(function (k, v) {
$(v.link).attr('fb-order', i++);
+ $(v.link).attr('fb-orderable', v.interactive ? '1' : '0');
});
if (refresh) {
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;
if (dest === '') {
dest = '<em>' + TRANSLATIONS.empty + '</em>';
l += '<input name="' + uid + '" type="checkbox"> ';
l += '<label class="layer" data-uid="' + uid + '">';
l += dest;
- l += '<span class="order">#' + $(this).attr('fb-order') + '</span>';
+ if (interactive) {
+ l += '<span class="order">#' + $(this).attr('fb-order') + '</span>';
+ }
l += '</label>';
l += '</div>';
- let level = $this.getLinkLevel($(this));
+
accessibility.push({
- interactive: level >= 5,
+ interactive: interactive,
zindex: parseInt($(this).attr('fb-calc-zindex')),
html: l,
order: parseInt($(this).attr('fb-order')),
}
};
var selection = $(".link.selected");
+ var orderableSelection = $('.link[fb-orderable="1"].selected');
var multiple = selection.length > 1;
var hasSelection = selection.length > 0;
+ var hasOrderableSelection = orderableSelection.length > 0;
+ var hasMultipleOrderableSelection = orderableSelection.length > 1;
var hasClipboard = !$this.linkeditor.clipboard.isEmpty();
res.items = {
}
});
}
- if (hasSelection) {
+ if (hasOrderableSelection) {
res.items = $.extend(res.items, {
'sep_order': '---------', "order": {
name: (TRANSLATIONS.edit_link_order) + '', items: {
}
},
});
+ if (hasMultipleOrderableSelection) {
+ res.items = $.extend(res.items, {
+ "order_selection": {
+ name: (TRANSLATIONS.reorder_selection) + '', items: {
+ 'reorder_horizontal': {
+ name: TRANSLATIONS.reorder_horizontal, callback: function () {
+ $this.reorderSelection('horizontal');
+ }
+ }, 'reorder_vertical': {
+ name: TRANSLATIONS.reorder_vertical, callback: function () {
+ $this.reorderSelection('vertical');
+ }
+ },
+ }
+ },
+ });
+ }
}
if (hasSelection) {
res.items = $.extend(res.items, {
return this.linkeditor.accessibility.moveSelectionOrder(way);
},
+ reorderSelection: function (way) {
+ return this.linkeditor.accessibility.reorderSelection(way);
+ },
+
key: function (shortcut, scope) {
var $this = this;
key(shortcut, function (event, handler) {