/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
return maxCols;\r
}\r
\r
+\r
+ // Whole-positive-integer validator.\r
+ function validatorNum( msg )\r
+ {\r
+ return function()\r
+ {\r
+ var value = this.getValue(),\r
+ pass = !!( CKEDITOR.dialog.validate.integer()( value ) && value > 0 );\r
+\r
+ if ( !pass )\r
+ {\r
+ alert( msg );\r
+ this.select();\r
+ }\r
+\r
+ return pass;\r
+ };\r
+ }\r
+\r
function tableDialog( editor, command )\r
{\r
var makeElement = function( name )\r
label : editor.lang.table.rows,\r
required : true,\r
controlStyle : 'width:5em',\r
- validate : function()\r
- {\r
- var pass = true,\r
- value = this.getValue();\r
- pass = pass && CKEDITOR.dialog.validate.integer()( value )\r
- && value > 0;\r
- if ( !pass )\r
- {\r
- alert( editor.lang.table.invalidRows );\r
- this.select();\r
- }\r
- return pass;\r
- },\r
+ validate : validatorNum( editor.lang.table.invalidRows ),\r
setup : function( selectedElement )\r
{\r
this.setValue( selectedElement.$.rows.length );\r
label : editor.lang.table.columns,\r
required : true,\r
controlStyle : 'width:5em',\r
- validate : function()\r
- {\r
- var pass = true,\r
- value = this.getValue();\r
- pass = pass && CKEDITOR.dialog.validate.integer()( value )\r
- && value > 0;\r
- if ( !pass )\r
- {\r
- alert( editor.lang.table.invalidCols );\r
- this.select();\r
- }\r
- return pass;\r
- },\r
+ validate : validatorNum( editor.lang.table.invalidCols ),\r
setup : function( selectedTable )\r
{\r
this.setValue( tableColumns( selectedTable ) );\r
\r
setup : function( selectedTable )\r
{\r
- var val = selectedTable.getStyle( 'width' );\r
+ var val = selectedTable.getStyle( 'height' );\r
val && this.setValue( val );\r
},\r
commit : commitValue\r