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

מתוך צפונות ויקי
מ (Replacing usage of $.escapeRE with mw.RegExp.escape)
מ (premature change (the source change is still in "master" and not deployed))
שורה 3: שורה 3:
var
var
createHint = function() {
createHint = function() {
var elem = $(mw.RegExp.escape(this.href.replace(/.*#/, '#'))),
var elem = $($.escapeRE(this.href.replace(/.*#/, '#'))),
html = elem.html(),
html = elem.html(),
ltr = elem.css('direction') == 'ltr',
ltr = elem.css('direction') == 'ltr',

גרסה מ־15:26, 23 ביוני 2015

if ( mw.config.get( '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);});
})();