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

add tooltip-html-unsafe directive #246

Closed
lanterndev opened this issue Mar 19, 2013 · 6 comments
Closed

add tooltip-html-unsafe directive #246

lanterndev opened this issue Mar 19, 2013 · 6 comments

Comments

@lanterndev
Copy link
Contributor

See discussion in #154 and #202.

@joshdmiller
Copy link
Contributor

Thanks for opening this, @Skivvies. There is an outstanding tooltip pull request. As soon as that goes through (should be tomorrow-ish), this is what I'll work on.

joshdmiller pushed a commit to joshdmiller/bootstrap that referenced this issue Mar 22, 2013
The directive displays the unsanitized HTML in the tooltip instead of
the escaped text.

The $tooltip service has been modified to allow a little more
flexibility in terms of the prefix used on the $observe'd attributes.
For example, the `tooltip-html-unsafe` directive needs to be called as
written, but it would be nonsensical to require all other attributes
(like animation or placement) to also use that verbose prefix as opposed
to the simpler and more familiar `tooltip-` prefix. The service now
allows independent specification of the name and its prefix.

Lastly, the docs for the tooltip and popover have been updated to show
their available optional attributes.

Closes angular-ui#246
joshdmiller pushed a commit that referenced this issue Mar 25, 2013
The directive displays the unsanitized HTML in the tooltip instead of
the escaped text.

The $tooltip service has been modified to allow a little more
flexibility in terms of the prefix used on the $observe'd attributes.
For example, the `tooltip-html-unsafe` directive needs to be called as
written, but it would be nonsensical to require all other attributes
(like animation or placement) to also use that verbose prefix as opposed
to the simpler and more familiar `tooltip-` prefix. The service now
allows independent specification of the name and its prefix.

Lastly, the docs for the tooltip and popover have been updated to show
their available optional attributes.

Closes #246
@mlunoe
Copy link

mlunoe commented Apr 1, 2013

ng-show does not work with your tooltip-html-unsafe.
E.g. tooltip-html-unsafe='Hello'

@joshdmiller
Copy link
Contributor

@mlunoe What do you mean?

If you mean you can't pass ngShow into the tooltip as HTML, then you're right. The contents of the HTML are not compiled, so no AngularJS directives will work. This is meant for adding newlines with <br /> or adding bold or italic fonts, etc. I'm not sure I see the value in adding complex markup to a tooltip; if this is your issue, can you elaborate on your use case?

If you mean that <a tooltip-html-unsafe="blah" ng-show="myProp">Hello</a> doesn't work, can you post a Plunker?

@mlunoe
Copy link

mlunoe commented Apr 2, 2013

Hi Josh.

Sorry, it was a bit late for me when I commented and when you wrote me I
realised, that I was using a tooltip for something completely outside of
its purpose!

if you are interested I wanted to show my stackoverflow score in the
tooltip, here's the code:

<a 
  class="stack-info" href="http://stackoverflow.com/users/1008519/mlunoe"
  target="_blank" tooltip-placement="bottom" tooltip-html-unsafe=' <span
class="stack-info" ng-show="stackOverflow.score > 0">
{{stackOverflow.score}} </span> <span class="gold badgecount"
ng-show="stackOverflow.badge_counts.gold > 0"> <i class="icon-circle"></i>
{{stackOverflow.badge_counts.gold}} </span> <span class="silver badgecount"
ng-show="stackOverflow.badge_counts.silver > 0"> <i
class="icon-circle"></i> {{stackOverflow.badge_counts.silver}} </span>
<span class="bronze badgecount" ng-show="stackOverflow.badge_counts.bronze
> 0"> <i class="icon-circle"></i> {{stackOverflow.badge_counts.bronze}}
</span>'>
  <i class="icon-stack-overflow icon-large"></i>
</a>

And it works awesome :)

The idea was to only show when there was actually any badges (that is e.g.
not the case with gold badges for me)

So I am sorry about the comment as it was beyond the use of the tooltip
function. However, I started thinking and I realised, that somebody might
need it for, e.g. personalising tooltips or just showing different tooltips
based on the state. A basic solution would be to show the contents of a
variable, but if you wanted to show some tooltips for a new user logging in
to the application for the first time and something slightly the same under
some other conditions you need to create a new element for each.

Again, this was thoughts, however I think it could be kinda cool to explore
the uses of such a functionality :)

Best regards,

Michael

On Tue, Apr 2, 2013 at 1:31 AM, Josh D Miller [email protected]:

@mlunoe https://github.com/mlunoe What do you mean?

If you mean you can't pass ngShow into the tooltip as HTML, then you're
right. The contents of the HTML are not compiled, so no AngularJS
directives will work. This is meant for adding newlines with
or
adding bold or italic fonts, etc. I'm not sure I see the value in adding
complex markup to a tooltip; if this is your issue, can you elaborate on
your use case?

If you mean that Hellodoesn't work, can you post a Plunker?


Reply to this email directly or view it on GitHubhttps://github.com//issues/246#issuecomment-15743682
.

@joshdmiller
Copy link
Contributor

Yeah, it's not really meant to show content that complicated. We've considered allowing passing in a template (e.g. tooltip-template="'myfile.tpl.html'") that you can use to overwrite the default and that may be a better way to solve for a case like yours. But out of the box, I think it's asking too much out an HTML attribute.

If you want to explore using a template, open an issue and we can move the discussion there.

@jhiemer
Copy link

jhiemer commented Apr 3, 2013

Hi guys,
short question, after the test passed, when is are these features going into the the main source base?

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

Successfully merging a pull request may close this issue.

4 participants