मेडियाविकि:Gadget-ReferenceTooltips.js
टिप्पणी: संरक्षणक बाद, अहाँक परिवर्तन देखबा लेल अपन ब्राउजरक उपस्मृतिक हटबए पडत। फायरफक्स/ सफारी: सिफ्टके दाबि रिलोड, वा Ctrl-F5 वा Ctrl-R (म्याकपर ⌘-R) गुगल क्रोम: Ctrl-Shift-R दाबी(म्याकपर ⌘-Shift-R) इन्टरनेट एक्सप्लोरर: Refresh क्लिक करि Ctrl दाबि, वा Ctrl-F5 दाबी ओपेरा: Menu → Settings पर जाए (म्याकपर Opera → Preferences) आ ओकर बाद Privacy & security → Clear browsing data → Cached images and files
।
// See [[mw:Reference Tooltips]]
window.pg || $(document).ready( function($) {
// Make sure we are in article, project, or help namespace
if ( $.inArray(mw.config.get('wgCanonicalNamespace'), ['', 'Project', 'Help'] ) != -1 ) {
$(".reference").each( function() {
var tooltipNode, timer;
function findRef( h ){
h = h.firstChild.getAttribute("href"); h = h && h.split("#"); h = h && h[1];
h = h && document.getElementById( h );
return h;
}
function hide(){
if( tooltipNode && tooltipNode.parentNode == document.body ) {
timer = setTimeout( function() {
$(tooltipNode).animate({opacity: 0}, 100, function(){ document.body.removeChild( tooltipNode ) })
}, 100)
} else {
var h = findRef( this );
h && (h.style.border = "");
}
}
function show(){
if( !tooltipNode.parentNode || tooltipNode.parentNode.nodeType === 11 ){
document.body.appendChild( tooltipNode );
}
$(tooltipNode).stop().animate({opacity: 1}, 100)
clearTimeout( timer );
}
$(this).hover(function(){
var h = findRef( this );
if( !h ){return};
if( ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ) + $(window).height() > $( h ).offset().top ) {
h.style.border = "#080086 2px solid";
return;
}
if(!tooltipNode){
tooltipNode = document.createElement("ul");
tooltipNode.className = "referencetooltip";
var c = tooltipNode.appendChild( h.cloneNode( true ) );
try {
if( c.firstChild.nodeName != "A" ) {
while( c.childNodes[1].nodeName == "A" && c.childNodes[1].getAttribute( "href" ).indexOf("#cite_ref-") !== -1 ) {
do { c.removeChild( c.childNodes[1] ) } while ( c.childNodes[1].nodeValue == " " );
}
}
} catch (e) { mw.log(e) }
c.removeChild( c.firstChild );
tooltipNode.appendChild( document.createElement( "li" ) );
$(tooltipNode).hover(show, hide);
}
show();
var o = $(this).offset(), oH = tooltipNode.offsetHeight;
$(tooltipNode).css({top: o.top - oH, left: o.left - 7 });
if( tooltipNode.offsetHeight > oH ) { // is it squished against the right side of the page?
$(tooltipNode).css({left:'auto',right:0});
tooltipNode.lastChild.style.marginLeft = (o.left - tooltipNode.offsetLeft) + "px";
}
}, hide)
} );
}
} );