मिडियाविकी:Gadget-ShortUrl.js

विकिपीडिया कडल्यान

चत्राय: सांबाळ्ळ्या उपरांत, तुका घडयेक तुज्या ब्रावसराचो कॅश कडसरावंक पडत बदल पळोंवचे खातीर.

  • Firefox / Safari: Shift > धर Reload क्लीक करताना, वा दाम Ctrl-F5 वा Ctrl-R (⌘-R मॅक-आचेर)
  • Google Chrome: Ctrl-Shift-R दाम (⌘-Shift-R एका मॅक-आचेर)
  • Internet Explorer: Ctrl dhor Refresh क्लीक करताना, वा दाम Ctrl-F5
  • Opera: हांगा वच: Menu → Settings (Opera → Preferences मॅक-आचेर) आनी उपरांत Privacy & security → Clear browsing data → Cached images and files.‎
/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === Warning: Global gadget file ===                      |
 * |                  Changes made here will affect many users                   |
 * | Please discuss on the talk page or Tinto before making any changes to this  |
 * |_____________________________________________________________________________|
 *
 */
( 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;
	}

	var lang = mw.config.get('wgUserLanguage');
    var tooltiptext;
		switch(lang) {
			case 'gom-deva':
			case 'gom':
				tooltiptext = 'धाकटें URL: ' ;
    			break;
			case 'en':
				tooltiptext = 'Short URL: ' ;
    			break;
			default:
				tooltiptext = 'Dhaktem URL: ' ;
		}


	//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( tooltiptext + window.location.protocol + url )
						.append( $( '<a>' )
							.attr( {
								'class': 'title-shortlink title-shortlink-help-link',
								'id': 'title-shortlink-help-link',
								'href': '//gom.wikipedia.org/wiki/Help:Dhaktem_URL',
								'target': '_blank'
							} )
						);
	//add tooltip to document
	$( '#firstHeading' ).append( $icon );
	$( 'body' ).prepend( $tooltip.hide() );

	$( '.title-shortlink' ).mouseover( function() {
		var $offset = $icon.offset(),
			left;
		if ( timeoutID !== null ) {
			clearTimeout( timeoutID );
			timeoutID = null;
		}
		$icon.animate( { opacity: 1 }, 400 );
		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( 400,
				function () {
					$icon.animate( { opacity: 0.5 }, 400 );
				}
			);
		}, 500);
	} );
} );
} ( window, document, jQuery )); // End wrap with anonymous function