(bug 38663) [Regression] WikiEditor "Table" dialog broken

* Fixed by casting to a String before doing the round-trip check

* While at it, improve user interface to make it harder to make mistakes
  and easier to do it "right". By making it an HTML5 "number" input specifically,
  and building in min/max settings into the UI.
  Old browsers fallback to a plain text input (like it was before).

  Most browsers implement this number input by allowing the use of the scroll wheel
  and the up/down arrows to adjust the numbers, and not allowing non-numbers or numbers
  outside the allowed range.

* Follows-up 7721909f9f

Change-Id: If32da14f80c6a0e4be3e1fe7fd0b650be4ed8a09
This commit is contained in:
Timo Tijhof 2012-07-26 11:30:27 -07:00
parent b88a866ebe
commit e7a0484eb5

View file

@ -729,12 +729,12 @@ $.wikiEditor.modules.dialogs.config = {
<div class="wikieditor-toolbar-field-wrapper">\
<label for="wikieditor-toolbar-table-dimensions-rows"\
rel="wikieditor-toolbar-tool-table-dimensions-rows"></label><br/>\
<input type="text" id="wikieditor-toolbar-table-dimensions-rows" size="4"/>\
<input type="number" min="1" max="1000" id="wikieditor-toolbar-table-dimensions-rows" size="4"/>\
</div>\
<div class="wikieditor-toolbar-field-wrapper">\
<label for="wikieditor-toolbar-table-dimensions-columns"\
rel="wikieditor-toolbar-tool-table-dimensions-columns"></label><br/>\
<input type="text" id="wikieditor-toolbar-table-dimensions-columns" size="4"/>\
<input type="number" min="1" max="1000" id="wikieditor-toolbar-table-dimensions-columns" size="4"/>\
</div>\
</div>\
</div></fieldset>\
@ -832,8 +832,8 @@ $.wikiEditor.modules.dialogs.config = {
var colsVal = $( '#wikieditor-toolbar-table-dimensions-columns' ).val();
var rows = parseInt( rowsVal, 10 );
var cols = parseInt( colsVal, 10 );
var header = $( '#wikieditor-toolbar-table-dimensions-header' ).is( ':checked' ) ? 1 : 0;
if ( isNaN( rows ) || isNaN( cols ) || rows !== rowsVal || cols !== colsVal ) {
var header = $( '#wikieditor-toolbar-table-dimensions-header' ).prop( 'checked' ) ? 1 : 0;
if ( isNaN( rows ) || isNaN( cols ) || String( rows ) !== rowsVal || String( cols ) !== colsVal || rowsVal < 0 || colsVal < 0 ) {
alert( mw.msg( 'wikieditor-toolbar-tool-table-invalidnumber' ) );
return;
}
@ -841,7 +841,7 @@ $.wikiEditor.modules.dialogs.config = {
alert( mw.msg( 'wikieditor-toolbar-tool-table-zero' ) );
return;
}
if ( rows * cols > 1000 ) {
if ( ( rows * cols ) > 1000 ) {
alert( mw.msg( 'wikieditor-toolbar-tool-table-toomany', 1000 ) );
return;
}