mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/InputBox
synced 2024-11-28 00:50:02 +00:00
93351fb7d9
Remove the JavaScript module and its logic to toggle the disabled state on the submit button. Instead, let the browser handle this natively by setting the `required` attribute, which naturally prevents early submissions. Retain the current styling for 99% of cases by using the :required:invalid selector to target the submit button to make it appear disabled. This slight duplication of styles is needed because, despite the form effectively being disabled natively, the core mediawiki-ui styles only account for :disabled on the button directly and not e.g. inherited via form:invalid. It is also unclear whether we would want that, since there is some value to be had from having the form give a consistent look with a progressive button that can be submitted even at the wrong time to yield an assistive message to the required field, so hence handling this locally for now instead of with a generalised approach. In order to use the required true/false idiom, I have switched the generating of the HTML string from the old Xml::element method to Html::element. This means there is no need to store it in an array first and conditionally set it since true/false will result in absence or required="" as needed. As side-effect from this, redundant attributes like value="" and type="text" are ommitted from the output, just as MediaWiki core does more generally. Bug: T283303 Change-Id: I2c75e09dd3f89fa11fca311b4e1f8133946b01b1
258 lines
14 KiB
Plaintext
258 lines
14 KiB
Plaintext
!! Version 2
|
|
# Force the test runner to ensure the extension is loaded
|
|
!! hooks
|
|
inputbox
|
|
!! endhooks
|
|
|
|
!! test
|
|
InputBox type=search
|
|
!! wikitext
|
|
<inputbox>
|
|
type=search
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="searchbox" class="searchbox" action="/wiki/Special:Search"><input class="mw-inputbox-input mw-searchInput searchboxInput mw-ui-input mw-ui-input-inline" name="search" placeholder="" size="50" dir="ltr" /><br /><input type="submit" name="go" class="mw-ui-button" value="Try exact match" /> <input type="submit" name="fulltext" class="mw-ui-button" value="Search full text" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with minor
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
minor=1
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="1" name="minor" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with minor=0
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
minor=0
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="0" name="minor" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with preloadparams
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
preloadparams[]=param1
|
|
preloadparams[]=param2
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="param1" name="preloadparams[]" /><input type="hidden" value="param2" name="preloadparams[]" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty preloadparams
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
preloadparams[]=
|
|
preloadparams[]=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" name="preloadparams[]" /><input type="hidden" name="preloadparams[]" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with editintro
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
editintro=MediaWiki:Test
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="MediaWiki:Test" name="editintro" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty editintro
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
editintro=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" name="editintro" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with summary
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
summary=Summary test
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="Summary test" name="summary" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty summary
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
summary=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" name="summary" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with nosummary
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
nosummary=true
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="true" name="nosummary" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty nosummary
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
nosummary=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" name="nosummary" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with prefix
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
prefix=Test/
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="Test/" name="prefix" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty prefix
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
prefix=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with preload
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
preload=test
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="test" name="preload" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=create with empty preload
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
preload=
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" name="preload" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Create page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=comment
|
|
!! wikitext
|
|
<inputbox>
|
|
type=comment
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input type="hidden" value="new" name="section" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" placeholder="" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="New section" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=commenttitle
|
|
!! wikitext
|
|
<inputbox>
|
|
type=commenttitle
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="commentbox" class="commentbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input name="preloadtitle" class="mw-inputbox-input commentboxInput mw-ui-input mw-ui-input-inline" placeholder="" size="50" dir="ltr" /><input type="hidden" value="new" name="section" /><input type="hidden" name="title" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="New section" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=fulltext
|
|
!! wikitext
|
|
<inputbox>
|
|
type=fulltext
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="searchbox" class="searchbox" action="/wiki/Special:Search"><input class="mw-inputbox-input mw-searchInput searchboxInput mw-ui-input mw-ui-input-inline" name="search" placeholder="" size="50" dir="ltr" /><br /><input type="submit" name="fulltext" class="mw-ui-button" value="Search full text" /><input type="hidden" value="Search" name="fulltext" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=move
|
|
!! wikitext
|
|
<inputbox>
|
|
type=move
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="movebox" class="mw-movebox" action="/index.php" method="get"><input type="hidden" value="Special:MovePage/" name="title" /><input type="hidden" name="wpReason" /><input type="hidden" name="prefix" /><input name="wpNewTitle" class="mw-inputbox-input mw-moveboxInput mw-ui-input mw-ui-input-inline" placeholder="" size="50" dir="ltr" /><br /><input type="submit" class="mw-ui-button mw-ui-progressive" value="Move page" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=search with tour
|
|
!! wikitext
|
|
<inputbox>
|
|
type=search
|
|
tour=test
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="searchbox" class="searchbox" action="/wiki/Special:Search"><input class="mw-inputbox-input mw-searchInput searchboxInput mw-ui-input mw-ui-input-inline" name="search" placeholder="" size="50" dir="ltr" /><input type="hidden" value="test" name="tour" /><br /><input type="submit" name="go" class="mw-ui-button" value="Try exact match" /> <input type="submit" name="fulltext" class="mw-ui-button" value="Search full text" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox langconvert
|
|
!! options
|
|
language=sr variant=sr-el
|
|
!! wikitext
|
|
<inputbox>
|
|
type=create
|
|
default=-{sr-el: Some latin; sr-ec: Not latin }-
|
|
placeholder=-{sr-el: el; sr-ec: ec}-
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="createbox" class="createbox" action="/index.php" method="get"><input type="hidden" value="edit" name="action" /><input name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline mw-inputbox-createbox" value="Some latin" placeholder="el" required="" size="50" dir="ltr" /><br /><input type="submit" name="create" class="mw-ui-button mw-ui-progressive" value="Направи страницу" /></form></div>
|
|
!! end
|
|
|
|
!! test
|
|
InputBox type=search with aria label
|
|
!! wikitext
|
|
<inputbox>
|
|
type=search
|
|
arialabel=Search this wiki
|
|
</inputbox>
|
|
!! html+tidy
|
|
<div class="mw-inputbox-centered" style=""><form name="searchbox" class="searchbox" action="/wiki/Special:Search"><input class="mw-inputbox-input mw-searchInput searchboxInput mw-ui-input mw-ui-input-inline" name="search" placeholder="" size="50" dir="ltr" aria-label="Search this wiki" /><br /><input type="submit" name="go" class="mw-ui-button" value="Try exact match" /> <input type="submit" name="fulltext" class="mw-ui-button" value="Search full text" /></form></div>
|
|
!! end
|