MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показана 1 промежуточная версия этого же участника) | |||
| Строка 633: | Строка 633: | ||
var queue = []; | var queue = []; | ||
var processing = false; | var processing = false; | ||
// HTML для спиннера (анимация загрузки) | |||
var loadingImgHTML = '<img alt="Файл:Silva-loading.gif" src="/images/4/45/Silva-loading.gif?20260316201152" decoding="async" width="16" height="16" data-file-width="16" data-file-height="16" style="vertical-align:middle;margin-right:6px">'; | |||
function fetchParsedData(wikiText) { | function fetchParsedData(wikiText) { | ||
| Строка 722: | Строка 725: | ||
var loadingText = (loadingEl && (loadingEl.textContent || loadingEl.innerText || "").trim()) || "Загрузка..."; | var loadingText = (loadingEl && (loadingEl.textContent || loadingEl.innerText || "").trim()) || "Загрузка..."; | ||
// Если есть элемент .ajax-load-loading — можно удалить (как в оригинале), | |||
// но плейсхолдер мы всё равно создаём с картинкой + текстом. | |||
if (loadingEl && loadingEl.parentNode) { | if (loadingEl && loadingEl.parentNode) { | ||
loadingEl.parentNode.removeChild(loadingEl); | loadingEl.parentNode.removeChild(loadingEl); | ||
loadingEl = null; | loadingEl = null; | ||
} | |||
function createPlaceholderWithSpinner(text) { | |||
var placeholder = document.createElement("span"); | |||
placeholder.className = "ajax-load-placeholder"; | |||
// Добавляем картинку в начало и текст после неё | |||
placeholder.innerHTML = loadingImgHTML + '<span class="ajax-load-text">' + (text || '') + '</span>'; | |||
return placeholder; | |||
} | } | ||
| Строка 734: | Строка 747: | ||
container.dataset.ajaxLoaded = "1"; | container.dataset.ajaxLoaded = "1"; | ||
var placeholder = | var placeholder = createPlaceholderWithSpinner(loadingText); | ||
if (container && container.parentNode) { | if (container && container.parentNode) { | ||
| Строка 750: | Строка 761: | ||
}, { once: true }); | }, { once: true }); | ||
} else { | } else { | ||
var placeholder = | var placeholder = createPlaceholderWithSpinner(loadingText); | ||
if (contentEl && contentEl.parentNode) { | if (contentEl && contentEl.parentNode) { | ||