미디어위키:Gadget-CreatePageUw.js: 두 판 사이의 차이
식물 vs 좀비 위키
편집 요약 없음 |
편집 요약 없음 |
||
| 7번째 줄: | 7번째 줄: | ||
) { | ) { | ||
return; | return; | ||
} | |||
function setSubmitButtonLabel( button ) { | |||
var label; | |||
var widget; | |||
if ( !button ) { | |||
return; | |||
} | |||
button.classList.add( | |||
'pvz-createpage-submit-button' | |||
); | |||
button.removeAttribute( 'style' ); | |||
button.setAttribute( 'aria-label', '만들기' ); | |||
if ( | |||
button.tagName.toLowerCase() === | |||
'input' | |||
) { | |||
button.value = '만들기'; | |||
} else { | |||
label = button.querySelector( | |||
'.oo-ui-labelElement-label' | |||
); | |||
if ( label ) { | |||
label.textContent = '만들기'; | |||
} else { | |||
button.textContent = '만들기'; | |||
} | |||
} | |||
widget = button.closest( | |||
'.oo-ui-buttonInputWidget, ' + | |||
'.oo-ui-buttonWidget' | |||
); | |||
if ( widget ) { | |||
widget.classList.add( | |||
'pvz-createpage-submit-widget' | |||
); | |||
widget.classList.remove( | |||
'oo-ui-flaggedElement-progressive' | |||
); | |||
widget.removeAttribute( 'style' ); | |||
} | |||
} | } | ||
function initializeCreatePageUw() { | function initializeCreatePageUw() { | ||
var input = document.getElementById( | var input; | ||
var inputWidget; | |||
var fieldLayout; | |||
var insertionTarget; | |||
var imageBox; | |||
var image; | |||
var form; | |||
var submitButton; | |||
input = document.getElementById( | |||
'mw-input-wptitle' | 'mw-input-wptitle' | ||
); | ); | ||
| 24번째 줄: | 83번째 줄: | ||
'aria-label', | 'aria-label', | ||
'새로 재배할 문서의 제목을 입력하세요' | '새로 재배할 문서의 제목을 입력하세요' | ||
); | |||
input.classList.add( | |||
'pvz-createpage-input' | |||
); | |||
input.removeAttribute( 'style' ); | |||
inputWidget = input.closest( | |||
'.oo-ui-textInputWidget' | |||
); | |||
if ( inputWidget ) { | |||
inputWidget.classList.add( | |||
'pvz-createpage-input-widget' | |||
); | |||
inputWidget.removeAttribute( 'style' ); | |||
} | |||
fieldLayout = input.closest( | |||
'.oo-ui-fieldLayout' | |||
); | ); | ||
if ( | if ( | ||
document.querySelector( | !document.querySelector( | ||
'.pvz-createpage-sprout' | '.pvz-createpage-sprout' | ||
) | ) | ||
) { | ) { | ||
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 || | |||
inputWidget || | |||
input.parentElement; | |||
if ( | |||
insertionTarget && | |||
insertionTarget.parentNode | |||
) { | |||
insertionTarget.parentNode | |||
.insertBefore( | |||
imageBox, | |||
insertionTarget | |||
); | |||
} | |||
} | |||
form = input.closest( 'form' ); | |||
if ( | if ( !form ) { | ||
return; | |||
} | } | ||
submitButton = form.querySelector( | |||
'button[type="submit"], ' + | |||
'input[type="submit"], ' + | |||
'.oo-ui-buttonInputWidget button, ' + | |||
'.oo-ui-buttonInputWidget input' | |||
); | |||
setSubmitButtonLabel( submitButton ); | |||
} | } | ||
