GithubHelp home page GithubHelp logo

lorenzos / floatingtips Goto Github PK

View Code? Open in Web Editor NEW
35.0 5.0 9.0 79 KB

A Mootools plugin for creating floating balloon tips that nicely appears when hovering an element.

Home Page: http://www.mootools.net/forge/p/floatingtips

JavaScript 67.19% HTML 32.81%
tooltips mootools javascript baloon plugin

floatingtips's People

Contributors

afoeder avatar lorenzos avatar meleyal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

floatingtips's Issues

The tooltip doesn't hide everytime

Lorenzos, thanks for your work, it is really usefull

I notice an issue when the tooltip is used with a container.
For example the following code:

<div id='A'>
  <p id='B'>text B</p>
  <p id='C'>text C</p>
</div>

<script>
new FloatingTips('#A', {
  content: function() { return 'This is a test'; },
  position: 'bottom'
});
</script>

When the mouse goes on A over B, the tooltip appears correctly, then if you move the mouse down over C, then goes out from A, the tooltip is still shown.
Then, if you go on A over C, you will have 2 tooltips.
(I tried this on IE, Firefox and Chrome)

I don't know how to correct this, any idea?

Thanks for your help

PS: I needed a new position type, 'toporbottom' to display the tooltip on top if it can be seen, if not, it is display on bottom of the element.
I modified the code, a little bit for that, can I send it to you for other users if needed?

FloatingTip is not hidden when the element is disposed

In my case, I have elements associated with FloatingTips - classic
The FloatingTips is shown when the mouse rollover the element - classic

Now, I need to dispose elements to replace them by others, but if a FloatingTip is shown, it is not hidden, and it stays shown

Any idea to correct that?

Thanks

Provide a way to hideOn: 'memberPopup' or similar

Element members of the same FloatingTips instance should be known to FloatingTips in order to be able to close them (i.e. showing only one Tip at once).
As a side-feature, a hideOn: 'memberPopup' functionality could be introduced which will concern with that.
Will provide a PR.

FloatingTips on imagemap area

Hello lorenzo,

I have a question again. Is there a possibility to use the floating tips on an imagemap? I mean, it works, that the tooltip shows, but not on the expected position but on the top left corner of the page.
Is there a way to move it to the right position?

Thanx again,

Felix

Using multiple elements

Hi,
When i use class for multiple elements, tooltip for first matched element works well but for other there is no content in tooltips!
I used new FloatingTips('a'); as Javascript of jsFiddle demo sample and saw effect.

Thanks for handy plugin.

In IE, z-index is not set correctly from user CSS

Hi Lorenzo,

