미디어위키:Common.js: 두 판 사이의 차이
(본문 하이퍼링크를 새 탭에서 열기 (mw.hook wikipage.content)) |
(아카디아 게시판 -> 아카디아 포럼 명칭 변경, 모바일 viewport 대응 추가) |
||
| 1번째 줄: | 1번째 줄: | ||
/* 아카디아 | /* 아카디아 포럼 - 우측 상단 알약 탭 삽입 */ | ||
$(function() { | $(function() { | ||
if ($('.akadia-portal-links').length) return; | if ($('.akadia-portal-links').length) return; | ||
var $portal = $('<div class="akadia-portal-links"></div>'); | var $portal = $('<div class="akadia-portal-links"></div>'); | ||
$portal.append('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 | $portal.append('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>'); | ||
var $target = $('.vector-user-links').first(); | var $target = $('.vector-user-links').first(); | ||
if ($target.length) { $target.before($portal); } else { $('#p-personal').before($portal); } | if ($target.length) { $target.before($portal); } else { $('#p-personal').before($portal); } | ||
}); | }); | ||
/* 본문 하이퍼링크를 새 | /* 모바일 viewport 대응: 기본 viewport가 width=1000으로 고정되어 있어 디바이스 폭에 맞게 재설정 */ | ||
(function() { | |||
var screenW = window.screen && window.screen.width; | |||
if (screenW && screenW <= 720) { | |||
var meta = document.querySelector('meta[name="viewport"]'); | |||
var content = 'width=device-width, initial-scale=1, shrink-to-fit=no'; | |||
if (meta) { meta.setAttribute('content', content); } | |||
else { | |||
meta = document.createElement('meta'); | |||
meta.name = 'viewport'; | |||
meta.content = content; | |||
document.head.appendChild(meta); | |||
} | |||
} | |||
})(); | |||
/* 본문 하이퍼링크를 새 탭으로 열기 */ | |||
mw.hook('wikipage.content').add(function ($content) { | mw.hook('wikipage.content').add(function ($content) { | ||
$content.find('a').each(function () { | $content.find('a').each(function () { | ||
2026년 5월 12일 (화) 08:25 판
/* 아카디아 포럼 - 우측 상단 알약 탭 삽입 */
$(function() {
if ($('.akadia-portal-links').length) return;
var $portal = $('<div class="akadia-portal-links"></div>');
$portal.append('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>');
var $target = $('.vector-user-links').first();
if ($target.length) { $target.before($portal); } else { $('#p-personal').before($portal); }
});
/* 모바일 viewport 대응: 기본 viewport가 width=1000으로 고정되어 있어 디바이스 폭에 맞게 재설정 */
(function() {
var screenW = window.screen && window.screen.width;
if (screenW && screenW <= 720) {
var meta = document.querySelector('meta[name="viewport"]');
var content = 'width=device-width, initial-scale=1, shrink-to-fit=no';
if (meta) { meta.setAttribute('content', content); }
else {
meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = content;
document.head.appendChild(meta);
}
}
})();
/* 본문 하이퍼링크를 새 탭으로 열기 */
mw.hook('wikipage.content').add(function ($content) {
$content.find('a').each(function () {
var $a = $(this);
var href = $a.attr('href');
if (!href) return;
// 섹션 앵커(#section)는 새 탭으로 열지 않음
if (href.charAt(0) === '#') return;
// 섹션 편집(== 편집 ==) 링크는 새 탭으로 열지 않음
if ($a.closest('.mw-editsection').length) return;
$a.attr('target', '_blank');
var rel = $a.attr('rel') || '';
if (rel.indexOf('noopener') === -1) {
$a.attr('rel', (rel + ' noopener noreferrer').trim());
}
});
});