Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Conversation

@marudor
Copy link

@marudor marudor commented Apr 5, 2015

Using two way binding to watch for changes to title or content.
Also re-inits the tooltip to fix positioning.
Fixes #23
Requires Angular 1.3 > due to $watchGroups.
Also removes the feature to just use the title attribute.
Only works with tooltip-title and tooltip-content

@45kb
Copy link
Member

45kb commented Apr 5, 2015

@marudor hi, first of all thanks for your time and for the PR, help is always appreciated!

I didn't had any chance to try your changes yet, but having a quick look it seems to me that is no more possible to use html inside both tooltip-title and tooltip-content attributes...

Am i mistaking?

@marudor
Copy link
Author

marudor commented Apr 6, 2015

You are correct. Let me change it. I've used ng-bind. Just changing it to ng-bind-html should do the trick.
Just did not think about it.

@marudor
Copy link
Author

marudor commented Apr 6, 2015

Works for HTML as well now.
Does need ngSanitize for safe HTML usage though

@45kb
Copy link
Member

45kb commented Apr 15, 2015

@marudor Hi man, sorry for the delay, actually you did an awesome job but, really, ngSanitize is not needed, the aim is to release an indipendent so 0 dependencies module.

Thanks for your time

@marudor
Copy link
Author

marudor commented Apr 16, 2015

Well in that case you could assume valid HTML and mark it safe with $sce.
That way it is still possible to use ng-bind-html without ng-sanitize.
I would detect ng-sanitize though as it is way safer to use sanitize for html Content

@45kb
Copy link
Member

45kb commented Apr 16, 2015

@marudor the $sce (if working) could be the solution, let know if you try something 👯

We would just avoid including exetrnal file for the directive like ngSanitize

@rupakg
Copy link

rupakg commented Apr 16, 2015

@marudor This is exactly the issue I have been struggling with and I happened to stumble upon the PR. I would be glad to help, if you need it. Thanks for putting up the fix.

@marudor
Copy link
Author

marudor commented Apr 16, 2015

There you go.
If ngSanitize is available it will use it and not fall back to $sce.
If it is not available it will just mark the content and title as trusted.
This is slightly dangeours though. If someone fills tooltipContent or title with user input it should not be used without ngSanitize.

@rupakg
Copy link

rupakg commented Apr 16, 2015

@marudor Thanks a lot for working it so quickly. I already use ngSanitize so it will be ok for me. I will test it out. I will be using your commit till this gets merged.

@45kb if you guys can review and merge, that would be awesome.

@rupakg
Copy link

rupakg commented Apr 16, 2015

@marudor While testing I found that just plain static text in the tooltip-content or tooltip-title does not work anymore, as angular wants to eval the value, like so:

tooltip-content="this is a very long text that i want to show."

while dynamic content works fine.

tooltip-content="tooltip()"

Can you verify that?

@marudor
Copy link
Author

marudor commented Apr 16, 2015

@rupakg You have to wrap it as string.
So
tooltip-content="'this is a very long text that i want to show'"
works.
For added performance do tootlip-content="::'this is a very long text that i want to show'"
The :: makes it one time. So no watching for the two way binding.

@rupakg
Copy link

rupakg commented Apr 16, 2015

@marudor cool. interesting comment about the ::. Thanks again.

@bubbleheadinc
Copy link

@marudor How about when using markup and binding? This used to work before changes:

tooltip-content="<div>Account: {{account.name}}</div><div>{{account.type | capitalize}}: {{account.status}}</div>" 

I am using ngSantize. I tried with the single quotes as you suggested above and I've also tried with ng-bind on spans instead of expression.

Thanks for any help!

@marudor
Copy link
Author

marudor commented Apr 17, 2015

For that I will probably need to adjust it a little.
I'm not recompiling the input. So it will not work for mixed static and angular expressions.
I would need to set the content to
$compile(tooltipContent)($scope)
Will make a commit and comment this evening when I am back from work.

@45kb
Copy link
Member

45kb commented Apr 17, 2015

@marudor thank you for the time you are spending on this! 👍

@bubbleheadinc
Copy link

@marudor Sounds great. What about templates with Angular template or templateURL? Maybe that would be a better way to deal with it? I'm a bit of an Angular n00b, though.

@rupakg
Copy link

rupakg commented Apr 17, 2015

sounds a little over kill for using an Angular template for a tooltip!

@bubbleheadinc
Copy link

Yeah, I guess so. Just seems a bit clunky to me to have to declare the markup for tooltip-content over and over again for each tooltip if you don't want to use the default structure. Either way, the $compile(tooltipContent)($scope) fix @marudor is making would help a ton.

@wouldgo
Copy link
Member

wouldgo commented Apr 20, 2015

Hi @marudor,

I've reviewed the diffs in this PR. It's seems legit to me to merge the actual commits, we need only one last thing: could you please update the README.md integrating the you intervents?

Thanks a lot for your commitment and contribution!

Dario

@45kb
Copy link
Member

45kb commented Apr 20, 2015

@marudor @bubbleheadinc @marudor Sorry, i don't quite understand the discussion topic at the moment, but (just guessing), is having the possibility to inject html templates inside tooltip-content="" and tooltip-title="" what you are discussing for?

Because, in such case, cound't be better a new attribute, for example tooltip-template="" ?

@bubbleheadinc
Copy link

@45kb Yes, I was suggesting a template instead of -content so as to more easily manage any custom structure. Unfortunately I don't have the knowledge to code it, but it seems to me another attribute would work well if anyone was willing to put it together.

@rupakg
Copy link

rupakg commented Apr 28, 2015

@marudor @45kb any chance this PR could be rebased and merged. I would really appreciate it.

@45kb
Copy link
Member

45kb commented Apr 28, 2015

@rupakg we would @marudor to finish pushing changes, he just need to pull all the new changes from the master , verify and commit.

Actually, if in a hurry, you can use his changes from here https://github.com/marudor/angular-tooltips

Let's give him some time he is doing it for all and for free 👍

@rupakg
Copy link

rupakg commented Apr 28, 2015

@45kb actually we are using @marudor 's fork, but it is ~16 commits behind upstream.

@rupakg
Copy link

rupakg commented Apr 28, 2015

@marudor absolutely, no hurries at all. And, I appreciate all your hard work. /cc @45kb

@45kb
Copy link
Member

45kb commented Apr 28, 2015

@rupakg no problems at all 👍 as soon as this feature is ready we will make a new updated release don't worry

@45kb
Copy link
Member

45kb commented May 27, 2015

Hi all, we just merged a new PR for dynamic content and title feel free to try it #37

Now the only thing missing is ngSanitize on them...

I am going to remove this PR but, seriously, feel free to open another one if necessary!

Thanks a lot to everyone.

@45kb 45kb closed this May 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

5 participants