미디어위키:Gadget-CreatePageUw.js: 두 판 사이의 차이

식물 vs 좀비 위키
잔글 Brokey님이 미디어위키:CreatePageUw.js 문서를 넘겨주기를 만들지 않고 미디어위키:Gadget-CreatePageUw.js 문서로 이동했습니다
편집 요약 없음
 
(같은 사용자의 중간 판 4개는 보이지 않습니다)
2번째 줄: 2번째 줄:
'use strict';
'use strict';


if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CreatePage' ) {
if (
mw.config.get( 'wgCanonicalSpecialPageName' ) !==
'CreatePage'
) {
return;
return;
}
}


function initializeCreatePageUw() {
function insertSproutImage( input, fieldLayout ) {
var input = document.getElementById( 'mw-input-wptitle' );
var imageBox;
var image;
var insertionTarget;


if ( !input ) {
if (
document.querySelector(
'.pvz-createpage-sprout'
)
) {
return;
return;
}
}


document.body.classList.add( 'pvz-createpage-page' );
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.placeholder = '새로 재배할 문서의 제목을 입력하세요';
input.setAttribute(
input.setAttribute(
'aria-label',
'aria-label',
21번째 줄: 62번째 줄:
);
);


/* 입력창 위의 설명 문구 숨기기 */
input.classList.add(
var fieldLayout = input.closest( '.oo-ui-fieldLayout' );
'pvz-createpage-input'
);


if ( fieldLayout ) {
inputWidget = input.closest(
var fieldHeader = fieldLayout.querySelector(
'.oo-ui-textInputWidget'
'.oo-ui-fieldLayout-header'
);
 
if ( inputWidget ) {
inputWidget.classList.add(
'pvz-createpage-input-widget'
);
);
if ( fieldHeader ) {
fieldHeader.classList.add(
'pvz-createpage-hidden'
);
}
}
}


var inputLabel = document.querySelector(
fieldLayout = input.closest(
'label[for="mw-input-wptitle"]'
'.oo-ui-fieldLayout'
);
);


if ( inputLabel ) {
if ( fieldLayout ) {
inputLabel.classList.add(
fieldLayout.classList.add(
'pvz-createpage-hidden'
'pvz-createpage-input-layout'
);
);
}
}


/* 양식 내부의 '문서 만들기' 제목 숨기기 */
insertSproutImage(
var fieldset = input.closest( 'fieldset' );
input,
fieldLayout
);
}
 
function customizeSubmitButton( form ) {
var submitButton;
var submitWidget;
var fieldLayout;
var label;


if ( fieldset ) {
submitButton = form.querySelector(
var legend = fieldset.querySelector( 'legend' );
'input[type="submit"], ' +
'button[type="submit"], ' +
'.oo-ui-buttonInputWidget-input, ' +
'.oo-ui-buttonElement-button'
);


if ( legend ) {
if ( !submitButton ) {
legend.classList.add(
return;
'pvz-createpage-hidden'
);
}
}
}


/* Sprout 이미지 중복 생성 방지 */
submitButton.classList.add(
'pvz-createpage-submit-button'
);
 
submitButton.setAttribute(
'aria-label',
'제출'
);
 
if (
if (
document.querySelector(
submitButton.tagName.toLowerCase() ===
'.pvz-createpage-sprout'
'input'
)
) {
) {
return;
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'
);
}
}
}


var imageBox = document.createElement( 'div' );
function initializeCreatePageUw() {
imageBox.className = 'pvz-createpage-sprout';
var input;
var form;


var image = document.createElement( 'img' );
input = document.getElementById(
image.src = mw.util.getUrl(
'mw-input-wptitle'
'Special:Redirect/file/Sprout_PvZ2.png'
);
);
image.alt = '';


imageBox.appendChild( image );
if ( !input ) {
return;
}
 
customizeInput( input );


var insertionTarget =
form = input.closest( 'form' );
fieldLayout || input.parentElement;


if (
if ( form ) {
insertionTarget &&
customizeSubmitButton( form );
insertionTarget.parentNode
) {
insertionTarget.parentNode.insertBefore(
imageBox,
insertionTarget
);
}
}
}
}