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

מתוך צפונות ויקי
(לכבות אם popup מופעל. לא צריך תלות מפורשת ב-tipsy - זה מוגדר כבר בקובץ הראשי.)
שורה 1: שורה 1:
if (wgAction == 'view')
if (wgAction == 'view' && ! mw.user.options.get('gadget-popup')) //note: this gadget depends on jquery.tipsy and mediawiki.user.
mw.loader.using('jquery.tipsy', function() {
(function() { // do not contaminate main namespace.
var
var
createHint = function() {
createHint = function() {
שורה 8: שורה 8:
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;' : '') + '"';
if (html)
return html
return '<div ' + divClass + divCss + '>' + html + '</div>';
? '<div ' + divClass + divCss + '>' + html + '</div>'
return '';
: '';
},
},
gravity = function() {
gravity = function() {
שורה 21: שורה 21:


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

גרסה מ־21:32, 19 באפריל 2012

if (wgAction == 'view' && ! mw.user.options.get('gadget-popup')) //note: this gadget depends on jquery.tipsy and mediawiki.user.
(function() { // do not contaminate main namespace.
	var
		createHint = function() {
			var elem = $($.escapeRE(this.href.replace(/.*#/, '#'))),
				html = elem.html(),
				ltr = elem.css('direction') == 'ltr',
				divClass = ltr ? 'class="mw-content-ltr"' : '',
				divCss = 'style="word-wrap:break-word;' + (ltr ? 'text-align:left;' : '') + '"';
			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);});
})();