Letractively / tooltips

Automatically exported from code.google.com/p/tooltips
0 stars 0 forks source link

Patch: disable tooltip on mouse, at place tooltip at bottom left of element. #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I wanted tooltips on input boxes, but the damn tooltips kept getting in the
way of typing. So i added an option to allow the ability to have the
tooltip appear at the mouse, or in the bottom left of the element with the
tooltip on.

ADD TO DEFAULT OPTIONS:

showAtMousePointer: true    // If true, the tooltip appears at the position
of the mouse pointer, else the bottom left of the element if false.

REPLACE SHOW() METHOD WITH:

    show: function(e) {

        if (this.options.showAtMousePointer) {
            this.xCord = Event.pointerX(e);
            this.yCord = Event.pointerY(e);
            } else {
            this.xCord = this.el.cumulativeOffset()['left']+5;
            this.yCord = this.el.cumulativeOffset()['top']+this.el.getHeight()-20;
        }

        if(!this.initialized)
            this.timeout = window.setTimeout(this.appear.bind(this),
this.options.delay);
    },

REPLACE THE UPDATE() METHOD WITH:

    update: function(e){
        if (this.options.showAtMousePointer) {
            this.xCord = Event.pointerX(e);
            this.yCord = Event.pointerY(e);
            } else {
            this.xCord = this.el.cumulativeOffset()['left']+5;
            this.yCord = this.el.cumulativeOffset()['top']+this.el.getHeight()-20;
        }
        this.setup();
    },

Kind regards,
Scott http://www.coderprofile.com/coder/VBAssassin

Original issue reported on code.google.com by vantagewebstudios@gmail.com on 20 Oct 2009 at 4:25

GoogleCodeExporter commented 8 years ago
Change this.xCord = this.el.cumulativeOff... & this.yCord = 
this.el.cumulativeOff... to:

this.xCord =
this.el.cumulativeOffset()['left']-this.el.cumulativeScrollOffset()['left']+docu
ment.viewport.getScrollOffsets()['left']+5;
this.yCord =
this.el.cumulativeOffset()['top']-this.el.cumulativeScrollOffset()['top']+docume
nt.viewport.getScrollOffsets()['top']+this.el.getHeight()-20;

It will fix anything to do with scroll bars. Including the document scroll bar 
+ any
parent scroll bars created using overflow:auto/scroll

Kind regards,
Scott

Original comment by vantagewebstudios@gmail.com on 21 Oct 2009 at 1:50