fix bug reverse selection checkbox

+ fix bug checkbox double (de)selection
+ better disabling approach without repetition
+ clean some comments
This commit is contained in:
lenovo
2022-11-17 11:19:28 +01:00
parent 1cf306d11f
commit 410fbe699d
3 changed files with 53 additions and 111 deletions

View File

@@ -24,11 +24,11 @@
- [/] create action to publish all
- [/] deal with multiplication of filters
- [/] deal with window size
- [/] la carte ne s'affiche pas sur les pages
- [/] filtres sur chrome
- [/] infowindow new design
- [/] infowindow enlever scroll border
- [/] hide filters before css ready
- [x] reduire hauteur du select menu
- [/] dans categories, placer "autres" en bas
@@ -36,7 +36,8 @@
- [/] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement
- [/] zoom sur cluster problem
- [/] transform names without space
- [ ] change appearance of filter according to other filters
- [/] change appearance of filter according to other filters
- [/] change title of select options that appears on cursor hover
- [ ] deal with error double event irl and online
#### verifications:

View File

@@ -115,79 +115,6 @@ function redraw_clusters(indexes) {
g_marker_cluster.render();
}
/*
' pays ' '-- categories --'
' [france] ' ' table ron. '
' chili ' '-- conferenc. --'
' bresil ' ' atelier '
' canada ' '-- forums --'
' benin ' '-- seminaire. --'
' rencontre. '
' autres '
' [pays ] ' ' categories '
' france ' ' table ron. '
' chili ' ' conferenc. '
' bresil ' ' atelier '
' canada ' ' forums '
' benin ' ' seminaire. '
' rencontre. '
' autres '
'-- pays --' ' categories '
' france ' ' table ron. '
' chili ' ' conferenc. '
'-- bresil --' ' [atelier ] '
'-- canada --' ' forums '
'-- benin --' ' seminaire. '
' rencontre. '
' autres '
' pays ' ' [categories] '
' france ' ' table ron. '
' chili ' ' conferenc. '
' bresil ' ' atelier '
' canada ' ' forums '
' benin ' ' seminaire. '
' rencontre. '
' autres '
' pays ' '-- categories --'
' france ' '-- table ron. --'
' [chili ] ' '-- conferenc. --'
' bresil ' ' atelier '
' canada ' ' forums '
' benin ' '-- seminaire. --'
'-- rencontre. --'
' autres '
' pays ' '-- categories --'
' [france] ' ' table ron. '
' chili ' '-- conferenc. --'
' bresil ' ' atelier '
' canada ' '-- forums --'
' benin ' '-- seminaire. --'
' rencontre. '
' autres '
' pays ' '-- categories --'
' [france] ' ' table ron. '
' chili ' '-- conferenc. --'
' bresil ' ' [atelier ] '
' canada ' '-- forums --'
' benin ' '-- seminaire. --'
' rencontre. '
' autres '
*/
function html_item(menu_name, menu_item) {
let item = menu_item.replace(/ /g, "_");
let html_id = `filter_${menu_name}_${item}`;
@@ -200,12 +127,30 @@ function toggle_menu_items(menu_name, x_abled) {
let class_name = `filter_menu_${name}`;
let items = document.getElementsByClassName(class_name);
for (let item of items) {
item.classList.remove('enable');
if (x_abled === "disable") {
item.setAttribute('disabled', '');
// for (let item of items) {
// item.classList.remove('enable');
// if (x_abled === "disable") {
// item.setAttribute('disabled', '');
// }
// else {
// item.removeAttribute('disabled');
// }
// }
if (x_abled === "disable") {
for (let item of items) {
item.classList.remove('enable');
if (item.classList.contains('to_enable')) {
item.classList.replace('to_enable', 'enable');
item.removeAttribute('disabled');
}
else
item.setAttribute('disabled', '');
}
else {
}
else {
for (let item of items) {
item.classList.remove('enable');
item.removeAttribute('disabled');
}
}
@@ -214,7 +159,9 @@ function toggle_menu_items(menu_name, x_abled) {
function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
// in case it's a menu title, like "Pays" or "Categories",
// or it's Mode menu, and both (irl and online) are abled or disabled,
// or it's Mode menu,
// and it was the first selection, meaning it does'nt contains 'enable'
// and both (irl and online) are abled or disabled,
// just act like Reset button
// it's too bas it will also go through this menu items even though it's unnecessary
if (menu_item_ori == null) { // it's a menu name
@@ -222,6 +169,11 @@ function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
toggle_menu_items("item", "enable");
return;
}
let menu_item_name = menu_item_ori._name;
let item_ori_html = html_item(menu_name_ori, menu_item_name);
let is_enabled = item_ori_html.classList.contains('enable');
if (menu_name_ori === "mode") {
let mode_menus = document.getElementsByClassName("filter_menu_mode");
let state = 0;
@@ -232,12 +184,14 @@ function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
state--;
}
if (state != 0) { // state equal 0 if both have a different state, because (0 + 1 - 1 = 0) and (0 - 1 + 1 = 0)
// "item" as a menu name will select all items in all menus
toggle_menu_items("item", "enable");
return;
if (! is_enabled) {
// "item" as a menu name will select all items in all menus
toggle_menu_items("item", "enable");
return;
}
}
else if (reverse) { // menu is "mode" and only one item is selected and the action was to deselect one, so the action has trigered on item but really we want to see the options of the other item, so let's switch them
if (menu_index === 0)
else if (reverse) { // menu is "mode" and only one item is selected and the action was to deselect one, so the action has trigered one item but really we want to see the options of the other item, so let's switch them
if (menu_index == 0)
menu_index++;
else
menu_index--;
@@ -245,10 +199,6 @@ function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
}
}
let menu_item_name = menu_item_ori._name;
let item_ori_html = html_item(menu_name_ori, menu_item_name);
let is_enabled = item_ori_html.classList.contains('enable');
let keys = Object.keys(menu_item_ori);
// loop through list of other menu_items available for this menu_item
// loop though menu names (pays, categories, mode)
@@ -258,14 +208,21 @@ function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
if (menu_name === "indexes")
continue;
else if (! is_enabled) {
// it's too bad it will disable all to then enable certains, it would be better to check each time
toggle_menu_items(menu_name, "disable");
// loop through items in menu names (ex. for "pays" : france, chili, cuba)
// // it's too bad it will disable all and then enable certains, it would be better to check each time
// toggle_menu_items(menu_name, "disable");
// // loop through items in menu names (ex. for "pays" : france, chili, cuba)
// for (let item of menu_item_ori[menu_name]) {
// let item_html = html_item(menu_name, item);
// item_html.classList.add('enable');
// item_html.removeAttribute('disabled');
// }
for (let item of menu_item_ori[menu_name]) {
let item_html = html_item(menu_name, item);
item_html.classList.add('enable');
item_html.removeAttribute('disabled');
item_html.classList.add('to_enable');
}
toggle_menu_items(menu_name, "disable");
}
}
}

View File

@@ -90,22 +90,6 @@
#ljdp_map_filters input.filter_menu_checkbox:checked
+ label.filter_menu_checkbox p::before {
/*
background-color: #ba197a;
background-color: #ca1c84;
background-color: #e01f93;
background-color: #e3359e;
background-color: #e74ba9;
background-color: #ea62b3;
background-color: #ed78be;
background-color: #f08fc9;
background-color: #f3a5d4;
background-color: #f6bcdf;
background-color: #f9d2e9;
background-color: #fce9f4;
*/
/*
*/
background-color: #ccc;
}