미디어위키:Gadget-quickpage.js: 두 판 사이의 차이
새 문서: mw.loader.using( ['oojs-ui-core', 'oojs-ui.styles.icons-editing'], function () { →────────── CSS (1회 삽입) ──────────: if (!document.getElementById('qp-style')) { mw.util.addCSS(` .qp-card { padding:16px; border:1px solid light-dark(#ccc,#555); border-radius:8px; background:light-dark(#f9f9f9,#222); } `).id = 'qp-style'; } /* ────────── UI 주입 ────────... |
편집 요약 없음 |
||
| 4번째 줄: | 4번째 줄: | ||
/* ────────── CSS (1회 삽입) ────────── */ | /* ────────── CSS (1회 삽입) ────────── */ | ||
if (!document.getElementById('qp-style')) { | |||
var style = document.createElement('style'); | |||
style.id = 'qp-style'; | |||
style.textContent = ` | |||
.qp-card { | .qp-card { | ||
padding:16px; | padding:16px; | ||
| 12번째 줄: | 14번째 줄: | ||
background:light-dark(#f9f9f9,#222); | background:light-dark(#f9f9f9,#222); | ||
} | } | ||
`; | |||
document.head.appendChild(style); | |||
} | |||
/* ────────── UI 주입 ────────── */ | /* ────────── UI 주입 ────────── */ | ||
2026년 1월 24일 (토) 18:15 판
mw.loader.using(
['oojs-ui-core', 'oojs-ui.styles.icons-editing'],
function () {
/* ────────── CSS (1회 삽입) ────────── */
if (!document.getElementById('qp-style')) {
var style = document.createElement('style');
style.id = 'qp-style';
style.textContent = `
.qp-card {
padding:16px;
border:1px solid light-dark(#ccc,#555);
border-radius:8px;
background:light-dark(#f9f9f9,#222);
}
`;
document.head.appendChild(style);
}
/* ────────── UI 주입 ────────── */
mw.hook('wikipage.content').add(function ($content) {
$content.find('.quickpage-container').each(function () {
var $box = $(this);
if ($box.children().length) return;
var input = new OO.ui.TextInputWidget({
placeholder: '문서 제목 입력…'
});
var button = new OO.ui.ButtonWidget({
label: '문서 생성',
icon: 'edit',
flags: ['progressive']
});
var field = new OO.ui.ActionFieldLayout(
input, button, { align: 'top' }
);
$box.append(field.$element);
function go() {
var title = input.getValue().trim();
if (!title) return;
var encoded = mw.util.wikiUrlencode(title);
// MediaWiki는 존재 여부와 상관없이 edit로 가면
// 없으면 생성, 있으면 편집
var url = mw.util.getUrl(encoded, { action: 'edit' });
window.location.href = url;
}
button.on('click', go);
input.on('enter', go);
});
});
}
);