Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

feat(tooltip): Add isOpen to tooltip level for toggle of tooltip #2148

Closed
wants to merge 1 commit into from

Conversation

mfunkie
Copy link

@mfunkie mfunkie commented May 5, 2014

This feature allows the user to provide an expression to tooltips (and popovers) so that they can programmatically close and open the tooltips.

@tehs0ap
Copy link

tehs0ap commented May 14, 2014

I've duplicated your changes into my own fork to play around with them a bit for a project I'm working on. I think I've come across some issues with your pull request. I'm new to the whole open source process, so feel free to let me know if I'm going about something the wrong way.

The problems I ran into is that when using the popover-is-open attribute to control the popup is that the positioning of the popup was incorrect and the default event triggers would still fire, which is more of an annoyance, than an actual issue.

For the positioning:
I'm not sure if the problem is occurs when popover-is-open is a hard coded expression.
When I was binding if to a value on the controller scope however, the position would be off because the show function was running before the contents of the popover where set. In your popover-is-open attribute observer you call show() which actually returns the positioning function so that it can be called again after the digest I believe. So I made the following changes.

// show and hide will set tt_isOpen for us
if (isOpen) {
    // timeout required to let the current digest loop finish so that 
    // we can correctly reposition the tooltip
    $timeout(showTooltipBind);
} else {
    hide();
}

I think this also allows the manual toggle to have the popup_delay feature.

For the default triggers:
Add a default trigger that does nothing that can be set from the view without have to use the setTriggers method on the $tooltipProvider. Something like 'manual' or 'never'.

// Default hide triggers for each show trigger
var triggerMap = {
  'mouseenter': 'mouseleave',
  'click': 'click',
  'focus': 'blur',
  'manual': 'manual'
};

Then you could have the tooltip or popover be controlled purely programatically.

<button type="button" class="btn btn-large" 
  popover="{{popover.message}}" 
  popover-title="{{popover.title}}" 
  popover-is-open="{{popover.isOpen}}" 
  popover-trigger="manual" >Button</button>

This is really just a suggestion, maybe its not something that needs to be implemented.

Hopefully this was clear and helpful.

@kulicuu
Copy link

kulicuu commented May 15, 2014

This is nice thanks! I hope to contribute to this.

@tehs0ap
Copy link

tehs0ap commented May 15, 2014

I think the changes in #1848 might also have this covered.

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

Successfully merging this pull request may close these issues.

None yet

5 participants