मीडियाविकि:Gadget-ShortUrl.js
पठन सेटिंग्स
सूचना : भवता/भवत्या कृतानि सम्पादनानि संरक्ष्य तानि परिवर्तनेषु द्रष्टुं गवेषकस्य पृष्ठस्य पुनरारोपणम् (reload) आवश्यकं भवति ।
- Firefox / Safari: Shiftकुड्मलेन सह Reloadकुड्मलं नुदतु ।
- Google Chrome: Ctrl-Shift-R नोदनेन पुनरारोपणं भवति । (⌘-R इति Mac तन्त्रांशप्रयोक्तॄभ्यः)
- Internet Explorer: Ctrlकुड्मलेन सह Refreshकुड्मलं नुदतु, Ctrl-F5 नुदतु वा ।
- Opera: Tools → Preferences इत्यत्र गत्वा कर्तुं शक्नोति ।
/* _____________________________________________________________________________
* | |
* | === पूर्वसूचना : वैश्विकोपकरणसञ्चिका === |
* |_____________________________________________________________________________|
*
*/
( function ( window, document, $, undefined ) { // Wrap with anonymous function
$( document ).ready(function () {
'use strict';
//get url from sidebar
var url = $("li#t-shorturl").children().attr("href");
//return if short url doesn't exist, or user's not in the view tab
if ( url === undefined ||
mw.config.get("wgAction") !== "view" ||
window.location.href.match("diff=") !== null ) {
return;
}
//create html elements
var timeoutID = null,
$icon = $( '<span>' )
.addClass('title-shortlink')
.addClass('title-shortlink-icon'),
$tooltip = $( '<span>' )
.addClass('title-shortlink')
.addClass('title-shortlink-tooltip')
.html( 'लघुसार्वसङ्केतः (URL) : ' + window.location.protocol + url )
.append( $( '<a>' )
.attr( {
'class': 'title-shortlink title-shortlink-help-link',
'id': 'title-shortlink-help-link',
'href': '//sa.wikipedia.org/wiki/विकिपीडिया:लघुसार्वसङ्केतः',
'target': '_blank'
} )
);
//add tooltip to document
$( '#firstHeading' ).append( $icon );
$( 'body' ).prepend( $tooltip.hide() );
// settimeout idea...
// http://stackoverflow.com/questions/6786322#comment8062858_6786647
$( '.title-shortlink' ).mouseover( function() {
var $offset = $icon.offset(),
left;
if ( timeoutID !== null ) {
clearTimeout( timeoutID );
timeoutID = null;
}
$icon.animate( { opacity: 1 }, 4000 );
left = ( $offset.left + $tooltip.width() > window.innerWidth ) ?
$offset.left - $tooltip.width() :
$offset.left;
$tooltip
.css( {
'top' : $offset.top + $icon.height() + 'px',
'left' : left + 'px'
} )
.show();
} );
$( '.title-shortlink' ).mouseleave( function() {
timeoutID = setTimeout ( function () {
$tooltip.fadeOut( 4000,
function () {
$icon.animate( { opacity: 0.5 }, 4000 );
}
);
}, 500);
} );
} );
} ( window, document, jQuery )); // End wrap with anonymous function