MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 664: | Строка 664: | ||
mw.hook('wikipage.content').fire(root); | mw.hook('wikipage.content').fire(root); | ||
initAjaxLoader(root); | initAjaxLoader(root); | ||
} | } | ||
| Строка 708: | Строка 707: | ||
} | } | ||
}); | }); | ||
} | |||
function createPlaceholderWithSpinner(text, loadingImgHTML) { | |||
if (!loadingImgHTML) { | |||
loadingImgHTML = '<img alt="Файл:Silva-loading.gif" src="/images/4/45/Silva-loading.gif?20260316201152" decoding="async" width="16" height="16" style="vertical-align:middle;margin-right:6px">'; | |||
} | |||
if (!text) { | |||
text = "Пожалуйста, подождите, содержимое загружается..."; | |||
} | |||
var placeholder = document.createElement("span"); | |||
placeholder.className = "ajax-load-placeholder"; | |||
placeholder.innerHTML = loadingImgHTML + '<span class="ajax-load-text">' + text + '</span>'; | |||
return placeholder; | |||
} | } | ||
| Строка 718: | Строка 733: | ||
var queue = []; | var queue = []; | ||
var processing = false; | var processing = false; | ||
function processQueue() { | function processQueue() { | ||
| Строка 744: | Строка 757: | ||
nextBatch(); | nextBatch(); | ||
} | } | ||
| Строка 762: | Строка 768: | ||
if (!wikiText) return; | if (!wikiText) return; | ||
var loadingText = | var loadingImgHTML = loadingEl ? (loadingEl.innerHTML || "").trim() || null : null; | ||
var loadingText = loadingEl ? (loadingEl.textContent || loadingEl.innerText || "").trim() || null : null; | |||
if (loadingEl && loadingEl.parentNode) { | if (loadingEl && loadingEl.parentNode) { | ||
loadingEl.parentNode.removeChild(loadingEl); | loadingEl.parentNode.removeChild(loadingEl); | ||
} | } | ||
| Строка 776: | Строка 782: | ||
container.dataset.ajaxLoaded = "1"; | container.dataset.ajaxLoaded = "1"; | ||
var placeholder = createPlaceholderWithSpinner(loadingText); | var placeholder = createPlaceholderWithSpinner(loadingText, loadingImgHTML); | ||
if (container && container.parentNode) { | if (container && container.parentNode) { | ||
| Строка 788: | Строка 794: | ||
}, { once: true }); | }, { once: true }); | ||
} else { | } else { | ||
var placeholder = createPlaceholderWithSpinner(loadingText); | var placeholder = createPlaceholderWithSpinner(loadingText, loadingImgHTML); | ||
if (contentEl && contentEl.parentNode) { | if (contentEl && contentEl.parentNode) { | ||
| Строка 1077: | Строка 1083: | ||
if (!root) return; | if (!root) return; | ||
var placeholder = createPlaceholderWithSpinner(); | |||
var placeholder = | |||
root.innerHTML = ''; | root.innerHTML = ''; | ||