미디어위키:Gadget-CreatePageUw.js: 두 판 사이의 차이
식물 vs 좀비 위키
새 문서: ( function () { 'use strict'; if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CreatePage' ) { return; } function initializeCreatePageUw() { var input = document.getElementById( 'mw-input-wptitle' ); if ( !input ) { return; } document.body.classList.add( 'pvz-createpage-page' ); input.placeholder = '새로 재배할 문서의 제목을 입력하세요'; input.setAttribute( 'aria-label', '새로 재배할 문서의 제목을 입력하세요'... |
편집 요약 없음 |
||
| (같은 사용자의 중간 판 5개는 보이지 않습니다) | |||
| 2번째 줄: | 2번째 줄: | ||
'use strict'; | 'use strict'; | ||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CreatePage' ) { | if ( | ||
mw.config.get( 'wgCanonicalSpecialPageName' ) !== | |||
'CreatePage' | |||
) { | |||
return; | return; | ||
} | } | ||
function | function insertSproutImage( input, fieldLayout ) { | ||
var | var imageBox; | ||
var image; | |||
var insertionTarget; | |||
if ( | if ( | ||
document.querySelector( | |||
'.pvz-createpage-sprout' | |||
) | |||
) { | |||
return; | return; | ||
} | } | ||
document. | 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( | input.setAttribute( | ||
'aria-label', | 'aria-label', | ||
| 21번째 줄: | 62번째 줄: | ||
); | ); | ||
input.classList.add( | |||
'pvz-createpage-input' | |||
); | |||
if ( | inputWidget = input.closest( | ||
'.oo-ui-textInputWidget' | |||
' | ); | ||
if ( inputWidget ) { | |||
inputWidget.classList.add( | |||
'pvz-createpage-input-widget' | |||
); | ); | ||
} | } | ||
fieldLayout = input.closest( | |||
' | '.oo-ui-fieldLayout' | ||
); | ); | ||
if ( | if ( fieldLayout ) { | ||
fieldLayout.classList.add( | |||
'pvz-createpage- | '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 ( | 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' | |||
); | |||
} | } | ||
} | |||
var | function initializeCreatePageUw() { | ||
var input; | |||
var form; | |||
input = document.getElementById( | |||
'mw-input-wptitle' | |||
' | |||
); | ); | ||
if ( !input ) { | |||
return; | |||
} | |||
customizeInput( input ); | |||
form = input.closest( 'form' ); | |||
if ( | if ( form ) { | ||
customizeSubmitButton( form ); | |||
} | } | ||
} | } | ||
