factorize click on menu buttons, open menu on all menu entries right click

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Julien Veyssier 2019-04-30 19:37:40 +02:00
Родитель 74b3ee6213
Коммит b0d46464c9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4141FEE162030638
7 изменённых файлов: 65 добавлений и 74 удалений

Просмотреть файл

@ -48,14 +48,6 @@ ContactsController.prototype = {
that.updateTimeFilterRange();
that.timeFilterController.setSliderToMaxInterval();
});
// click on menu button
$('body').on('click', '.contactsMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
// reset
$('body').on('click', '.resetContact', function(e) {
var ul = $(this).parent().parent();

Просмотреть файл

@ -33,20 +33,12 @@ DevicesController.prototype = {
this.map = map;
this.mainLayer = L.featureGroup();
var that = this;
// click on menu buttons
$('body').on('click', '.devicesMenuButton, .deviceMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
// toggle a device
$('body').on('click', '.device-line .device-name', function(e) {
var id = $(this).parent().attr('device');
that.toggleDevice(id, true, true);
});
// click on a device name : zoom to bounds
// zoom to bounds
$('body').on('click', '.zoomDeviceButton', function(e) {
var id = $(this).parent().parent().parent().parent().attr('device');
that.zoomOnDevice(id);

Просмотреть файл

@ -36,12 +36,23 @@ FavoritesController.prototype = {
this.map = map;
var that = this;
// UI events
// click on menu buttons
$('body').on('click', '.favoritesMenuButton, .categoryMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
// toggle favorites
$('body').on('click', '#navigation-favorites > a', function(e) {
that.toggleFavorites();
that.optionsController.saveOptionValues({favoritesEnabled: that.map.hasLayer(that.cluster)});
that.updateTimeFilterRange();
that.timeFilterController.setSliderToMaxInterval();
// expand category list if we just enabled favorites and category list was folded
if (that.map.hasLayer(that.cluster) && !$('#navigation-favorites').hasClass('open')) {
that.toggleCategoryList();
that.optionsController.saveOptionValues({favoriteCategoryListShow: $('#navigation-favorites').hasClass('open')});
}
});
// expand category list
$('body').on('click', '#navigation-favorites', function(e) {
if (e.target.tagName === 'LI' && $(e.target).attr('id') === 'navigation-favorites') {
that.toggleCategoryList();
that.optionsController.saveOptionValues({favoriteCategoryListShow: $('#navigation-favorites').hasClass('open')});
}
});
// toggle a category
@ -156,25 +167,6 @@ FavoritesController.prototype = {
that.categoryDeletionTimer[cat].pause();
delete that.categoryDeletionTimer[cat];
});
// toggle favorites
$('body').on('click', '#navigation-favorites > a', function(e) {
that.toggleFavorites();
that.optionsController.saveOptionValues({favoritesEnabled: that.map.hasLayer(that.cluster)});
that.updateTimeFilterRange();
that.timeFilterController.setSliderToMaxInterval();
// expand category list if we just enabled favorites and category list was folded
if (that.map.hasLayer(that.cluster) && !$('#navigation-favorites').hasClass('open')) {
that.toggleCategoryList();
that.optionsController.saveOptionValues({favoriteCategoryListShow: $('#navigation-favorites').hasClass('open')});
}
});
// expand category list
$('body').on('click', '#navigation-favorites', function(e) {
if (e.target.tagName === 'LI' && $(e.target).attr('id') === 'navigation-favorites') {
that.toggleCategoryList();
that.optionsController.saveOptionValues({favoriteCategoryListShow: $('#navigation-favorites').hasClass('open')});
}
});
// export favorites
$('body').on('click', '#export-displayed-favorites', function(e) {
that.exportDisplayedFavorites();

Просмотреть файл

@ -49,14 +49,6 @@ NonLocalizedPhotosController.prototype = {
that.updateTimeFilterRange();
that.timeFilterController.setSliderToMaxInterval();
});
// click on menu button
$('body').on('click', '.nonLocalizedPhotosMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
//save geolocations to pictures
$('body').on('click', '.save-all-nonlocalized', function(e) {

Просмотреть файл

@ -45,14 +45,6 @@ PhotosController.prototype = {
that.updateTimeFilterRange();
that.timeFilterController.setSliderToMaxInterval();
});
// click on menu button
$('body').on('click', '.photosMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
$('body').on('click', '.movephoto', function(e) {
var ul = $(this).parent().parent();
var filePath = ul.attr('filepath');

Просмотреть файл

@ -51,6 +51,53 @@
}
mapController.map.contextmenu.hide();
};
// click on menu buttons
$('body').on('click',
'.routingMenuButton, .favoritesMenuButton, .categoryMenuButton, .photosMenuButton, .contactsMenuButton, ' +
'.nonLocalizedPhotosMenuButton, .devicesMenuButton, .deviceMenuButton, .tracksMenuButton, .trackMenuButton',
function(e) {
var menu = $(this).parent().parent().parent().find('> .app-navigation-entry-menu');
var wasOpen = menu.hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
menu.addClass('open');
}
});
// right click on entry line
$('body').on('contextmenu',
'#navigation-routing > .app-navigation-entry-utils, #navigation-routing > a, ' +
'#navigation-favorites > .app-navigation-entry-utils, #navigation-favorites > a, ' +
'.category-line > a, .category-line > .app-navigation-entry-utils, ' +
'#navigation-devices > .app-navigation-entry-utils, #navigation-devices > a, ' +
'.device-line > a, .device-line > .app-navigation-entry-utils, ' +
'#navigation-tracks > .app-navigation-entry-utils, #navigation-tracks > a, ' +
'.track-line > a, .track-line > .app-navigation-entry-utils, ' +
'#navigation-nonLocalizedPhotos > .app-navigation-entry-utils, #navigation-nonLocalizedPhotos > a, ' +
'#navigation-contacts > .app-navigation-entry-utils, #navigation-contacts > a, ' +
'#navigation-photos > .app-navigation-entry-utils, #navigation-photos > a ',
function(e) {
var menu = $(this).parent().find('> .app-navigation-entry-menu');
var wasOpen = menu.hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
menu.addClass('open');
}
return false;
});
// right click on expand icon
$('body').on('contextmenu', '#navigation-favorites, #navigation-photos, #navigation-devices, #navigation-tracks', function(e) {
var id = $(e.target).attr('id');
if (e.target.tagName === 'LI' && (id === 'navigation-favorites' || id === 'navigation-photos' || id === 'navigation-devices' || id === 'navigation-tracks')) {
var menu = $(this).find('> .app-navigation-entry-menu');
var wasOpen = menu.hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
menu.addClass('open');
}
return false;
}
});
});
var geoLinkController = {
@ -622,14 +669,6 @@
//this.setRouter(this.ghRouter);
//console.log(this.control);
$('body').on('click', '.routingMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
// toggle routing control
$('body').on('click', '#navigation-routing > a', function(e) {
that.toggleRouting();

Просмотреть файл

@ -33,14 +33,6 @@ TracksController.prototype = {
this.mainLayer = L.featureGroup();
var that = this;
// UI events
// click on menu buttons
$('body').on('click', '.tracksMenuButton, .trackMenuButton', function(e) {
var wasOpen = $(this).parent().parent().parent().find('>.app-navigation-entry-menu').hasClass('open');
$('.app-navigation-entry-menu.open').removeClass('open');
if (!wasOpen) {
$(this).parent().parent().parent().find('>.app-navigation-entry-menu').addClass('open');
}
});
// toggle a track
$('body').on('click', '.track-line .track-name', function(e) {
var id = $(this).parent().attr('track');