Hide one toggle when another is clicked - toggle

When using several toggle items on a page (just toggle, not togggleClass etc) how is it possible to close one when another is opened?
$(document).ready(function(){
$(".toggle-trigger").click(function(){
$(".toggled-div").toggle(300);
});
});
$(document).ready(function(){
$(".toggle-trigger-2").click(function(){
$(".toggled-div-2").toggle(300);
});
});
So ideally, when toggle-trigger-2 is clicked to toggle toggled-div-2, toggle-trigger-div (the first one) is hidden.

Related

Keep keyboard open on page and disable every close option

I have an app with 2 pages. The first page is the main menu, and when you navigate to the 2nd page, a keyboard open himself inside a TextField (autofocus).
What I want to do is disabling every ways of closing the keyboard. Right now, it doesn't close when you submit, but that's the only thing I achieved to do.
The user can still close it with every other ways (in my case, it's the android navigation bar who has the left button who can dismiss it).
Is there any ways to keep the keyboard open during the whole time an user stays on a page?
EDIT:
I found this package : keyboard_visibility to do that inside initState:
KeyboardVisibilityNotification().addNewListener(onHide: () {
setState(() {
FocusScope.of(context).requestFocus(_focus);
});
});
Each time I hide the keyboard, onHide is called and I can execute some code. Here I try to focus the TextInput again to re-open the keyboard immediately. When the keyboard is hided, the function is called, but requestFocus doesn't seems to work.
Try this,
FocusScope.of(context).requestFocus(FocusNode());

How to keep a popup visible if show popup is on hover, not click. It hides as soon as you leave the marker

I am using clustering, and when the mouse hovers over one cluster it shows a popup.
The user needs to click on a link on that popup.
But as soon as the mouse leaves the marker, the popup closes.
What's an easy way to do this?
I've read and found there is this mousemove event, but i'm afraid that will be triggered many times and slow things down.
map.on('mousein ', 'clusters', function (e) {
var coordinates = e.features[0].geometry.coordinates.slice();
var id = e.features[0].id;
map.getSource('users').getClusterLeaves(id, 50, 0, function(error, features){
const html = features
new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(html)
.addTo(map);
})
});
Right now, it hides the popup as soon as you leave the marker.
I want the popup to be shown if user hover over marker and corresponding popup.

How can I show the popup on bottom middle of the page when clicking MapboxGL marker?

I want to show a popup on the bottom middle of the page when clicking a marker.
I have used the following code
new mapboxgl.Popup({ anchor: 'top' })
This shows popup on the bottom of the marker. But I want to show the popup at the bottom middle of the page
Popups are more for attaching to the map at some lat/lng, if you want to trigger something to show/hide based on a click, I would create a separate div then show/hide it appropriately and set the text of it as needed.
map.on('click', 'mylayer', function (e) {
// show or hide your div
// feature that was clicked would be e.features[0]
} );
For the "show or hide your div" part, you could reference:
How can I hide/show a div when a button is clicked?

Modal: how to make it accessible for keyboard navigation?

I'm developing an app using Angular and Semantic-UI. It should be accessible even for people who use keyboards for navigate the app.
I'm experiencing some problems with modal:
$(".my-modal").modal({
autofocus: true
});
$(function() {
$("#open").click(function(){
$(".my-modal").modal('show');
});
});
Here is the full code of my sample: http://jsfiddle.net/s6o0tdp7
As you can see when you open the modal the focus move on the first button. I would like to have focus on the entire modal, at the begin of the modal container, so users can move with tab button to go to the other sections of the modal that lay below.
Besides the modal should prevent users from going to elements of the page that is under the modal.
How to get these two behaviours?

Event handler tab control with jQuery

I have a survey with many input elements, and I have a progress bar that shows how much of the survey that has been filled out/answered by having a click event on the input elements. This works fine until someone use tab control to navigate through the form. Is there a tab control event, or some other event that I can use to track this behaviour?
Use the event focus to capture when the user is tabbing around in your controls:
$.on("focus", "input", function() { });