JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / table / dialogs / table.js
index 2fd2ff0..d4bfb89 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -33,6 +33,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                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
@@ -281,19 +300,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                        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
@@ -307,19 +314,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                        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
@@ -468,7 +463,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \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