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

מתוך צפונות ויקי
(←‏using [[mw:CodeEditor|CodeEditor]]: התאמה להערות ltr, עקב תלונת משתמשים.)
מ (26 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-CiteTooltip.js יובאו)
 
(14 גרסאות ביניים של 4 משתמשים אינן מוצגות)
שורה 1: שורה 1:
if (wgAction == 'view')
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  
&& 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() {
createHint = function() {
var elem = $($.escapeRE(this.href.replace(/.*#/, '#')));
var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ).replace(/"/g, '\\"') + '"]',
if (elem.css('direction') == 'ltr') //tipsy forces text-align, so class itself is not enough
elem = $(selector),
return '<div  class="mw-content-ltr" style="text-align:left">' + elem.html() + '</div>';
html = elem.html(),
else
ltr = elem.css('direction') == 'ltr',
return elem.html();
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() {
gravity = function() {
var loc =  
var loc =
($(this).offset().top > ($(document).scrollTop() + $(window).height() - 120) ? 's' : 'n') +
($(this).offset().top > ($(document).scrollTop() + $(window).height() - 120) ? 's' : 'n') +
($(this).offset().left > ($(document).scrollLeft() + $(window).width() / 4) ? '' : 'w');
($(this).offset().left > ($(document).scrollLeft() + $(window).width() / 4) ? '' : 'w');
שורה 16: שורה 24:
},
},
tipsyParams = {html: true, delayOut: 1500, delayIn: 300, fade: true, opacity: 1, gravity: gravity, title: createHint};
tipsyParams = {html: true, delayOut: 1500, delayIn: 300, fade: true, opacity: 1, gravity: gravity, title: createHint};
 
$(function() {$('sup.reference a').tipsy(tipsyParams);});
$(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);});
});