MediaWiki:Gadget-Tooltip.js: Difference between revisions

Kuhlau (talk | contribs)
No edit summary
Kuhlau (talk | contribs)
No edit summary
(One intermediate revision by the same user not shown)
Line 4: Line 4:
});
});


// Auto-positioning of floating tooltips, mainly for [[T:tt]]
// Auto-positioning of floating tooltips, on desktop/hoverable only (maybe need to refine by skin so that it matches the css?)
mw.loader.using('oojs-ui-widgets').then(() => { // make sure the PopupWidget library is loaded
mw.loader.using('oojs-ui-widgets').then(() => { // make sure the PopupWidget library is loaded
const supportsHover = window.matchMedia('(hover: hover)').matches;
mw.hook('wikipage.content').add((contents)=>{ // hydrate any content inserted
mw.hook('wikipage.content').add((contents)=>{ // hydrate any content inserted
if (contents instanceof Element || contents instanceof NodeList) {contents = $(contents);}
if (contents instanceof Element || contents instanceof NodeList) {contents = $(contents);}
Line 33: Line 35:
// [[T:Tt]]'s toggle effect
// [[T:Tt]]'s toggle effect
$wrapper.append(popup.$element);
$wrapper.append(popup.$element);
$toggle.on('click', ()=> { popup.toggle() });
// T:Extra Effect's hover effect
// T:Extra Effect's hover effect
/* if (isEE) {
let time;
popup.$element.find('.oo-ui-popupWidget-popup').toggleClass('hnaw-extra-effect', true);
$toggle.add(popup.$element).on('mouseover mouseout', (e) => {
let time;
if (time) { clearTimeout(time); }
$toggle.add(popup.$element).on('mouseover mouseout', (e) => {
time = setTimeout(()=>{
if (time) { clearTimeout(time); }
popup.toggle(e.type==='mouseout' ? false : true);
time = setTimeout(()=>{
}, e.type==='mouseout' ? 250 : 0);
popup.toggle(e.type==='mouseout' ? false : true);
});
}, e.type==='mouseout' ? 250 : 0);
});
}*/
});
});
});
});
});
});