מדיה ויקי:Gadget-CiteTooltip.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
(די.)
מ (26 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-CiteTooltip.js יובאו)
 
(21 גרסאות ביניים של 4 משתמשים אינן מוצגות)
שורה 1: שורה 1:
if (wgAction == 'view' && wgNamespaceNumber== 0)
if ( mw.config.get( 'wgAction' ) === 'view'  
mw.loader.using('jquery.tipsy', function() {
&& mw.user.options.get('gadget-popup') != '1' // note: do not use !==, as we can't trust the precise type of the option
var createHint = function() {return $('#' + this.id.replace('ref', 'note')).html();},
&& mw.user.options.get('popupsreferencepreviews') != '1'
autoGravity = function (){return $(this).offset().left>($(document).scrollLeft()+$(window).width()/2)?'ne':'nw';}  
&& mw.user.options.get( 'popups-reference-previews' ) != '1'
tipsyParams = {html: true, delayOut: 1500, delayIn: 300, fade: true, opacity: 1, gravity: autoGravity, title: createHint};
) //note: this gadget depends on jquery.tipsy. it's consumed here, instead of gadget definition,
$(function() {$('sup.reference').tipsy(tipsyParams);});
//in case one of the conditions above is false, to avoid unnecessary load of the library
mw.loader.using(['jquery.tipsy'], function() {  
var
createHint = function() {
var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ).replace(/"/g, '\\"') + '"]',
elem = $(selector),
html = elem.html(),
ltr = elem.css('direction') == 'ltr',
divClass = ltr ? 'class="mw-content-ltr"' : '',
divCss = 'style="word-wrap:break-word;' + (ltr ? 'text-align:left;' : '') + '"';
console.log(selector);
return html ? '<div ' + divClass + divCss + '>' + html + '</div>' : '';
},
gravity = function() {
var loc =
($(this).offset().top > ($(document).scrollTop() + $(window).height() - 120) ? 's' : 'n') +
($(this).offset().left > ($(document).scrollLeft() + $(window).width() / 4) ? '' : 'w');
return loc;
},
tipsyParams = {html: true, delayOut: 1500, delayIn: 300, fade: true, opacity: 1, gravity: gravity, title: createHint};
 
$(function() {$('sup.reference a').tipsy(tipsyParams);});
});
});

גרסה אחרונה מ־23:20, 4 בדצמבר 2022

if ( mw.config.get( 'wgAction' ) === 'view' 
	&& mw.user.options.get('gadget-popup') != '1' // note: do not use !==, as we can't trust the precise type of the option
	&& mw.user.options.get('popupsreferencepreviews') != '1'
	&& mw.user.options.get( 'popups-reference-previews' ) != '1'
	)	//note: this gadget depends on jquery.tipsy. it's consumed here, instead of gadget definition, 
		//in case one of the conditions above is false, to avoid unnecessary load of the library
mw.loader.using(['jquery.tipsy'], function() { 
	var
		createHint = function() {
			var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ).replace(/"/g, '\\"') + '"]',
				elem = $(selector),
				html = elem.html(),
				ltr = elem.css('direction') == 'ltr',
				divClass = ltr ? 'class="mw-content-ltr"' : '',
				divCss = 'style="word-wrap:break-word;' + (ltr ? 'text-align:left;' : '') + '"';
			console.log(selector);
			return html ? '<div ' + divClass + divCss + '>' + html + '</div>' : '';
		},
		gravity = function() {
			var loc =
				($(this).offset().top > ($(document).scrollTop() + $(window).height() - 120) ? 's' : 'n') +
				($(this).offset().left > ($(document).scrollLeft() + $(window).width() / 4) ? '' : 'w');
			return loc;
		},
		tipsyParams = {html: true, delayOut: 1500, delayIn: 300, fade: true, opacity: 1, gravity: gravity, title: createHint};

	$(function() {$('sup.reference a').tipsy(tipsyParams);});
});