Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sidebar icons to be tools or links that don't open a panel #147

Open
woodbri opened this issue Mar 14, 2019 · 5 comments
Open

Allow sidebar icons to be tools or links that don't open a panel #147

woodbri opened this issue Mar 14, 2019 · 5 comments

Comments

@woodbri
Copy link

woodbri commented Mar 14, 2019

I have two use case where I would like to have a button on the sidebar that does not open a panel:

  1. I would like to add a measure tool and the button would toggle the tool on/off changing the button background to indicate state
  2. I would like the button to open a modal dialog for situations where the sidebar is not wide enough.

It seems like you might have thought about something like these you have role="tab" and maybe adding role="button" and role="toggle" would allow nice integration of other behaviors.

@umbe1987
Copy link

@woodbri I also would need case 1 e.g. to toggle user position on/off. I thought one good way would be to add the class active, but this would mean 1) there could be more active tabs 2) the panel should not open.

@woodbri
Copy link
Author

woodbri commented Mar 14, 2019

I trying to hack it with jQuery, my thoughts are this:

  • add class="measure" to A tag, when active addClass('measure-active')
  • add a click handler to class measure the toggles the control by removeClass('measure-active') and turns off measure interactions, or turns it on
  • figure out how to disable your sidebar events on the A tag with class="measure"

This should all get done inside the sidebar class, but at the moment I'm just trying to work around it to see if I can get it to work.

@DrPDash
Copy link

DrPDash commented May 20, 2019

I also need this feature and scratching my head. Any further thoughts so far? Thanks

@woodbri
Copy link
Author

woodbri commented Aug 12, 2019

I ended up adding a class .not-tab to the to the links in the side bar that are not tabs, ie; I don't want them to open the sidebar. And on some of them I opened a modal dialog to get access to more space than the sidebar offered, and had the modals close the sidebar with the following code snippets.

// now disable all not-tab links so sidebar ignores them
$('.not-tab').each( function(i) { this.parentNode._sidebar = null; });

// close the sidebar if we are opening a modal dialog
$('.modal').on($.modal.OPEN, function(event, modal) {
    sidebar.close();
});

@nathanvda
Copy link

This is already supported, but not well documented. If one just drops the href='#' from the link, the sidebar code will ignore those buttons, and you can attach any behaviour you want.

For the original discussion, see #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants