미디어위키:CategoryPillar.js

Nxdsxn (토론 | 기여)님의 2026년 7월 17일 (금) 17:42 판 (Install package: clbiwiki-portal-frame-canvas-atomic-v3-20260717 / js/CategoryPillar.js)

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
/* portal-frame canvas v3 — 2026-07-17 */
/* =========================================
CategoryPillar
canvas CategoryNav 내부 프로젝트 기둥 호환 모듈
========================================= */

(function (window, document, mw) {
    'use strict';

    var BUILD_TAG = 'portal-frame-canvas-v3-20260717';
    window.PortalFrameModules = window.PortalFrameModules || {};
    window.PortalFrameModules.CategoryPillar = BUILD_TAG;

    var REQUIRED_CATEGORY_VERSION = BUILD_TAG;
    var warned = false;

    function categoryReady() {
        var ready = window.CategoryNav &&
            window.CategoryNav.version === REQUIRED_CATEGORY_VERSION &&
            typeof window.CategoryNav.renderAll === 'function';
        if (!ready && !warned && window.console && typeof window.console.error === 'function') {
            warned = true;
            window.console.error(
                '[CategoryNav 구버전 감지: CategoryPillar.js와 MediaWiki:CategoryNav.js를 같은 배포 세트로 업데이트하세요] ' +
                '필요 버전=' + REQUIRED_CATEGORY_VERSION
            );
        }
        if (ready) warned = false;
        return ready;
    }

    function renderAll(root) {
        var scope = root && root.querySelectorAll ? root : document;
        if (!categoryReady()) return 0;
        return scope.querySelectorAll(
            '.main-portal [data-component="category-nav"] .portal-category-canvas'
        ).length;
    }

    window.CategoryPillar = {
        version:BUILD_TAG,
        buildTag:BUILD_TAG,
        init:renderAll,
        renderAll:renderAll,
        render:function () { return renderAll(document) > 0; }
    };

    if (mw && mw.hook) {
        mw.hook('wikipage.content').add(function (content) {
            renderAll(content && content[0] ? content[0] : document);
        });
    }
}(window, document, window.mw));