Route::match(['post'], $segment . '/{id}/edit/links/import/replace', $controller . '@importLinks');
Route::match(['post'], $segment . '/{id}/edit/links/move', $controller . '@moveLinks');
Route::match(['get'], $segment . '/{id}/edit/links/versions/restore/{version}', $controller . '@restoreLinks');
+ Route::match(['get'], $segment . '/{id}/edit/links/fixdriftedlinks', $controller . '@fixDriftedLinks');
Route::match(['get'], $segment . '/{id}/edit/links/assets/{file}', $controller . '@getLinkAsset');
Route::put($segment . '/{id}/save/links', $controller . '@saveLinks');
}
return view('fluidbook_publication.link_editor', ['id' => $id, 'fluidbook' => FluidbookPublication::find($id)]);
}
+
+
+ protected function fixDriftedLinks($fluidbook_id)
+ {
+ if (!FluidbookPublication::hasPermission($fluidbook_id)) {
+ abort(401);
+ }
+ /** @var FluidbookPublication $book */
+ $book = FluidbookPublication::find($fluidbook_id);
+ $w = $book->getPageWidth();
+ $w2 = $w * 2;
+ Links::getLinksAndRulers($fluidbook_id, $links, $rulers);
+ foreach ($links as $i => $link) {
+ $change = false;
+ while (true) {
+ if ($link['page'] % 2 === 0) {
+ $diff = $link['left'] - $w2;
+ } else {
+ $diff = $link['left'] - $w;
+ }
+ if ($diff < 0) {
+ break;
+ }
+ $change = true;
+ $link['left'] -= $w;
+ }
+ if ($change) {
+ $links[$i] = $link;
+ }
+ }
+ Links::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Corriger la dérive des liens"), $links, $rulers, [], []);
+ }
}
return false;
});
- this.key('ctrl+a', function () {
+ this.key('ctrl+alt+shift+f', function () {
+ $this.fixDriftedLinks();
+ });
+
+ this.key('ctrl+a', function () {
$this.selectAll();
return false;
});
})
},
+
+ fixDriftedLinks: function () {
+ var $this = this;
+ var callback = function () {
+ $this._fixDriftedLinks();
+ }
+
+ //Restore links from 2022-12-07 13:37:15
+ this.linkeditor.save.saveIfUnsavedChanges(TRANSLATIONS.before_fix_drifted, false, callback);
+ },
+
+ _fixDriftedLinks: function () {
+ $.ajax({
+ url: '/fluidbook-publication/' + FLUIDBOOK_DATA.id + '/edit/links/fixdriftedlinks',
+ success: function (data) {
+ window.location.reload();
+ },
+ });
+ },
+
+
allowsKeyboardShortcut: function (shortcut) {
if (shortcut === 'pageup' || shortcut === 'pagedown' || shortcut === 'enter') {
return true;
loadLinks: function (page, side) {
let $this = this;
$.each(LINKS, function (uid, link) {
- if ($this.linkeditor.single && page % 2 === 1 && link.page % 2 === 0 && link.left > $this.linkeditor.pw) {
+ if (!$this.linkeditor.single && page % 2 === 1 && link.page % 2 === 0 && link.left > $this.linkeditor.pw) {
link.page++;
link.left -= $this.linkeditor.pw;
}
return;
}
if (side === 'right') {
+ link.page--;
link.left = parseInt(link.left) + $this.linkeditor.pw;
}
$this.addLink(link, side);
'empty'=>__('Vide'),
'copy_link_id'=>__('Copier l\'identifiant unique'),
'level'=>__('Niveau'),
+ 'before_fix_drifted'=>__('Sauvegarde avant la correction de la dérive des liens'),
];
$rulers=!count($rulers)?'{}':json_encode($rulers);