[Libreoffice-commits] online.git: loleaflet/src

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 17 02:42:17 UTC 2019


 loleaflet/src/control/Control.PartsPreview.js |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 001dcac278ebbff58b4d8437e17ce81c4e824cbe
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Fri Nov 23 01:36:17 2018 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sat Aug 17 04:41:59 2019 +0200

    leaflet: support reordering slides to first position
    
    Change-Id: I23fba5d7e10d861ec482974cf355c9fb1ae13a64
    Reviewed-on: https://gerrit.libreoffice.org/69637
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/71101

diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 25ffd099d..35c5e57cc 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -63,6 +63,13 @@ L.Control.PartsPreview = L.Control.extend({
 				});
 				this._scrollContainer = $('#slide-sorter .mCSB_container').get(0);
 
+				// Add a special frame just as a drop-site for reordering.
+				var frame = L.DomUtil.create('div', 'preview-frame', this._scrollContainer);
+				this._addDnDHandlers(frame);
+				frame.setAttribute('draggable', false);
+				L.DomUtil.setStyle(frame, 'height', '12px');
+
+				// Create the preview parts
 				for (var i = 0; i < parts; i++) {
 					this._previewTiles.push(this._createPreview(i, e.partNames[i], bottomBound));
 				}
@@ -144,7 +151,7 @@ L.Control.PartsPreview = L.Control.extend({
 	_setPart: function (e) {
 		var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
 		if (part !== null) {
-			var partId = parseInt(part);
+			var partId = parseInt(part) - 1; // The first part is just a drop-site for reordering.
 
 			if (e.ctrlKey) {
 				this._map.selectPart(partId, 2, false); // Toggle selection on ctrl+click.
@@ -331,7 +338,9 @@ L.Control.PartsPreview = L.Control.extend({
 
 		var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
 		if (part !== null) {
-			var partId = parseInt(part);
+			var partId = parseInt(part) - 1; // First frame is a drop-site for reordering.
+			if (partId < 0)
+				partId = -1; // First item is -1.
 			this.partsPreview._map._socket.sendMessage('moveselectedclientparts position=' + partId);
 		}
 


More information about the Libreoffice-commits mailing list