[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - 15 commits - loleaflet/dist loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 16 18:56:02 UTC 2018
loleaflet/dist/toolbar/toolbar.js | 63 ++++--------
loleaflet/src/control/Control.DocumentRepair.js | 2
loleaflet/src/control/Control.Layers.js | 2
loleaflet/src/control/Control.PartsPreview.js | 2
loleaflet/src/control/Control.Permission.js | 2
loleaflet/src/control/Control.Selection.js | 2
loleaflet/src/control/Control.Tabs.js | 2
loleaflet/src/control/Control.js | 4
loleaflet/src/layer/marker/ClipboardContainer.js | 26 ++++-
loleaflet/src/layer/tile/TileLayer.js | 56 ++++++-----
loleaflet/src/map/Map.js | 62 +-----------
loleaflet/src/map/handler/Map.Drag.js | 40 +-------
loleaflet/src/map/handler/Map.Keyboard.js | 112 ++++++++++-------------
loleaflet/src/map/handler/Map.Mouse.js | 2
loleaflet/src/map/handler/Map.Tap.js | 70 ++++++--------
15 files changed, 173 insertions(+), 274 deletions(-)
New commits:
commit 4b148695a7ece17875142e1f406edacc79752ac6
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Aug 12 21:06:10 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: fix the number of users label from the status bar
Change-Id: I0b7e66c73a335295e5e61510bc0b68fc5c08ca58
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 512057c79..c6925cfe3 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -28,13 +28,6 @@ function _mobilify() {
statusbar.hide(item.id);
}
});
-
- nUsers = '%n';
- oneUser = '1';
- noUser = '0';
- updateUserListCount();
-
- $('#document-name-input').hide();
}
function resizeToolbar() {
@@ -1070,10 +1063,18 @@ map.on('doclayerinit', function () {
break;
}
- toolbarUp.refresh();
- statusbar.refresh();
+
if (L.Browser.mobile) {
_mobilify();
+ nUsers = '%n';
+ oneUser = '1';
+ noUser = '0';
+ $('#document-name-input').hide();
+ } else {
+ nUsers = _('%n users');
+ oneUser = _('1 user');
+ noUser = _('0 users');
+ $('#document-name-input').show();
}
updateUserListCount();
commit 77160ebcb4af447476b053a62bb0870eb5fb5a71
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Aug 8 15:08:09 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: remove invalid input focus
Change-Id: Ieb29394daac95a7a0666a852e7e375ab6d665429
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 5e8783205..d04c2e817 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -829,7 +829,6 @@ L.Map = L.Evented.extend({
vex.dialogID = -1;
this._startInactiveTimer();
- this.focus();
return vex.close(id);
}
} else {
@@ -838,7 +837,6 @@ L.Map = L.Evented.extend({
}
this._startInactiveTimer();
- this.focus();
return false;
},
commit 895390438449837533d0ab1439c7918fb8928751
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Aug 8 09:05:50 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: fix the status bar that loses the input focus
Change-Id: Ia39a33295e3a1c153636e2dd33a232cbe2b399b7
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 6185cc213..512057c79 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -37,42 +37,13 @@ function _mobilify() {
$('#document-name-input').hide();
}
-function _unmobilify() {
- var toolbarUp = w2ui['toolbar-up'];
- var statusbar = w2ui['toolbar-down'];
-
- toolbarUp.items.forEach(function(item) {
- if (item.mobile === false && item.hidden) {
- toolbarUp.show(item.id);
- }
- });
-
- statusbar.items.forEach(function(item) {
- if (item.mobile === false && item.hidden) {
- statusbar.show(item.id);
- }
- });
-
- nUsers = _('%n users');
- oneUser = _('1 user');
- noUser = _('0 users');
- updateUserListCount();
-
- $('#document-name-input').show();
-}
-
function resizeToolbar() {
- var toolbarUp = w2ui['toolbar-up'];
- var statusbar = w2ui['toolbar-down'];
-
- if ($(window).width() < mobileWidth) {
- _mobilify();
- } else {
- _unmobilify();
+ if ($(window).width() !== map.getSize().x) {
+ var toolbarUp = w2ui['toolbar-up'];
+ var statusbar = w2ui['toolbar-down'];
+ toolbarUp.resize();
+ statusbar.resize();
}
-
- toolbarUp.resize();
- statusbar.resize();
}
function _cancelSearch() {
@@ -1101,9 +1072,14 @@ map.on('doclayerinit', function () {
}
toolbarUp.refresh();
statusbar.refresh();
- resizeToolbar();
-});
+ if (L.Browser.mobile) {
+ _mobilify();
+ }
+ updateUserListCount();
+ toolbarUp.refresh();
+ statusbar.refresh();
+});
map.on('commandstatechanged', function (e) {
var toolbar = w2ui['toolbar-up'];
commit a8db51441f9681836426464fb06dc7cac2cfa410
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Aug 7 21:10:19 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: fix invalidate size
Change-Id: Ic4d06f2cf9a945bef4e8b81acd483238bf4e2bdb
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f799a5855..5e8783205 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -350,41 +350,12 @@ L.Map = L.Evented.extend({
return this.panTo(newCenter, options);
},
- invalidateSize: function (options) {
+ invalidateSize: function () {
if (!this._loaded) { return this; }
- options = L.extend({
- animate: false,
- pan: true
- }, options === true ? {animate: true} : options);
-
var oldSize = this.getSize();
this._sizeChanged = true;
-
- var newSize = this.getSize(),
- oldCenter = oldSize.divideBy(2).round(),
- newCenter = newSize.divideBy(2).round(),
- offset = oldCenter.subtract(newCenter);
-
- if (!offset.x && !offset.y) { return this; }
-
- if (options.animate && options.pan) {
- this.panBy(offset);
-
- } else {
- if (options.pan) {
- this._rawPanBy(offset);
- }
-
- this.fire('move');
-
- if (options.debounceMoveend) {
- clearTimeout(this._sizeTimer);
- this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
- } else {
- this.fire('moveend');
- }
- }
+ var newSize = this.getSize();
return this.fire('resize', {
oldSize: oldSize,
@@ -828,7 +799,7 @@ L.Map = L.Evented.extend({
_onResize: function () {
L.Util.cancelAnimFrame(this._resizeRequest);
this._resizeRequest = L.Util.requestAnimFrame(
- function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);
+ function () { this.invalidateSize(); }, this, false, this._container);
},
_activate: function () {
commit 5fa2c00b70c723dbdd2a19a096882662225bdb23
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Aug 5 18:30:16 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: show the cursor only if clipContainer is focused
Change-Id: I209952df810d23b244e8b963304115fd81e30a81
diff --git a/loleaflet/src/layer/marker/ClipboardContainer.js b/loleaflet/src/layer/marker/ClipboardContainer.js
index b6f80e871..63b136183 100644
--- a/loleaflet/src/layer/marker/ClipboardContainer.js
+++ b/loleaflet/src/layer/marker/ClipboardContainer.js
@@ -17,7 +17,9 @@ L.ClipboardContainer = L.Layer.extend({
L.DomEvent.on(this._textArea, 'copy cut paste ' +
'keydown keypress keyup ' +
'compositionstart compositionupdate compositionend textInput',
- this._map._handleDOMEvent, this._map);
+ this._map._handleDOMEvent, this._map)
+ .on(this._textArea, 'focus', this.onGotFocus, this)
+ .on(this._textArea, 'blur', this.onLostFocus, this);
},
onRemove: function () {
@@ -28,10 +30,24 @@ L.ClipboardContainer = L.Layer.extend({
L.DomEvent.off(this._textArea, 'copy cut paste ' +
'keydown keypress keyup ' +
'compositionstart compositionupdate compositionend textInput',
- this._map._handleDOMEvent, this._map);
+ this._map._handleDOMEvent, this._map)
+ .off(this._textArea, 'focus', this.onGotFocus, this)
+ .off(this._textArea, 'blur', this.onLostFocus, this);
+ },
+
+ onGotFocus: function () {
+ this.setLatLng(this._map._docLayer._updateCursorPos());
+ },
+
+ onLostFocus: function () {
+ this._map.removeLayer(this._map._docLayer._cursorMarker);
},
focus: function(focus) {
+ if (this._map._permission !== 'edit') {
+ return;
+ }
+
if (focus === false) {
this._textArea.blur();
} else {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 79be20cc8..09f3dc93d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1445,6 +1445,22 @@ L.TileLayer = L.GridLayer.extend({
this._onUpdateCursor();
},
+ _updateCursorPos: function () {
+ var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
+ this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
+ var cursorPos = this._visibleCursor.getNorthWest();
+
+ if (!this._cursorMarker) {
+ this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
+ }
+ else {
+ this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
+ }
+
+ this._map.addLayer(this._cursorMarker);
+ return this._visibleCursor.getNorthWest();
+ },
+
// Update cursor layer (blinking cursor).
_onUpdateCursor: function (scroll) {
var cursorPos = this._visibleCursor.getNorthWest();
@@ -1477,23 +1493,11 @@ L.TileLayer = L.GridLayer.extend({
// the state of the document (if the falgs are set)
_updateCursorAndOverlay: function (update) {
if (this._map._permission === 'edit'
+ && this._map._clipboardContainer._textArea === document.activeElement
&& this._isCursorVisible
&& this._isCursorOverlayVisible
&& !this._isEmptyRectangle(this._visibleCursor)) {
-
- var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
- this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
-
- var cursorPos = this._visibleCursor.getNorthWest();
-
- if (!this._cursorMarker) {
- this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
- }
- else {
- this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
- }
- this._map.addLayer(this._cursorMarker);
- this._map._clipboardContainer.setLatLng(this._visibleCursor.getNorthWest());
+ this._updateCursorPos();
}
else if (this._cursorMarker) {
this._map.removeLayer(this._cursorMarker);
commit 745836293ac29a0b310286f8ddaa72b66d8b2185
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Aug 5 16:50:25 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: replace refocusOnMap with map focus
Change-Id: I271ea3a3ed22320b1184e1bfc348ecb69f681fd8
diff --git a/loleaflet/src/control/Control.DocumentRepair.js b/loleaflet/src/control/Control.DocumentRepair.js
index aafe9deb1..c27541d59 100644
--- a/loleaflet/src/control/Control.DocumentRepair.js
+++ b/loleaflet/src/control/Control.DocumentRepair.js
@@ -119,7 +119,7 @@ L.Control.DocumentRepair = L.Control.extend({
_onCloseClick: function (e) {
this._map.enable(true);
- this._refocusOnMap();
+ this._map.focus();
this.remove();
},
diff --git a/loleaflet/src/control/Control.Layers.js b/loleaflet/src/control/Control.Layers.js
index 2eae18a61..a8b955fe1 100644
--- a/loleaflet/src/control/Control.Layers.js
+++ b/loleaflet/src/control/Control.Layers.js
@@ -238,7 +238,7 @@ L.Control.Layers = L.Control.extend({
this._handlingClick = false;
- this._refocusOnMap();
+ this._map.focus();
},
_expand: function () {
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index f466be8c6..4f16f9054 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -70,7 +70,7 @@ L.Control.PartsPreview = L.Control.extend({
.on(img, 'click', L.DomEvent.stopPropagation)
.on(img, 'click', L.DomEvent.stop)
.on(img, 'click', this._setPart, this)
- .on(img, 'click', this._refocusOnMap, this);
+ .on(img, 'click', this._map.focus, this._map);
this._map.getPreview(i, i, 180, 180, {autoUpdate: this.options.autoUpdate});
return img;
diff --git a/loleaflet/src/control/Control.Permission.js b/loleaflet/src/control/Control.Permission.js
index 1178580fa..bdbd222e9 100644
--- a/loleaflet/src/control/Control.Permission.js
+++ b/loleaflet/src/control/Control.Permission.js
@@ -26,7 +26,7 @@ L.Control.PermissionSwitch = L.Control.extend({
else {
this._map.setPermission('view');
}
- this._refocusOnMap();
+ this._map.focus();
},
_onUpdatePermission: function (e) {
diff --git a/loleaflet/src/control/Control.Selection.js b/loleaflet/src/control/Control.Selection.js
index af0ed0e2c..75a6d74ca 100644
--- a/loleaflet/src/control/Control.Selection.js
+++ b/loleaflet/src/control/Control.Selection.js
@@ -26,7 +26,7 @@ L.Control.Selection = L.Control.extend({
else {
this._map.disableSelection();
}
- this._refocusOnMap();
+ this._map.focus();
},
_onUpdatePermission: function (e) {
diff --git a/loleaflet/src/control/Control.Tabs.js b/loleaflet/src/control/Control.Tabs.js
index 8295f2fd6..76e2f946e 100644
--- a/loleaflet/src/control/Control.Tabs.js
+++ b/loleaflet/src/control/Control.Tabs.js
@@ -126,7 +126,7 @@ L.Control.Tabs = L.Control.extend({
.on(tab, 'click', L.DomEvent.stopPropagation)
.on(tab, 'click', L.DomEvent.stop)
.on(tab, 'click', this._setPart, this)
- .on(tab, 'click', this._refocusOnMap, this);
+ .on(tab, 'click', this._map.focus, this._map);
this._spreadsheetTabs[id] = tab;
}
}
diff --git a/loleaflet/src/control/Control.js b/loleaflet/src/control/Control.js
index abc2ac57f..99f797560 100644
--- a/loleaflet/src/control/Control.js
+++ b/loleaflet/src/control/Control.js
@@ -77,10 +77,6 @@ L.Control = L.Class.extend({
}
var corner = this._map._controlCorners[this.options.position];
return corner.hasChildNodes();
- },
-
- _refocusOnMap: function () {
- this._map.focus();
}
});
commit 85b28b2bcacf908f7109ae6d50952819f94d5b3c
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Aug 5 16:39:03 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: replace clipboardContainer with map focus
Change-Id: I616e5b8417522ec06d7311f335d3c60888a32b82
diff --git a/loleaflet/src/layer/marker/ClipboardContainer.js b/loleaflet/src/layer/marker/ClipboardContainer.js
index 4dc7792a7..b6f80e871 100644
--- a/loleaflet/src/layer/marker/ClipboardContainer.js
+++ b/loleaflet/src/layer/marker/ClipboardContainer.js
@@ -32,10 +32,10 @@ L.ClipboardContainer = L.Layer.extend({
},
focus: function(focus) {
- if (focus) {
- this._textArea.focus();
- } else {
+ if (focus === false) {
this._textArea.blur();
+ } else {
+ this._textArea.focus();
}
},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 3db127030..79be20cc8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -270,7 +270,7 @@ L.TileLayer = L.GridLayer.extend({
for (var key in this._selectionHandles) {
this._selectionHandles[key].on('drag dragend', this._onSelectionHandleDrag, this);
}
- this._map._clipboardContainer.focus(true);
+ this._map.focus();
map.setPermission(this.options.permission);
@@ -1677,7 +1677,7 @@ L.TileLayer = L.GridLayer.extend({
}
if (e.type === 'dragend') {
e.target.isDragged = false;
- this._map._clipboardContainer.focus(true);
+ this._map.focus();
this._map.fire('scrollvelocity', {vx: 0, vy: 0});
}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 2c4412e1e..f799a5855 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -660,7 +660,7 @@ L.Map = L.Evented.extend({
console.debug('focus:');
if (this._docLayer) {
console.debug('focus: focussing');
- this._clipboardContainer.focus(true);
+ this._clipboardContainer.focus();
}
},
@@ -1063,8 +1063,7 @@ L.Map = L.Evented.extend({
// Calling from some other place with no real 'click' event doesn't work
if (type === 'click') {
if (this._permission === 'edit') {
- this._clipboardContainer.focus(false);
- this._clipboardContainer.focus(true);
+ this.focus();
}
// unselect if anything is selected already
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 787cd60f6..7fc588c61 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -229,7 +229,7 @@ L.Map.Keyboard = L.Handler.extend({
if (this._map._permission === 'edit') {
return;
}
- this._map._container.focus();
+ this._map.focus();
},
// Convert javascript key codes to UNO key codes.
@@ -513,7 +513,7 @@ L.Map.Keyboard = L.Handler.extend({
case 93: // Right Cmd (Safari)
// we prepare for a copy or cut event
this._map._clipboardContainer.setValue(window.getSelection().toString());
- this._map._clipboardContainer.focus(true);
+ this._map.focus();
this._map._clipboardContainer.select();
return true;
case 80: // p
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index d5b280a0c..91ad67b9b 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -150,7 +150,7 @@ L.Map.Mouse = L.Handler.extend({
var docLayer = this._map._docLayer;
this._mouseEventsQueue = [];
docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, buttons, modifier);
- this._map._clipboardContainer.focus(true);
+ this._map.focus();
}, this));
this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), timeOut);
commit 5a5bd7eae16b27bfa4cabb60c1904bd4433b350e
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Aug 7 09:11:20 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: use setValue
Change-Id: Ica14c95e2aec31423a47d904c3c499b706261370
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 975a93e41..787cd60f6 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -392,7 +392,7 @@ L.Map.Keyboard = L.Handler.extend({
// get the composited char codes
// clear the input now - best to do this ASAP so the input
// is clear for the next word
- this._map._clipboardContainer._textArea.value = '';
+ this._map._clipboardContainer.setValue('');
// Set all keycodes to zero
this._map._docLayer._postCompositionEvent(0, 'end', '');
}
commit 8a6c22417308cd0a2d766c9df045460ff5beefa2
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Aug 1 21:20:12 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: fix panning inside max bounds
Change-Id: I5c08a529cb05471f3e248ab403dff5370de0ee46
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index b3ef7730b..2c4412e1e 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -12,6 +12,7 @@ L.Map = L.Evented.extend({
zoom: 10,
minZoom: 1,
maxZoom: 20,
+ maxBounds: L.latLngBounds([0, 0], [-100, 100]),
fadeAnimation: false, // Not useful for typing.
trackResize: true,
markerZoomAnimation: true,
@@ -325,25 +326,14 @@ L.Map = L.Evented.extend({
return this.fire('moveend');
},
- setMaxBounds: function (bounds, options) {
+ setMaxBounds: function (bounds) {
bounds = L.latLngBounds(bounds);
this.options.maxBounds = bounds;
- options = options || {};
-
- if (!bounds) {
- return this.off('moveend', this._panInsideMaxBounds);
- }
if (this._loaded) {
- this._panInsideMaxBounds();
- }
-
- if (options.panInside === false) {
- return this.off('moveend', this._panInsideMaxBounds);
+ this.panInsideBounds(this.options.maxBounds);
}
-
- return this.on('moveend', this._panInsideMaxBounds);
},
setDocBounds: function (bounds) {
@@ -806,10 +796,6 @@ L.Map = L.Evented.extend({
return this.getMaxZoom() - this.getMinZoom();
},
- _panInsideMaxBounds: function () {
- this.panInsideBounds(this.options.maxBounds);
- },
-
_checkIfLoaded: function () {
if (!this._loaded) {
throw new Error('Set map center and zoom first.');
commit 26aad36771ebd5a304b763912184acd2ea26dfdf
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Aug 1 21:14:02 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: fix dragging the document layer
Change-Id: I7047781926581c84ea8f1cb6576799d91099f6b5
diff --git a/loleaflet/src/map/handler/Map.Drag.js b/loleaflet/src/map/handler/Map.Drag.js
index 10b3b4aca..bb177a3b9 100644
--- a/loleaflet/src/map/handler/Map.Drag.js
+++ b/loleaflet/src/map/handler/Map.Drag.js
@@ -9,9 +9,6 @@ L.Map.mergeOptions({
inertiaDeceleration: 3400, // px/s^2
inertiaMaxSpeed: Infinity, // px/s
easeLinearity: 0.2,
-
- // TODO refactor, move to CRS
- worldCopyJump: false
});
L.Map.Drag = L.Handler.extend({
@@ -25,16 +22,10 @@ L.Map.Drag = L.Handler.extend({
this._draggable.on({
down: this._onDown,
dragstart: this._onDragStart,
+ predrag: this._onPreDrag,
drag: this._onDrag,
dragend: this._onDragEnd
}, this);
-
- if (map.options.worldCopyJump) {
- this._draggable.on('predrag', this._onPreDrag, this);
- map.on('viewreset', this._onViewReset, this);
-
- map.whenReady(this._onViewReset, this);
- }
}
this._draggable.enable();
},
@@ -92,17 +83,10 @@ L.Map.Drag = L.Handler.extend({
},
_onPreDrag: function () {
- // TODO refactor to be able to adjust map pane position after zoom
- var worldWidth = this._worldWidth,
- halfWidth = Math.round(worldWidth / 2),
- dx = this._initialWorldOffset,
- x = this._draggable._newPos.x,
- newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
- newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
- newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;
-
- this._draggable._absPos = this._draggable._newPos.clone();
- this._draggable._newPos.x = newX;
+ var org = this._map.getPixelOrigin();
+ var size = this._map.getLayerMaxBounds().getSize().subtract(this._map.getSize());
+ this._draggable._newPos.x = Math.max(Math.min(org.x, this._draggable._newPos.x), org.x - size.x);
+ this._draggable._newPos.y = Math.max(Math.min(org.y, this._draggable._newPos.y), org.y - size.y);
},
_onDragEnd: function (e) {
@@ -115,9 +99,7 @@ L.Map.Drag = L.Handler.extend({
if (noInertia) {
map.fire('moveend');
-
} else {
-
var direction = this._lastPos.subtract(this._positions[0]),
duration = (this._lastTime - this._times[0]) / 1000,
ease = options.easeLinearity,
@@ -133,18 +115,6 @@ L.Map.Drag = L.Handler.extend({
if (!offset.x || !offset.y) {
map.fire('moveend');
-
- } else {
- offset = map._limitOffset(offset, map.options.maxBounds);
-
- L.Util.requestAnimFrame(function () {
- map.panBy(offset, {
- duration: decelerationDuration,
- easeLinearity: ease,
- noMoveStart: true,
- animate: true
- });
- });
}
}
}
commit a725f23064aff4f1a34ef47dd288f9871bfe651a
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Jul 29 15:01:10 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: fix delete with backspace
Change-Id: I36eddf8b81849592982d01f3a4c7f3be0f0c0ee3
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index f83caf3d3..975a93e41 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -172,13 +172,13 @@ L.Map.Keyboard = L.Handler.extend({
this._map.on('mousedown', this._onMouseDown, this);
this._map.on('keydown keyup keypress', this._onKeyDown, this);
- this._map.on('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
+ this._map.on('compositionstart compositionupdate compositionend textInput', this._onIME, this);
},
removeHooks: function () {
this._map.off('mousedown', this._onMouseDown, this);
this._map.off('keydown keyup keypress', this._onKeyDown, this);
- this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
+ this._map.off('compositionstart compositionupdate compositionend textInput', this._onIME, this);
},
_ignoreKeyEvent: function(e) {
@@ -295,25 +295,6 @@ L.Map.Keyboard = L.Handler.extend({
var charCode = e.originalEvent.charCode;
var keyCode = e.originalEvent.keyCode;
- if (e.type === 'compositionstart' || e.type === 'compositionupdate') {
- this._isComposing = true; // we are starting composing with IME
- var txt = '';
- for (var i = 0; i < e.originalEvent.data.length; i++) {
- txt += e.originalEvent.data[i];
- }
- if (txt) {
- compEventFn('input', txt);
- }
- }
-
- if (e.type === 'compositionend') {
- this._isComposing = false; // stop of composing with IME
- // get the composited char codes
- // clear the input now - best to do this ASAP so the input
- // is clear for the next word
- inputEle.value = '';
- }
-
if (!this._isComposing && e.type === 'keyup') {
// not compositing and keyup, clear the input so it is ready
// for next word (or char only)
@@ -339,14 +320,12 @@ L.Map.Keyboard = L.Handler.extend({
}
else if (e.type === 'keydown') {
this._keyHandled = false;
- this._bufferedTextInputEvent = null;
if (this.handleOnKeyDownKeys[keyCode] && charCode === 0) {
keyEventFn('input', charCode, unoKeyCode);
}
}
- else if ((e.type === 'keypress' || e.type === 'compositionend') &&
- (!this.handleOnKeyDownKeys[keyCode] || charCode !== 0)) {
+ else if ((e.type === 'keypress') && (!this.handleOnKeyDownKeys[keyCode] || charCode !== 0)) {
if (charCode === keyCode && charCode !== 13) {
// Chrome sets keyCode = charCode for printable keys
// while LO requires it to be 0
@@ -357,47 +336,13 @@ L.Map.Keyboard = L.Handler.extend({
// key press times will be paired with the invalidation messages
docLayer._debugKeypressQueue.push(+new Date());
}
- if (e.type === 'compositionend') {
- // Set all keycodes to zero
- compEventFn('end', '');
- } else {
- keyEventFn('input', charCode, unoKeyCode);
- }
+ keyEventFn('input', charCode, unoKeyCode);
this._keyHandled = true;
}
- else if (e.type === 'textInput') {
- // Store the textInput event
- this._bufferedTextInputEvent = e;
- }
else if (e.type === 'keyup') {
- // Hack for making space and spell-check text insert work
- // in Chrome (on Andorid) or Chrome with IME.
- //
- // Chrome (Android) IME triggers keyup/keydown input with
- // code 229 when hitting space (as with all composiiton events)
- // with addition to 'textinput' event, in which we only see that
- // space was entered. Similar situation is also when inserting
- // a soft-keyboard spell-check item - it is visible only with
- // 'textinput' event (no composition event is fired).
- // To make this work we need to insert textinput.data here..
- //
- // TODO: Maybe make sure this is only triggered when keydown has
- // 229 code. Also we need to detect that composition was overriden
- // (part or whole word deleted) with the spell-checked word. (for
- // example: enter 'tar' and with spell-check correct that to 'rat')
-
- if (!this._keyHandled && this._bufferedTextInputEvent) {
- var textInputData = this._bufferedTextInputEvent.originalEvent.data;
- charCode = e.originalEvent.keyCode;
- for (var i = 0; i < textInputData.length; i++) {
- keyEventFn('input', textInputData[i].charCodeAt(), 0);
- }
- }
keyEventFn('up', charCode, unoKeyCode);
-
this._keyHandled = true;
- this._bufferedTextInputEvent = null;
}
if (keyCode === 9) {
// tab would change focus to other DOM elements
@@ -430,6 +375,51 @@ L.Map.Keyboard = L.Handler.extend({
L.DomEvent.stopPropagation(e.originalEvent);
},
+ _onIME: function (e) {
+ if (e.type === 'compositionstart' || e.type === 'compositionupdate') {
+ this._isComposing = true; // we are starting composing with IME
+ var txt = '';
+ for (var i = 0; i < e.originalEvent.data.length; i++) {
+ txt += e.originalEvent.data[i];
+ }
+ if (txt) {
+ this._map._docLayer._postCompositionEvent(0, 'input', txt);
+ }
+ }
+
+ if (e.type === 'compositionend') {
+ this._isComposing = false; // stop of composing with IME
+ // get the composited char codes
+ // clear the input now - best to do this ASAP so the input
+ // is clear for the next word
+ this._map._clipboardContainer._textArea.value = '';
+ // Set all keycodes to zero
+ this._map._docLayer._postCompositionEvent(0, 'end', '');
+ }
+
+ if (e.type === 'textInput' && !this._keyHandled) {
+ // Hack for making space and spell-check text insert work
+ // in Chrome (on Andorid) or Chrome with IME.
+ //
+ // Chrome (Android) IME triggers keyup/keydown input with
+ // code 229 when hitting space (as with all composiiton events)
+ // with addition to 'textinput' event, in which we only see that
+ // space was entered. Similar situation is also when inserting
+ // a soft-keyboard spell-check item - it is visible only with
+ // 'textinput' event (no composition event is fired).
+ // To make this work we need to insert textinput.data here..
+ //
+ // TODO: Maybe make sure this is only triggered when keydown has
+ // 229 code. Also we need to detect that composition was overriden
+ // (part or whole word deleted) with the spell-checked word. (for
+ // example: enter 'tar' and with spell-check correct that to 'rat')
+ var data = e.originalEvent.data;
+ for (var idx = 0; idx < data.length; idx++) {
+ this._map._docLayer._postKeyboardEvent('input', data[idx].charCodeAt(), 0);
+ }
+ }
+ },
+
_handleCtrlCommand: function (e) {
// Control
if (e.originalEvent.keyCode == 17)
commit d99e6783e2a6db82494069a0d9d84d3aa3820440
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Jul 29 14:46:51 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: check tolerance when the move event occurs
Change-Id: I9e1d28e1b198e81f876a323c978478e4ccea7474
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
index 3b8db8a85..caf474bff 100644
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ b/loleaflet/src/map/handler/Map.Tap.js
@@ -70,8 +70,11 @@ L.Map.Tap = L.Handler.extend({
_onMove: function (e) {
var first = e.touches[0];
- this._newPos = new L.Point(first.clientX, first.clientY);
- this._simulateEvent('mousemove', first);
+ var newPos = new L.Point(first.clientX, first.clientY);
+ if (newPos.distanceTo(this._startPos) > this._map.options.tapTolerance) {
+ this._newPos = newPos;
+ this._simulateEvent('mousemove', first);
+ }
},
_simulateEvent: function (type, e) {
commit e9cd680857feb0c28f1323d2adce9c2eab0f2536
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jul 24 13:57:44 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: handle long click
Change-Id: I3c3ecce737e5c2457e922e2e612f0312dfab72dd
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
index bc0b27e6e..3b8db8a85 100644
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ b/loleaflet/src/map/handler/Map.Tap.js
@@ -21,31 +21,21 @@ L.Map.Tap = L.Handler.extend({
L.DomEvent.preventDefault(e);
- this._fireClick = true;
-
// don't simulate click or track longpress if more than 1 touch
if (e.touches.length > 1) {
- this._fireClick = false;
clearTimeout(this._holdTimeout);
return;
}
- var first = e.touches[0],
- el = first.target;
+ var first = e.touches[0];
this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
- // if touching a link, highlight it
- if (el.tagName && el.tagName.toLowerCase() === 'a') {
- L.DomUtil.addClass(el, 'leaflet-active');
- }
-
// simulate long hold but setting a timeout
this._holdTimeout = setTimeout(L.bind(function () {
if (this._isTapValid()) {
- this._fireClick = false;
- this._onUp();
- this._simulateEvent('contextmenu', first);
+ this._fireDblClick = true;
+ this._onUp(e);
}
}, this), 1000);
@@ -65,21 +55,12 @@ L.Map.Tap = L.Handler.extend({
touchend: this._onUp
}, this);
- if (this._fireClick && e && e.changedTouches) {
-
- var first = e.changedTouches[0],
- el = first.target;
-
- if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
- L.DomUtil.removeClass(el, 'leaflet-active');
- }
+ var first = e.changedTouches[0];
+ this._simulateEvent('mouseup', first);
- this._simulateEvent('mouseup', first);
-
- // simulate click if the touch didn't move too much
- if (this._isTapValid()) {
- this._simulateEvent('click', first);
- }
+ if (this._fireDblClick) {
+ this._simulateEvent('dblclick', first);
+ this._fireDblClick = false;
}
},
@@ -90,21 +71,27 @@ L.Map.Tap = L.Handler.extend({
_onMove: function (e) {
var first = e.touches[0];
this._newPos = new L.Point(first.clientX, first.clientY);
+ this._simulateEvent('mousemove', first);
},
_simulateEvent: function (type, e) {
- var simulatedEvent = document.createEvent('MouseEvents');
-
- simulatedEvent._simulated = true;
- e.target._simulatedClick = true;
-
- simulatedEvent.initMouseEvent(
- type, true, true, window, 1,
- e.screenX, e.screenY,
- e.clientX, e.clientY,
- false, false, false, false, 0, null);
-
- e.target.dispatchEvent(simulatedEvent);
+ var simulatedEvent = {
+ type: type,
+ canBubble: false,
+ cancelable: true,
+ screenX: e.screenX,
+ screenY: e.screenY,
+ clientX: e.clientX,
+ clientY: e.clientY,
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false,
+ button: 0,
+ target: e.target,
+ preventDefault: function () {}
+ };
+ this._map._handleDOMEvent(simulatedEvent);
}
});
commit 35c1d1602541d27b6b7405b5e38eb2e677665867
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Jul 23 14:52:58 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: mobile: do not zoom out when edits a document
Change-Id: Ic5b78df16c8ac0ccfb7334e6809b58665cd04494
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 7b0ffa3d4..3db127030 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2049,8 +2049,11 @@ L.TileLayer = L.GridLayer.extend({
_fitWidthZoom: function (e, maxZoom) {
if (isNaN(this._docWidthTwips)) { return; }
- var size = e ? e.newSize : this._map.getSize();
- var widthTwips = size.x * this._map.options.tileWidthTwips / this._tileSize;
+ var oldSize = e ? e.oldSize : this._map.getSize();
+ var newSize = e ? e.newSize : this._map.getSize();
+ if (newSize.x - oldSize.x === 0) { return; }
+
+ var widthTwips = newSize.x * this._map.options.tileWidthTwips / this._tileSize;
var ratio = widthTwips / this._docWidthTwips;
maxZoom = maxZoom ? maxZoom : this.options.maxZoom;
commit e25dc8bba06375c375202515e718f56c983f3e45
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Apr 16 17:17:08 2018 -0400
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Aug 16 20:28:22 2018 +0200
loleaflet: fix when document window zooms out until it disappears
Change-Id: If0f7234429130aed47dbc9156fde2e125680638f
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index d5575ce91..7b0ffa3d4 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2048,20 +2048,19 @@ L.TileLayer = L.GridLayer.extend({
},
_fitWidthZoom: function (e, maxZoom) {
+ if (isNaN(this._docWidthTwips)) { return; }
var size = e ? e.newSize : this._map.getSize();
var widthTwips = size.x * this._map.options.tileWidthTwips / this._tileSize;
- maxZoom = maxZoom ? maxZoom : this._map.getZoom();
+ var ratio = widthTwips / this._docWidthTwips;
+ maxZoom = maxZoom ? maxZoom : this.options.maxZoom;
// 'fit width zoom' has no use in spreadsheets, ignore it there
if (this._docType !== 'spreadsheet') {
var crsScale = this._map.options.crs.scale(1);
- if (this._docWidthTwips > 0)
- {
- var ratio = widthTwips / this._docWidthTwips;
- var zoom = this._map.getZoom() + Math.floor(Math.log(ratio) / Math.log(crsScale));
+ var zoom = 10 + Math.floor(Math.log(ratio) / Math.log(crsScale));
- zoom = Math.max(1, zoom);
- zoom = Math.min(maxZoom, zoom);
+ zoom = Math.min(maxZoom, Math.max(1, zoom));
+ if (this._docWidthTwips * this._map.getZoomScale(zoom, 10) < widthTwips) {
this._map.setZoom(zoom, {animate: false});
}
}
More information about the Libreoffice-commits
mailing list