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

מתוך צפונות ויקי
(JS "return" is an aberant, due to JS automatic addition of semicolon at EOL after a return statement.)
מ (26 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-CiteTooltip.js יובאו)
 
(10 גרסאות ביניים של 4 משתמשים אינן מוצגות)
שורה 1: שורה 1:
if (wgAction == 'view' && ! mw.user.options.get('gadget-popup')) //note: this gadget depends on jquery.tipsy and mediawiki.user.
if ( mw.config.get( 'wgAction' ) === 'view'  
(function() { // do not contaminate main namespace.
&& 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
var
createHint = function() {
createHint = function() {
var elem = $($.escapeRE(this.href.replace(/.*#/, '#'))),
var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ).replace(/"/g, '\\"') + '"]',
elem = $(selector),
html = elem.html(),
html = elem.html(),
ltr = elem.css('direction') == 'ltr',
ltr = elem.css('direction') == 'ltr',
divClass = ltr ? 'class="mw-content-ltr"' : '',
divClass = ltr ? 'class="mw-content-ltr"' : '',
divCss = 'style="word-wrap:break-word;' + (ltr ? 'text-align:left;' : '') + '"';
divCss = 'style="word-wrap:break-word;' + (ltr ? 'text-align:left;' : '') + '"';
console.log(selector);
return html ? '<div ' + divClass + divCss + '>' + html + '</div>' : '';
return html ? '<div ' + divClass + divCss + '>' + html + '</div>' : '';
},
},
שורה 19: שורה 26:


$(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);});
});