Mudanças entre as edições de "Widget:Item"
Ir para navegação
Ir para pesquisar
m |
m |
||
| Linha 387: | Linha 387: | ||
function getThumbUrl(filename, width) { | function getThumbUrl(filename, width) { | ||
var title = "Special:Redirect/file/" + String(filename).replace(/ /g, "_"); | var title = "Special:Redirect/file/" + String(filename).replace(/ /g, "_"); | ||
var scriptPath = ""; | var scriptPath = ""; | ||
try { | try { | ||
| Linha 397: | Linha 392: | ||
scriptPath = mw.config.get("wgScriptPath") || ""; | scriptPath = mw.config.get("wgScriptPath") || ""; | ||
} | } | ||
} catch ( | } catch (e) { /* ignore */ } | ||
/* Caminho relativo ao origin da página (HTTPS). mw.util.getUrl | |||
pode gerar http://IP/… e o browser bloqueia Mixed Content. */ | |||
return scriptPath + "/index.php?title=" + encodeURIComponent(title) + "&width=" + width; | return scriptPath + "/index.php?title=" + encodeURIComponent(title) + "&width=" + width; | ||
} | } | ||
| Linha 423: | Linha 420: | ||
} | } | ||
} | } | ||
function watchIconHydration() { | |||
if (!window.MutationObserver) return; | |||
var pending = null; | |||
var observer = new MutationObserver(function (mutations) { | |||
var need = false; | |||
for (var i = 0; i < mutations.length; i++) { | |||
var added = mutations[i].addedNodes; | |||
for (var j = 0; j < added.length; j++) { | |||
var node = added[j]; | |||
if (node.nodeType !== 1) continue; | |||
if (node.matches && node.matches(".item-icon[data-i]")) { | |||
need = true; | |||
break; | |||
} | |||
if (node.querySelector && node.querySelector(".item-icon[data-i]")) { | |||
need = true; | |||
break; | |||
} | |||
} | |||
if (need) break; | |||
} | |||
if (!need) return; | |||
if (pending) clearTimeout(pending); | |||
pending = setTimeout(function () { | |||
pending = null; | |||
hydrateAllIcons(); | |||
}, 0); | |||
}); | |||
observer.observe(document.documentElement, { childList: true, subtree: true }); | |||
} | |||
window.glaItemHydrateIcons = hydrateAllIcons; | |||
function protectItemWrapperEvents() { | function protectItemWrapperEvents() { | ||
| Linha 453: | Linha 483: | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
hydrateAllIcons(); | hydrateAllIcons(); | ||
watchIconHydration(); | |||
}); | }); | ||
} else { | } else { | ||
hydrateAllIcons(); | hydrateAllIcons(); | ||
watchIconHydration(); | |||
} | } | ||
protectItemWrapperEvents(); | protectItemWrapperEvents(); | ||