Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [jquery] Przerobienie starej funkcji tooltip., Proszę o podpowiedź.
luis2luis
post 29.01.2020, 19:07:30
Post #1





Grupa: Zarejestrowani
Postów: 190
Pomógł: 0
Dołączył: 25.11.2015

Ostrzeżenie: (0%)
-----


Witam.
Mam w pewną funkcje tooltip, która ma jużpare lat smile.gif

Chciałem zmienić jej wywoływanie poprostu poprzez klase .help, jednak mam problem, nie wiem jakie parametry przekazać funkcji. Fajny mechanizm jest w JQuery UI, ale nie chce teraz zmieniać wszystkich wywołań toltip'a.


Kod
function help(v,e,t) {

  alert('v:' + v + ' e:'+e+' t:'+t); wywołałem taki alert. poniżej info co zwraca.

  if(!v.title||!document.createElement)return
  t=document.createElement("div")
  t.move=function(e){
    e=e||event

    if( !e ) e = window.event;

    if ( e.pageX || e.pageY ) {//ff
      posx = e.pageX;
      posy = e.pageY;
    } else if ( e.clientX || e.clientY ) {//ie nie dziala
      posx = e.clientX + document.body.scrollLeft;
      posy = e.clientY + document.body.scrollTop;
    }

    t.style.left=posx-205+"px";//x FF
    t.style.top=posy+30+"px";

  }
  t.hide=function(x){
    v.title=t.innerHTML
    if(x=$$("tooltip")) document.body.removeChild(x)
  }
  t.move(e);
  t.id="tooltip"
  t.innerHTML=v.title;v.title=""
  document.body.appendChild(t)
  v.onmouseout=t.hide
  v.onmousemove=t.move
}


//wywołuje tak:
<a onmouseover=help(this,event) title="TREŚC NA WYSKAKUJĄCYM OKIENKU.." href="java script:;"><img src="grafika/help.gif"></a>

//chciałem po prostu tak:

<span class="help" title="tresc wyskakujacego okienka.">HELP</span>


Alert z tej funkcji zwraca: v:java script:; e:[object MouseEvent] t:undefined

Nie wiem jak wywołać tą funkcje w taki sposób:


Kod
$( document ).ready(function() {

  $( ".help" ).on( "mouseover", function(e) {
    help($(this), e);
    console.log('wywołana funkcja HELP');
  });
});


Ten post edytował luis2luis 29.01.2020, 20:33:24
Go to the top of the page
+Quote Post
aras785
post 29.01.2020, 22:29:54
Post #2





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

Ostrzeżenie: (0%)
-----


Cześć,

https://jsfiddle.net/o0aeug1c/1/

Ogólnie przepisałbym to na jquery po prostu smile.gif
Go to the top of the page
+Quote Post
luis2luis
post 30.01.2020, 00:24:36
Post #3





Grupa: Zarejestrowani
Postów: 190
Pomógł: 0
Dołączył: 25.11.2015

Ostrzeżenie: (0%)
-----


Cytat(aras785 @ 29.01.2020, 22:29:54 ) *
Cześć,

https://jsfiddle.net/o0aeug1c/1/

Ogólnie przepisałbym to na jquery po prostu smile.gif


Dziękuje bardzo. Niestety okienko nie zawsze pojawia się i nie znika wogóle smile.gif

Ten post edytował luis2luis 30.01.2020, 00:24:57
Go to the top of the page
+Quote Post
aras785
post 30.01.2020, 00:32:09
Post #4





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

Ostrzeżenie: (0%)
-----


Bo nie wiedziałem, że mam przerobić tak aby działało to poprawnie biggrin.gif

https://jsfiddle.net/Lry2n56d/
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 14:44