just stumbled upon the following lines (currently https://github.com/lorenzos/FloatingTips/blob/master/Source/FloatingTips.js#L139 ):

var cwr = new Element('div').addClass(o.className).setStyle('margin', 0);
var tip = new Element('div')
    .addClass(o.className + '-wrapper')
    .addClass('position-' + this.options.position)
    .setStyles({ 'margin': 0, 'padding': 0, 'z-index': cwr.getStyle('z-index') })
    .adopt(cwr);

I'm talking about the setStyles(...z-index:...) setting; how is this supposed to work when its fetched from cwr which is just created one line above?
In my case, this evals to 'auto' which is the worst of all, because no CSS rules apply anymore then (the auto has precedence).

Do you see a reason for this, or would you see a configuration workaround?

bug when calling show before the show opacity effect is over

If you call show on some element that has tip several times before the fx opacity effect is over, then the object create more and more tips cause it doesn't recognize that the tip is in the middle of the animation:
line 84:

if (old) if (old.getStyle('opacity') == 1) { clearTimeout(old.retrieve('timeout')); return this; }

The fix is to set the compare to != 0

if (old) if (old.getStyle('opacity') != 0) { clearTimeout(old.retrieve('timeout')); return this; }

Suggestion: offset option callback-able

Hi Lorenzo,

In my case it was useful to have the offset-option a callback because I wanted to float-tip a progress-bar-percentage; so I had to calculate the offset dependent of the progress.

So right after the line:

var tipSz = tip.getSize(), trgC = elem.getCoordinates(body);

I added:

var offsetOption = ( 'function' === typeOf(o.offset) ? Object.merge({x:0, y:0}, o.offset(elem)) : o.offset );

And replaced the following line with:

var pos = { x: trgC.left + offsetOption.x, y: trgC.top + offsetOption.y };

(sorry I'm too lazy to build a pull request)

This checks of the given offset option is a function; if so, it invokes it and merges the result with x:0 and y:0 (the callback function has to return an object with x and/or y).
So basically the functionality keeps the same with the exception that, in case of a function is given, it is invoked.

Thanks and best!
-adrian

Handling position of fixed positioned children

Hi Lorenzo,

I have a top menu which is position:fixed, and as soon as the page body is scrolled, the floating tips are displayed incorrectly.
This boils down to MooTool's .getCoordinates() method, see this example: http://jsfiddle.net/afoeder/gnpY2/

Do you have an idea how to circumvent this, especially from my user side? I think I could even substract the current scroll pos, but then the offset calculation must be a callback.
At the last resort, do you think this would be a good idea? something like a "positionCalculationCallback" or so...

Manual zIndex (as option)

You might want to consider adding a z-index as option zIndex or something.
I was playing with some layered designs and it didn't work in webkit. If you add a z-index to the .floating-tip class in css it doesn't matter, because it will be seen as 'auto' in webkit (safari + chrome). Firefox works OK, but that might be a 'bug' really in Firefox.

You need to set a 'position' value for the z-index to work, but adding a position breaks the final layout (since the tip is created inside the class).
So I guess either work with a (required) position: relative with z-index value in the user's css and reset/fix all positioning in the _create method, or add a zIndex as option and apply it to the created tip.

I'm a bit tired atm, so didn't create a demo fiddle, can do that tomorrow.

Trigger On Event

Hello,

it's not an issue as such, more a question of how to.

Your class is really cool and I would like to use it with my form that uses ajax for validation. On the error response, I would like to trigger a tip for a particular input with an error message.

Could I do something like

if(response == 1){

new FloatingTips('myinput' , { position: 'right', showOn:'load', 'content':'error, incorrect value' });
}

Any help would be great.

Thanks!

[BUG] Tips are always created on show

I don't know if this is intended, the code doesn't tell that very well.
There is

    show: function(element) {
        var old = element.retrieve('floatingtip');
        if (old) if (old.getStyle('opacity') != 0) { clearTimeout(old.retrieve('timeout')); return this; }
        var tip = this._create(element);
        if (tip == null) return this;
        element.store('floatingtip', tip);
        this._animate(tip, 'in');
        element.store('floatingtip_visible', true);
        this.fireEvent('show', [tip, element]);
        return this;
    },

I can't see the intention of the second line if(old) if (old.getStyle.... because if the opacity is 0, the condition would not match and the tip is created in any case.
As far as I can see it, the following block would make more sense (caution: does not work, should only show the idea):

    show: function(element) {
        var tip = element.retrieve('floatingtip');
        if (tip) {
            if (tip.getStyle('opacity') != 0) {
                clearTimeout(tip.retrieve('timeout'));
                return this;
            }
        } else {
            tip = this._create(element);
            if (tip == null) return this;
            element.store('floatingtip', tip);
        }
        this._animate(tip, 'in');
        element.store('floatingtip_visible', true);
        this.fireEvent('show', [tip, element]);
        return this;
    },

This will reuse the same tip every time. What do you think @lorenzos ?

Why don't you allow an Elements instance as input?

Hi, class looks nice.. using it left some stuff to desire, eg. why don't you allow an Elements instance as the input?
It's more common to feed a class either 1 element, a collection of elements as an Elements instance or just a string (and the class will try and document.id it or something).
With your setup I have to input a string selector or an "element collection" but I don't know what kind of collection.
I can't even feed it document.id('myLink') or 'myLink', no.. it has to be '#myLink' ... grmbl! very annoying.

Apart from that, nice ;)

Lacking 'sources' in package.yml

Hi Lorenzo,
could you please be so kind and add the 'sources' directive in your package.yml so that the packager works fine?

sources:
  - "Source/floatingtips.js"

That'd be fine, thanks and happy-new-year in advance :)

Hide tip on outside click

Provide an "outsideclick" (pseudo-) event as possible value for the hideOn option, which will hide the tooltip when clicking outside the tooltip (especially interesting for FloatingTips.Dialog).

In FloatingTips.Dialog this would be a reasonable default option rather than the 'never', but this will mean a breaking change.

@lorenzos what do you think about the idea at all and the FloatingTips.Dialog default thing?

Will create a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.