X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftable%2Fdialogs%2Ftable.js;h=d4bfb8937430e05b5ec5159340657c68528cf78d;hb=refs%2Ftags%2Fv3.6.3;hp=2fd2ff050dee1389257716d78d47da88f61df95b;hpb=e73319a12b56100b29ef456fd74114fe5519e01c;p=ckeditor.git diff --git a/_source/plugins/table/dialogs/table.js b/_source/plugins/table/dialogs/table.js index 2fd2ff0..d4bfb89 100644 --- a/_source/plugins/table/dialogs/table.js +++ b/_source/plugins/table/dialogs/table.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -33,6 +33,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return maxCols; } + + // Whole-positive-integer validator. + function validatorNum( msg ) + { + return function() + { + var value = this.getValue(), + pass = !!( CKEDITOR.dialog.validate.integer()( value ) && value > 0 ); + + if ( !pass ) + { + alert( msg ); + this.select(); + } + + return pass; + }; + } + function tableDialog( editor, command ) { var makeElement = function( name ) @@ -281,19 +300,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license label : editor.lang.table.rows, required : true, controlStyle : 'width:5em', - validate : function() - { - var pass = true, - value = this.getValue(); - pass = pass && CKEDITOR.dialog.validate.integer()( value ) - && value > 0; - if ( !pass ) - { - alert( editor.lang.table.invalidRows ); - this.select(); - } - return pass; - }, + validate : validatorNum( editor.lang.table.invalidRows ), setup : function( selectedElement ) { this.setValue( selectedElement.$.rows.length ); @@ -307,19 +314,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license label : editor.lang.table.columns, required : true, controlStyle : 'width:5em', - validate : function() - { - var pass = true, - value = this.getValue(); - pass = pass && CKEDITOR.dialog.validate.integer()( value ) - && value > 0; - if ( !pass ) - { - alert( editor.lang.table.invalidCols ); - this.select(); - } - return pass; - }, + validate : validatorNum( editor.lang.table.invalidCols ), setup : function( selectedTable ) { this.setValue( tableColumns( selectedTable ) ); @@ -468,7 +463,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license setup : function( selectedTable ) { - var val = selectedTable.getStyle( 'width' ); + var val = selectedTable.getStyle( 'height' ); val && this.setValue( val ); }, commit : commitValue