MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 217: | Line 217: | ||
// ── Init ─────────────────────────────────────────────────────── | // ── Init ─────────────────────────────────────────────────────── | ||
function init() { | function init() { | ||
tagTextNodes(); | var content = document.querySelector('.mw-parser-output'); | ||
var alreadyTagged = content && content.querySelector('[data-deva]'); | |||
if (!alreadyTagged) { | |||
translatableSpans = []; | |||
tagTextNodes(); | |||
} | |||
buildBar(); | buildBar(); | ||
watchTocActive(); | watchTocActive(); | ||
} | } | ||
if (window.mw) { | if (window.mw) { | ||
mw.hook('wikipage.content').add(function () { | mw.hook('wikipage.content').add(function () { | ||
var oldBar = document.querySelector('.gr-script-bar'); | setTimeout(function () { | ||
var oldBar = document.querySelector('.gr-script-bar'); | |||
if (oldBar) oldBar.remove(); | |||
// | |||
// Check if content is already tagged from a previous hook fire | |||
var content = document.querySelector('.mw-parser-output'); | |||
var alreadyTagged = content && content.querySelector('[data-deva]'); | |||
if (!alreadyTagged) { | |||
translatableSpans = []; | |||
tagTextNodes(); | |||
} | |||
buildBar(); | |||
watchTocActive(); | |||
}, 150); | |||
}); | }); | ||
} | } | ||