מדיה ויקי:Gadget-CiteTooltip.js: הבדלים בין גרסאות בדף
(maintenance: improve the jquery selector to match more and not throw JS errors) |
אין תקציר עריכה |
||
שורה 4: | שורה 4: | ||
var | var | ||
createHint = function() { | createHint = function() { | ||
var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ) + '"]', | var selector = '[id="' + decodeURIComponent( mw.util.escapeRegExp(this.href.replace(/.*#/, '') ) ).replace(/"/g, '\\"') + '"]', | ||
elem = $(selector), | elem = $(selector), | ||
html = elem.html(), | html = elem.html(), |
גרסה מ־19:41, 27 באוגוסט 2020
if ( mw.config.get( 'wgAction' ) === 'view' && ! mw.user.options.get('gadget-popup')) //note: this gadget depends on jquery.tipsy and mediawiki.user.
mw.loader.using(['mediawiki.util', 'mediawiki.user'], function() {
if (mw.user.options.get('popupsreferencepreviews') == 1) return;
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);});
});