미디어위키:Common.js: 두 판 사이의 차이
Resultofunion (토론 | 기여) 편집 요약 없음 |
Resultofunion (토론 | 기여) 편집 요약 없음 |
||
| 318번째 줄: | 318번째 줄: | ||
// 데스크탑 언어 | // 데스크탑 언어 | ||
var langDiv = document.getElementById('right-navigation'); | $(document).ready(function () { | ||
if(langDiv) | |||
var navHTML = '<nav id="p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation">' + | // 왼쪽 인터랭 리스트 가져오기 | ||
const $interLangList = $('#p-lang .vector-menu-content-list'); | |||
if ($interLangList.length === 0) return; | |||
// 헤더 삽입 위치 | |||
var langDiv = document.getElementById('right-navigation'); | |||
if (!langDiv) return; | |||
// 헤더 기본 틀 생성 | |||
var navHTML = | |||
'<nav id="p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation">' + | |||
'<input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">' + | |||
'<label id="p-cactions-label" aria-label="" class="vector-menu-heading">' + | |||
'<span class="select-language"></span>' + | |||
'<span class="vector-menu-heading-label">Language</span>' + | |||
'</label>' + | |||
} | '<div class="vector-menu-content">' + | ||
'<ul class="vector-menu-content-list" id="header-lang-list"></ul>' + | |||
'</div>' + | |||
'</nav>'; | |||
langDiv.insertAdjacentHTML('afterbegin', navHTML); | |||
// 헤더 ul | |||
const $headerList = $('#header-lang-list'); | |||
// 왼쪽 언어 li 를 하나씩 읽어서 헤더에 복사 | |||
$interLangList.find('li.interlanguage-link').each(function () { | |||
const $oldA = $(this).find('a'); | |||
const href = $oldA.attr('href'); | |||
const title = $oldA.attr('title'); | |||
const text = $oldA.text(); | |||
const newLi = | |||
'<li class="mw-list-item">' + | |||
'<a href="' + href + '" title="' + title + '">' + | |||
'<span>' + text + '</span>' + | |||
'</a>' + | |||
'</li>'; | |||
$headerList.append(newLi); | |||
}); | |||
}); | |||