leaflet: unified the tooltip bindings

additionally, tooltips in tablet will be visible on long press now

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Idc9bb0ac12b849871292293286f9019449cc9851
This commit is contained in:
Pranam Lashkari 2021-04-04 22:48:03 +05:30 committed by pedropintosilva
parent d6d7b90abe
commit d0f58ddd7d
10 changed files with 40 additions and 23 deletions

View file

@ -42,8 +42,7 @@ L.Control.FormulaBar = L.Control.extend({
$('#addressInput').off('keyup', that.onAddressInput.bind(that)).on('keyup', that.onAddressInput.bind(that));
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
toolbar.bind('touchstart', function(e) {
w2ui['formulabar'].touchStarted = true;

View file

@ -2080,8 +2080,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
image.src = data.image.replace(/\\/g, '');
image.alt = data.text;
image.title = data.text;
if (!window.ThisIsAMobileApp)
$(image).tooltip();
builder.map.uiManager.enableTooltip(image);
if (data.loading && data.loading === 'true') {
var loaderContainer = L.DomUtil.create('div', 'ui-drawing-area-loader-container', container);
@ -2389,8 +2388,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
$(div).addClass('no-label');
} else {
div.title = data.text;
if (!window.ThisIsAMobileApp)
$(div).tooltip();
builder.map.uiManager.enableTooltip(div);
$(div).addClass('no-label');
}
@ -2608,8 +2606,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
}
sectionTitle.title = data.text;
if (!window.ThisIsAMobileApp)
$(sectionTitle).tooltip();
builder.map.uiManager.enableTooltip(sectionTitle);
var updateFunction = function() {
var items = builder.map['stateChangeHandler'];

View file

@ -286,6 +286,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({
L.DomUtil.addClass(container, builder.options.cssClass);
L.DomUtil.addClass(container, 'ui-combobox');
var select = L.DomUtil.create('select', builder.options.cssClass, container);
builder.map.uiManager.enableTooltip(container);
var processedData = [];
@ -404,8 +405,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({
div.id = id;
div.title = data.text;
if (!window.ThisIsAMobileApp)
$(div).tooltip();
builder.map.uiManager.enableTooltip(div);
var icon = builder._createIconURL(data.command);
var buttonId = id + 'img';

View file

@ -39,8 +39,8 @@ L.Control.PresentationBar = L.Control.extend({
window.hideTooltip(this, e.target);
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
if (this.map.getDocType() === 'drawing')
w2ui['presentation-toolbar'].disable('presentation');

View file

@ -38,8 +38,7 @@ L.Control.SearchBar = L.Control.extend({
window.setupSearchInput();
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
toolbar.bind('touchstart', function(e) {
w2ui['searchbar'].touchStarted = true;

View file

@ -35,8 +35,7 @@ L.Control.SheetsBar = L.Control.extend({
window.hideTooltip(this, e.target);
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
toolbar.bind('touchstart', function(e) {
w2ui['spreadsheet-toolbar'].touchStarted = true;

View file

@ -27,8 +27,7 @@ L.Control.SigningBar = L.Control.extend({
onRefresh: function() {
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
toolbar.bind('touchstart', function() {
w2ui['document-signing-bar'].touchStarted = true;

View file

@ -239,8 +239,7 @@ L.Control.StatusBar = L.Control.extend({
window.setupSearchInput();
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
}
toolbar.bind('touchstart', function() {

View file

@ -312,8 +312,7 @@ L.Control.TopToolbar = L.Control.extend({
window.insertShapes(event.target);
}
});
if (window.mode.isDesktop())
toolbar.tooltip();
this.map.uiManager.enableTooltip(toolbar);
toolbar.bind('touchstart', function() {
w2ui['editbar'].touchStarted = true;

View file

@ -4,7 +4,7 @@
and allows to controll them (show/hide)
*/
/* global app $ setupToolbar w2ui w2utils toolbarUpMobileItems _ */
/* global app $ setupToolbar w2ui w2utils toolbarUpMobileItems _ Hammer */
L.Control.UIManager = L.Control.extend({
mobileWizard: null,
@ -619,6 +619,32 @@ L.Control.UIManager = L.Control.extend({
else
return retval;
}
},
enableTooltip: function(element) {
var elem = $(element);
if (window.mode.isDesktop()) {
elem.tooltip();
elem.click(function() {
$('.ui-tooltip').fadeOut(function() {
$(this).remove();
});
});
}
else {
elem.tooltip({disabled: true});
(new Hammer(elem.get(0), {recognizers: [[Hammer.Press]]}))
.on('press', function () {
elem.tooltip('enable');
elem.tooltip('open');
document.addEventListener('touchstart', function closeTooltip () {
elem.tooltip('close');
elem.tooltip('disable');
document.removeEventListener('touchstart', closeTooltip);
});
}.bind(this));
}
}
});