미디어위키:Gadget-CreatePageUw.js: 두 판 사이의 차이
둘러보기로 이동
검색으로 이동
편집 요약 없음 |
편집 요약 없음 |
||
| (같은 사용자의 중간 판 2개는 보이지 않습니다) | |||
| 9번째 줄: | 9번째 줄: | ||
} | } | ||
function | function insertSproutImage( input, fieldLayout ) { | ||
var | var imageBox; | ||
var image; | |||
var insertionTarget; | |||
if ( | if ( | ||
| 34번째 줄: | 22번째 줄: | ||
} | } | ||
imageBox = document.createElement( 'div' ); | |||
imageBox.className = 'pvz-createpage-sprout'; | |||
imageBox.className = | |||
image = document.createElement( 'img' ); | |||
image.src = mw.util.getUrl( | image.src = mw.util.getUrl( | ||
'Special:Redirect/file/Sprout_PvZ2.png' | 'Special:Redirect/file/Sprout_PvZ2.png' | ||
); | ); | ||
image.alt = ''; | image.alt = ''; | ||
image.className = 'pvz-design-critical'; | image.className = 'pvz-design-critical'; | ||
| 52번째 줄: | 34번째 줄: | ||
imageBox.appendChild( image ); | imageBox.appendChild( image ); | ||
insertionTarget = | |||
fieldLayout || | |||
input.closest( '.oo-ui-fieldLayout-field' ) || | |||
input.parentElement; | |||
if ( | if ( | ||
| 67번째 줄: | 47번째 줄: | ||
insertionTarget | insertionTarget | ||
); | ); | ||
} | |||
} | |||
function customizeInput( input ) { | |||
var inputWidget; | |||
var fieldLayout; | |||
input.placeholder = | |||
'새로 재배할 문서의 제목을 입력하세요'; | |||
input.setAttribute( | |||
'aria-label', | |||
'새로 재배할 문서의 제목을 입력하세요' | |||
); | |||
input.classList.add( | |||
'pvz-createpage-input' | |||
); | |||
inputWidget = input.closest( | |||
'.oo-ui-textInputWidget' | |||
); | |||
if ( inputWidget ) { | |||
inputWidget.classList.add( | |||
'pvz-createpage-input-widget' | |||
); | |||
} | |||
fieldLayout = input.closest( | |||
'.oo-ui-fieldLayout' | |||
); | |||
if ( fieldLayout ) { | |||
fieldLayout.classList.add( | |||
'pvz-createpage-input-layout' | |||
); | |||
} | |||
insertSproutImage( | |||
input, | |||
fieldLayout | |||
); | |||
} | |||
function customizeSubmitButton( form ) { | |||
var submitButton; | |||
var submitWidget; | |||
var fieldLayout; | |||
var label; | |||
submitButton = form.querySelector( | |||
'input[type="submit"], ' + | |||
'button[type="submit"], ' + | |||
'.oo-ui-buttonInputWidget-input, ' + | |||
'.oo-ui-buttonElement-button' | |||
); | |||
if ( !submitButton ) { | |||
return; | |||
} | |||
submitButton.classList.add( | |||
'pvz-createpage-submit-button' | |||
); | |||
submitButton.setAttribute( | |||
'aria-label', | |||
'제출' | |||
); | |||
if ( | |||
submitButton.tagName.toLowerCase() === | |||
'input' | |||
) { | |||
submitButton.value = '제출'; | |||
} else { | |||
label = submitButton.querySelector( | |||
'.oo-ui-labelElement-label' | |||
); | |||
if ( label ) { | |||
label.textContent = '제출'; | |||
} else { | |||
submitButton.textContent = '제출'; | |||
} | |||
} | |||
submitWidget = submitButton.closest( | |||
'.oo-ui-buttonInputWidget, ' + | |||
'.oo-ui-buttonWidget' | |||
); | |||
if ( submitWidget ) { | |||
submitWidget.classList.add( | |||
'pvz-createpage-submit-widget' | |||
); | |||
} | |||
fieldLayout = submitButton.closest( | |||
'.oo-ui-fieldLayout' | |||
); | |||
if ( fieldLayout ) { | |||
fieldLayout.classList.add( | |||
'pvz-createpage-submit-layout' | |||
); | |||
} | |||
} | |||
function initializeCreatePageUw() { | |||
var input; | |||
var form; | |||
input = document.getElementById( | |||
'mw-input-wptitle' | |||
); | |||
if ( !input ) { | |||
return; | |||
} | |||
customizeInput( input ); | |||
form = input.closest( 'form' ); | |||
if ( form ) { | |||
customizeSubmitButton( form ); | |||
} | } | ||
} | } | ||
2026년 7월 25일 (토) 01:32 기준 최신판
( function () {
'use strict';
if (
mw.config.get( 'wgCanonicalSpecialPageName' ) !==
'CreatePage'
) {
return;
}
function insertSproutImage( input, fieldLayout ) {
var imageBox;
var image;
var insertionTarget;
if (
document.querySelector(
'.pvz-createpage-sprout'
)
) {
return;
}
imageBox = document.createElement( 'div' );
imageBox.className = 'pvz-createpage-sprout';
image = document.createElement( 'img' );
image.src = mw.util.getUrl(
'Special:Redirect/file/Sprout_PvZ2.png'
);
image.alt = '';
image.className = 'pvz-design-critical';
imageBox.appendChild( image );
insertionTarget =
fieldLayout ||
input.closest( '.oo-ui-fieldLayout-field' ) ||
input.parentElement;
if (
insertionTarget &&
insertionTarget.parentNode
) {
insertionTarget.parentNode.insertBefore(
imageBox,
insertionTarget
);
}
}
function customizeInput( input ) {
var inputWidget;
var fieldLayout;
input.placeholder =
'새로 재배할 문서의 제목을 입력하세요';
input.setAttribute(
'aria-label',
'새로 재배할 문서의 제목을 입력하세요'
);
input.classList.add(
'pvz-createpage-input'
);
inputWidget = input.closest(
'.oo-ui-textInputWidget'
);
if ( inputWidget ) {
inputWidget.classList.add(
'pvz-createpage-input-widget'
);
}
fieldLayout = input.closest(
'.oo-ui-fieldLayout'
);
if ( fieldLayout ) {
fieldLayout.classList.add(
'pvz-createpage-input-layout'
);
}
insertSproutImage(
input,
fieldLayout
);
}
function customizeSubmitButton( form ) {
var submitButton;
var submitWidget;
var fieldLayout;
var label;
submitButton = form.querySelector(
'input[type="submit"], ' +
'button[type="submit"], ' +
'.oo-ui-buttonInputWidget-input, ' +
'.oo-ui-buttonElement-button'
);
if ( !submitButton ) {
return;
}
submitButton.classList.add(
'pvz-createpage-submit-button'
);
submitButton.setAttribute(
'aria-label',
'제출'
);
if (
submitButton.tagName.toLowerCase() ===
'input'
) {
submitButton.value = '제출';
} else {
label = submitButton.querySelector(
'.oo-ui-labelElement-label'
);
if ( label ) {
label.textContent = '제출';
} else {
submitButton.textContent = '제출';
}
}
submitWidget = submitButton.closest(
'.oo-ui-buttonInputWidget, ' +
'.oo-ui-buttonWidget'
);
if ( submitWidget ) {
submitWidget.classList.add(
'pvz-createpage-submit-widget'
);
}
fieldLayout = submitButton.closest(
'.oo-ui-fieldLayout'
);
if ( fieldLayout ) {
fieldLayout.classList.add(
'pvz-createpage-submit-layout'
);
}
}
function initializeCreatePageUw() {
var input;
var form;
input = document.getElementById(
'mw-input-wptitle'
);
if ( !input ) {
return;
}
customizeInput( input );
form = input.closest( 'form' );
if ( form ) {
customizeSubmitButton( form );
}
}
if ( document.readyState === 'loading' ) {
document.addEventListener(
'DOMContentLoaded',
initializeCreatePageUw,
{ once: true }
);
} else {
initializeCreatePageUw();
}
}() );