clear: function () {
$("#linkeditor-links").html('');
},
+
+ alignSelection: function (align) {
+ if (align === 'left' || align === 'top') {
+ var min = 1000000;
+ $.each(this.getCurrentSelection(), function () {
+ min = Math.min(min, parseFloat($(this).attr('fb-' + align)));
+ });
+ $.each(this.getCurrentSelection(), function () {
+ $(this).attr('fb-' + align, min);
+ });
+ } else if (align === 'right' || align === 'bottom') {
+ var b = align === 'right' ? 'left' : 'top';
+ var l = align === 'right' ? 'width' : 'height';
+ var max = -10000000;
+ $.each(this.getCurrentSelection(), function () {
+ max = Math.max(max, parseFloat($(this).attr('fb-' + b)) + parseFloat($(this).attr('fb-' + l)));
+ });
+ $.each(this.getCurrentSelection(), function () {
+ $(this).attr('fb-' + b, max - parseFloat($(this).attr('fb-' + l)));
+ });
+ } else if (align === 'center' || align === 'middle') {
+ var b = align === 'center' ? 'left' : 'top';
+ var l = align === 'center' ? 'width' : 'height';
+ var max = -10000000;
+ var min = 1000000;
+ $.each(this.getCurrentSelection(), function () {
+ min = Math.min(min, parseFloat($(this).attr('fb-' + b)));
+ max = Math.max(max, parseFloat($(this).attr('fb-' + b)) + parseFloat($(this).attr('fb-' + l)));
+ });
+ var center = min + ((max - min) / 2);
+ $.each(this.getCurrentSelection(), function () {
+ $(this).attr('fb-' + b, center - parseFloat($(this).attr('fb-' + l)) / 2);
+ });
+ }
+
+ this.linkeditor.hasChanged();
+ },
+ distributeSelection: function (axis) {
+
+ },
};
module.exports = LinkeditorLinks;
</nav>
<nav id="linkeditor-toolbar-right">
<div class="when-selection-3">
- <a href="#" data-action="distributeSelection.horizontally"
+ <a href="#" data-action="links.distributeSelection" data-action-args="x"
data-tooltip="{{__('Distribuer la sélection horizontalement')}}"
data-icon="distribute-horizontally"></a>
- <a href="#" data-action="distributeSelection.vertically"
+ <a href="#" data-action="links.distributeSelection" data-action-args="y"
data-tooltip="{{__('Distribuer la sélection verticalement')}}"
data-icon="distribute-vertically"></a>
<div class="separator"></div>
</div>
<div class="when-selection-2">
@foreach($alignments as $a=>$label)
- <a href="#" data-action="alignSelection.{{$a}}" data-tooltip="{{$label}}"
+ <a href="#" data-action="links.alignSelection" data-action-args="{{$a}}"
+ data-tooltip="{{$label}}"
data-icon="align-{{$a}}"></a>
@endforeach
</div>