Ticket #6462: 6462_2.patch

File 6462_2.patch, 9.9 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/iframe/dialogs/iframe.js

     
    123123                                                                        style : 'width:100%',
    124124                                                                        labelLayout : 'vertical',
    125125                                                                        label : commonLang.width,
    126                                                                         validate : CKEDITOR.dialog.validate.integer( commonLang.invalidWidth ),
     126                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    127127                                                                        setup : function( iframeNode, fakeImage )
    128128                                                                        {
    129129                                                                                loadValue.apply( this, arguments );
    130130                                                                                if ( fakeImage )
    131                                                                                 {
    132                                                                                         var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
    133                                                                                         if ( !isNaN( fakeImageWidth ) )
    134                                                                                                 this.setValue( fakeImageWidth );
    135                                                                                 }
     131                                                                                        this.setValue( fakeImage.$.style.width );
    136132                                                                        },
    137133                                                                        commit : function( iframeNode, extraStyles )
    138134                                                                        {
    139135                                                                                commitValue.apply( this, arguments );
    140                                                                                 if ( this.getValue() )
    141                                                                                         extraStyles.width = this.getValue() + 'px';
     136                                                                                var val = this.getValue();
     137                                                                                val && ( extraStyles.width = val );
    142138                                                                        }
    143139                                                                },
    144140                                                                {
     
    147143                                                                        style : 'width:100%',
    148144                                                                        labelLayout : 'vertical',
    149145                                                                        label : commonLang.height,
    150                                                                         validate : CKEDITOR.dialog.validate.integer( commonLang.invalidHeight ),
     146                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    151147                                                                        setup : function( iframeNode, fakeImage )
    152148                                                                        {
    153149                                                                                loadValue.apply( this, arguments );
    154150                                                                                if ( fakeImage )
    155                                                                                 {
    156                                                                                         var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
    157                                                                                         if ( !isNaN( fakeImageHeight ) )
    158                                                                                                 this.setValue( fakeImageHeight );
    159                                                                                 }
     151                                                                                        this.setValue( fakeImage.$.style.height );
    160152                                                                        },
    161153                                                                        commit : function( iframeNode, extraStyles )
    162154                                                                        {
    163155                                                                                commitValue.apply( this, arguments );
    164                                                                                 if ( this.getValue() )
    165                                                                                         extraStyles.height = this.getValue() + 'px';
     156                                                                                var val = this.getValue();
     157                                                                                val && ( extraStyles.height = val );
    166158                                                                        }
    167159                                                                },
    168160                                                                {
  • _source/plugins/table/dialogs/table.js

     
    548548                                                                                        style : 'width:3em',
    549549                                                                                        label : editor.lang.table.cellSpace,
    550550                                                                                        'default' : 1,
    551                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellSpacing ),
     551                                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    552552                                                                                        setup : function( selectedTable )
    553553                                                                                        {
    554554                                                                                                this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );
     
    567567                                                                                        style : 'width:3em',
    568568                                                                                        label : editor.lang.table.cellPad,
    569569                                                                                        'default' : 1,
    570                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellPadding ),
     570                                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    571571                                                                                        setup : function( selectedTable )
    572572                                                                                        {
    573573                                                                                                this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );
  • _source/plugins/dialog/plugin.js

     
    28742874        {
    28752875                var notEmptyRegex = /^([a]|[^a])+$/,
    28762876                        integerRegex = /^\d*$/,
    2877                         numberRegex = /^\d*(?:\.\d+)?$/;
     2877                        numberRegex = /^\d*(?:\.\d+)?$/,
     2878                        cssLengthRegex = /(^[+-]?\d+(px|em|ex|in|cm|mm|pt|pc|\%)?$)|^$/i;
    28782879
    28792880                CKEDITOR.VALIDATE_OR = 1;
    28802881                CKEDITOR.VALIDATE_AND = 2;
     
    28832884                {
    28842885                        functions : function()
    28852886                        {
     2887                                var args = arguments;
    28862888                                return function()
    28872889                                {
    28882890                                        /**
     
    28912893                                         * combine validate functions together to make more sophisticated
    28922894                                         * validators.
    28932895                                         */
    2894                                         var value = this && this.getValue ? this.getValue() : arguments[0];
     2896                                        var value = this && this.getValue ? this.getValue() : args[ 0 ];
    28952897
    28962898                                        var msg = undefined,
    28972899                                                relation = CKEDITOR.VALIDATE_AND,
    28982900                                                functions = [], i;
    28992901
    2900                                         for ( i = 0 ; i < arguments.length ; i++ )
     2902                                        for ( i = 0 ; i < args.length ; i++ )
    29012903                                        {
    2902                                                 if ( typeof( arguments[i] ) == 'function' )
    2903                                                         functions.push( arguments[i] );
     2904                                                if ( typeof( args[i] ) == 'function' )
     2905                                                        functions.push( args[i] );
    29042906                                                else
    29052907                                                        break;
    29062908                                        }
    29072909
    2908                                         if ( i < arguments.length && typeof( arguments[i] ) == 'string' )
     2910                                        if ( i < args.length && typeof( args[i] ) == 'string' )
    29092911                                        {
    2910                                                 msg = arguments[i];
     2912                                                msg = args[i];
    29112913                                                i++;
    29122914                                        }
    29132915
    2914                                         if ( i < arguments.length && typeof( arguments[i]) == 'number' )
    2915                                                 relation = arguments[i];
     2916                                        if ( i < args.length && typeof( args[i]) == 'number' )
     2917                                                relation = args[i];
    29162918
    29172919                                        var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false );
    29182920                                        for ( i = 0 ; i < functions.length ; i++ )
     
    29272929                                        {
    29282930                                                if ( msg !== undefined )
    29292931                                                        alert( msg );
    2930                                                 if ( this && ( this.select || this.focus ) )
    2931                                                         ( this.select || this.focus )();
     2932                                                if ( this.select || this.focus  )
     2933                                                {
     2934                                                        if ( this.select )
     2935                                                                this.select();
     2936                                                        else
     2937                                                                this.focus();
     2938                                                }
     2939
    29322940                                                return false;
    29332941                                        }
    29342942
     
    29772985                                return this.regex( numberRegex, msg );
    29782986                        },
    29792987
     2988                        'cssLength' : function( msg )
     2989                        {
     2990                                return this.functions( function( val ){ return cssLengthRegex.test( CKEDITOR.tools.trim( val ) ); }, msg );
     2991                        },
     2992
    29802993                        equals : function( value, msg )
    29812994                        {
    29822995                                return this.functions( function( val ){ return val == value; }, msg );
  • _source/lang/en.js

     
    121121                alignBottom             : 'Bottom',
    122122                invalidHeight   : 'Height must be a number.',
    123123                invalidWidth    : 'Width must be a number.',
     124                invalidCssLength        : 'Value must be in CSS length unit.',
    124125
    125126                // Put the voice-only part of the label in the span.
    126127                unavailable             : '%1<span class="cke_accessibility">, unavailable</span>'
     
    271272                invalidBorder   : 'Border size must be a number.',
    272273                invalidWidth    : 'Table width must be a number.',
    273274                invalidHeight   : 'Table height must be a number.',
    274                 invalidCellSpacing      : 'Cell spacing must be a number.',
    275                 invalidCellPadding      : 'Cell padding must be a number.',
    276275
    277276                cell :
    278277                {
  • _source/plugins/flash/dialogs/flash.js

     
    367367                                                                        id : 'width',
    368368                                                                        style : 'width:95px',
    369369                                                                        label : editor.lang.common.width,
    370                                                                         validate : CKEDITOR.dialog.validate.integer( editor.lang.common.invalidWidth ),
     370                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    371371                                                                        setup : function( objectNode, embedNode, paramMap, fakeImage )
    372372                                                                        {
    373373                                                                                loadValue.apply( this, arguments );
    374374                                                                                if ( fakeImage )
    375                                                                                 {
    376                                                                                         var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
    377                                                                                         if ( !isNaN( fakeImageWidth ) )
    378                                                                                                 this.setValue( fakeImageWidth );
    379                                                                                 }
     375                                                                                        this.setValue( fakeImage.$.style.width );
    380376                                                                        },
    381377                                                                        commit : function( objectNode, embedNode, paramMap, extraStyles )
    382378                                                                        {
    383379                                                                                commitValue.apply( this, arguments );
    384                                                                                 if ( this.getValue() )
    385                                                                                         extraStyles.width = this.getValue() + 'px';
     380                                                                                var val = this.getValue();
     381                                                                                val && ( extraStyles.width = val );
    386382                                                                        }
    387383                                                                },
    388384                                                                {
     
    390386                                                                        id : 'height',
    391387                                                                        style : 'width:95px',
    392388                                                                        label : editor.lang.common.height,
    393                                                                         validate : CKEDITOR.dialog.validate.integer( editor.lang.common.invalidHeight ),
     389                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
    394390                                                                        setup : function( objectNode, embedNode, paramMap, fakeImage )
    395391                                                                        {
    396392                                                                                loadValue.apply( this, arguments );
    397393                                                                                if ( fakeImage )
    398                                                                                 {
    399                                                                                         var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
    400                                                                                         if ( !isNaN( fakeImageHeight ) )
    401                                                                                                 this.setValue( fakeImageHeight );
    402                                                                                 }
     394                                                                                        this.setValue( fakeImage.$.style.height );
    403395                                                                        },
    404396                                                                        commit : function( objectNode, embedNode, paramMap, extraStyles )
    405397                                                                        {
    406398                                                                                commitValue.apply( this, arguments );
    407                                                                                 if ( this.getValue() )
    408                                                                                         extraStyles.height = this.getValue() + 'px';
     399                                                                                var val = this.getValue();
     400                                                                                val && ( extraStyles.height = val );
    409401                                                                        }
    410402                                                                },
    411403                                                                {
  • _source/plugins/fakeobjects/plugin.js

     
    2525                                        if ( style )
    2626                                        {
    2727                                                // Get the width from the style.
    28                                                 var match = /(?:^|\s)width\s*:\s*(\d+)/i.exec( style ),
     28                                                var match = /(?:^|\s)width\s*:\s*(.*?)(:?;|$)/i.exec( style ),
    2929                                                        width = match && match[1];
    3030
    3131                                                // Get the height from the style.
    32                                                 match = /(?:^|\s)height\s*:\s*(\d+)/i.exec( style );
     32                                                match = /(?:^|\s)height\s*:\s*(.*?)(:?;|$)/i.exec( style );
    3333                                                var height = match && match[1];
    3434
    3535                                                if ( width )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy