$(window).on('keydown', function (e) {
- if (e.keyCode == 32) {
+ if (e.keyCode == 16) {
+ $("#linkeditor-main").addClass('selection');
+ } else if (e.keyCode == 32) {
if (!$this.mobileFirst) {
$("#linkeditor-main").addClass('grab');
}
- return false;
} else if (e.keyCode == 18) {
$("#linkeditor-main").addClass('duplicate');
- return false;
}
$this.rulers.moveRuler();
});
// Disable scroll by spacebar
$(window).on('keyup', function (e) {
- if (e.keyCode == 32) {
+ if (e.keyCode == 16) {
+ $("#linkeditor-main").removeClass('selection');
+ } else if (e.keyCode == 32) {
$this.zoom.resetZoomDrag();
} else if (e.keyCode == 18) {
$("#linkeditor-main").removeClass('duplicate');
- return false;
}
$this.rulers.moveRuler();
});
}
var deselectAll = true;
- if ($('#linkeditor-main').hasClass('duplicate')) {
+ if ($('#linkeditor-main').hasClass('selection')) {
+ $this.links.startRectSelection();
+ return false;
+ } else if ($('#linkeditor-main').hasClass('duplicate')) {
$this.links.duplicateLinkClick();
return false;
} else if ($('#linkeditor-main').hasClass('grab')) {
this.contextMenuPosition = null;
+ this.rectSelection = null;
+
this.dropTypes = [4, 7, 12, 15, 16, 17, 18, 25, 30, 31];
this.init();
},
mouseUp: function () {
+ this.endRectSelection();
this.stopDragLink();
this.stopResizeLink();
this.cleanPendingCreateLink();
},
moveDragLink: function () {
+ if (this.updateRectSelection()) {
+ return;
+ }
if (this.dragLinkPos === null) {
return;
}
this.linkeditor.hasChanged();
},
- dimensionSelection: function (dimension) {
- let d = this.getMinMaxSelection(dimension);
- this.getCurrentSelection().each(function () {
- $(this).attr('fb-' + dimension, d.maxl);
- });
- this.updateSelectionData([dimension]);
- this.linkeditor.hasChanged();
+ dimensionSelection: function (dimension, skipChanged) {
+ if (dimension === 'both') {
+ this.dimensionSelection('width', true);
+ this.dimensionSelection('height', true);
+
+ } else {
+ let d = this.getMinMaxSelection(dimension);
+ this.getCurrentSelection().each(function () {
+ $(this).attr('fb-' + dimension, d.maxl);
+ });
+ }
+ if (skipChanged !== true) {
+ this.updateSelectionData([dimension]);
+ this.linkeditor.hasChanged();
+ }
},
updateLinkData: function (id, data) {
this.linkeditor.hasChanged(false);
},
+
+
+ startRectSelection: function () {
+ $('.link.selected').addClass('selectedBeforeRect');
+ this.rectSelection = this.linkeditor.globalToCanvas(this.linkeditor.mx, this.linkeditor.my);
+ },
+
+ updateRectSelection: function () {
+ if (this.rectSelection === null) {
+ return false;
+ }
+
+ var $this = this;
+ let pos = this.linkeditor.globalToCanvas(this.linkeditor.mx, this.linkeditor.my);
+
+ var css = {};
+ css.width = pos.x - this.rectSelection.x;
+ css.height = pos.y - this.rectSelection.y;
+ css.left = this.rectSelection.x;
+ css.top = this.rectSelection.y;
+ if (css.width < 0) {
+ css.left = pos.x;
+ css.width *= -1;
+ }
+ if (css.height < 0) {
+ css.top = pos.y;
+ css.height *= -1;
+ }
+
+ $("#linkeditor-selectlink-rect").show();
+ $("#linkeditor-selectlink-rect").css(css);
+
+ let selectRect = $("#linkeditor-selectlink-rect").get(0).getBoundingClientRect();
+ $(".link:not(.selectedBeforeRect)").each(function () {
+ if ($this.linkeditor.utils.intersectRect($(this).get(0).getBoundingClientRect(), selectRect)) {
+ $this.selectLink(this);
+ } else {
+ $this.deselectLink(this);
+ }
+ });
+
+ return true;
+ },
+
+ endRectSelection: function () {
+ if (this.rectSelection === null) {
+ return false;
+ }
+ $(".selectedBeforeRect").removeClass('selectedBeforeRect');
+ $("#linkeditor-selectlink-rect").hide();
+ this.rectSelection = null;
+ return true;
+ },
+
+
};
module.exports = LinkeditorLinks;
&.grabbing
cursor: grabbing
- #linkeditor-duplicatelink-overlay
+ #linkeditor-duplicatelink-overlay, #linkeditor-selectlink-overlay
display: none
position: absolute
z-index: 700
max-height: calc(100% - $rulers-size)
width: calc(100% - $rulers-size)
max-width: calc(100% - $rulers-size)
- cursor: copy
&.duplicate
#linkeditor-duplicatelink-overlay
display: block
+ cursor: copy
+
+ &.selection
+ #linkeditor-selectlink-overlay
+ display: block
+ cursor: crosshair
+
+ #linkeditor-selectlink-rect
+ border: 1px dashed #000000
+ background-color: rgba(255, 255, 255, 0.25)
+ position: absolute
#linkeditor-editor
position: relative