Ticket #6462: 6462.patch

File 6462.patch, 9.3 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/flash/dialogs/flash.js

     
    366366                                                                        id : 'width',
    367367                                                                        style : 'width:95px',
    368368                                                                        label : editor.lang.flash.width,
    369                                                                         validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateWidth ),
     369                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.flash.validateWidth ),
     370                                                                        setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; },
     371                                                                        getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); },
    370372                                                                        setup : function( objectNode, embedNode, paramMap, fakeImage )
    371373                                                                        {
    372374                                                                                loadValue.apply( this, arguments );
    373375                                                                                if ( fakeImage )
    374                                                                                 {
    375                                                                                         var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
    376                                                                                         if ( !isNaN( fakeImageWidth ) )
    377                                                                                                 this.setValue( fakeImageWidth );
    378                                                                                 }
     376                                                                                        this.setValue( fakeImage.$.style.width );
    379377                                                                        },
    380378                                                                        commit : function( objectNode, embedNode, paramMap, extraStyles )
    381379                                                                        {
    382380                                                                                commitValue.apply( this, arguments );
    383                                                                                 if ( this.getValue() )
    384                                                                                         extraStyles.width = this.getValue() + 'px';
     381                                                                                var val = this.getValue();
     382                                                                                val && ( extraStyles.width = val );
    385383                                                                        }
    386384                                                                },
    387385                                                                {
     
    389387                                                                        id : 'height',
    390388                                                                        style : 'width:95px',
    391389                                                                        label : editor.lang.flash.height,
    392                                                                         validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateHeight ),
     390                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.flash.validateHeight ),
     391                                                                        setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; },
     392                                                                        getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); },
    393393                                                                        setup : function( objectNode, embedNode, paramMap, fakeImage )
    394394                                                                        {
    395395                                                                                loadValue.apply( this, arguments );
    396396                                                                                if ( fakeImage )
    397                                                                                 {
    398                                                                                         var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
    399                                                                                         if ( !isNaN( fakeImageHeight ) )
    400                                                                                                 this.setValue( fakeImageHeight );
    401                                                                                 }
     397                                                                                        this.setValue( fakeImage.$.style.height );
    402398                                                                        },
    403399                                                                        commit : function( objectNode, embedNode, paramMap, extraStyles )
    404400                                                                        {
    405401                                                                                commitValue.apply( this, arguments );
    406                                                                                 if ( this.getValue() )
    407                                                                                         extraStyles.height = this.getValue() + 'px';
     402                                                                                var val = this.getValue();
     403                                                                                val && ( extraStyles.height = val );
    408404                                                                        }
    409405                                                                },
    410406                                                                {
  • _source/plugins/dialog/plugin.js

     
    21582158                                if ( typeof( elementDefinition.isChanged ) == 'function' )
    21592159                                        this.isChanged = elementDefinition.isChanged;
    21602160
     2161                                // Overload 'get(set)Value' on definition.
     2162                                if ( typeof( elementDefinition.setValue ) == 'function' )
     2163                                {
     2164                                        this.setValue = CKEDITOR.tools.override( this.setValue, function( org )
     2165                                        {
     2166                                                return function( val ){ org.call( this, elementDefinition.setValue.call( this, val ) ); };
     2167                                        } );
     2168                                }
     2169                               
     2170                                if ( typeof( elementDefinition.getValue ) == 'function' )
     2171                                {
     2172                                        this.getValue = CKEDITOR.tools.override( this.getValue, function( org )
     2173                                        {
     2174                                                return function(){ return  elementDefinition.getValue.call( this, org.call( this ) ); };
     2175                                        } );
     2176                                }
     2177
    21612178                                // Add events.
    21622179                                CKEDITOR.event.implementOn( this );
    21632180
     
    27412758        {
    27422759                var notEmptyRegex = /^([a]|[^a])+$/,
    27432760                        integerRegex = /^\d*$/,
    2744                         numberRegex = /^\d*(?:\.\d+)?$/;
     2761                        numberRegex = /^\d*(?:\.\d+)?$/,
     2762                        cssLengthRegex = /(^[+-]?\d+(px|em|ex|in|cm|mm|pt|pc|\%)?$)|^$/i;
    27452763
    27462764                CKEDITOR.VALIDATE_OR = 1;
    27472765                CKEDITOR.VALIDATE_AND = 2;
     
    27502768                {
    27512769                        functions : function()
    27522770                        {
     2771                                var args = arguments;
    27532772                                return function()
    27542773                                {
    27552774                                        /**
     
    27582777                                         * combine validate functions together to make more sophisticated
    27592778                                         * validators.
    27602779                                         */
    2761                                         var value = this && this.getValue ? this.getValue() : arguments[0];
     2780                                        var value = this && this.getValue ? this.getValue() : args[0];
    27622781
    27632782                                        var msg = undefined,
    27642783                                                relation = CKEDITOR.VALIDATE_AND,
    27652784                                                functions = [], i;
    27662785
    2767                                         for ( i = 0 ; i < arguments.length ; i++ )
     2786                                        for ( i = 0 ; i < args.length ; i++ )
    27682787                                        {
    2769                                                 if ( typeof( arguments[i] ) == 'function' )
    2770                                                         functions.push( arguments[i] );
     2788                                                if ( typeof( args[i] ) == 'function' )
     2789                                                        functions.push( args[i] );
    27712790                                                else
    27722791                                                        break;
    27732792                                        }
    27742793
    2775                                         if ( i < arguments.length && typeof( arguments[i] ) == 'string' )
     2794                                        if ( i < args.length && typeof( args[i] ) == 'string' )
    27762795                                        {
    2777                                                 msg = arguments[i];
     2796                                                msg = args[i];
    27782797                                                i++;
    27792798                                        }
    27802799
    2781                                         if ( i < arguments.length && typeof( arguments[i]) == 'number' )
    2782                                                 relation = arguments[i];
     2800                                        if ( i < args.length && typeof( args[i]) == 'number' )
     2801                                                relation = args[i];
    27832802
    27842803                                        var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false );
    27852804                                        for ( i = 0 ; i < functions.length ; i++ )
     
    28442863                                return this.regex( numberRegex, msg );
    28452864                        },
    28462865
     2866                        'cssLength' : function( msg )
     2867                        {
     2868                                return this.functions( function( val ){ return cssLengthRegex.test( CKEDITOR.tools.trim( val ) ); }, msg );
     2869                        },
     2870
    28472871                        equals : function( value, msg )
    28482872                        {
    28492873                                return this.functions( function( val ){ return val == value; }, msg );
  • _source/plugins/table/dialogs/table.js

     
    547547                                                                                        id : 'txtCellSpace',
    548548                                                                                        style : 'width:3em',
    549549                                                                                        label : editor.lang.table.cellSpace,
    550                                                                                         'default' : 1,
    551                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellSpacing ),
     550                                                                                        'default' : '1px',
     551                                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.table.invalidCellSpacing ),
     552                                                                                        setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; },
     553                                                                                        getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); },
    552554                                                                                        setup : function( selectedTable )
    553555                                                                                        {
    554                                                                                                 this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );
     556                                                                                                this.setValue( selectedTable.getAttribute( 'cellSpacing' ) );
    555557                                                                                        },
    556558                                                                                        commit : function( data, selectedTable )
    557559                                                                                        {
    558                                                                                                 if ( this.getValue() )
    559                                                                                                         selectedTable.setAttribute( 'cellSpacing', this.getValue() );
    560                                                                                                 else
    561                                                                                                         selectedTable.removeAttribute( 'cellSpacing' );
     560                                                                                                var val = this.getValue();
     561                                                                                                val ? selectedTable.setAttribute( 'cellSpacing', val )
     562                                                                                                                : selectedTable.removeAttribute( 'cellSpacing' );
    562563                                                                                        }
    563564                                                                                },
    564565                                                                                {
     
    566567                                                                                        id : 'txtCellPad',
    567568                                                                                        style : 'width:3em',
    568569                                                                                        label : editor.lang.table.cellPad,
    569                                                                                         'default' : 1,
    570                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellPadding ),
     570                                                                                        'default' : '1px',
     571                                                                                        validate : CKEDITOR.dialog.validate.cssLength( editor.lang.table.invalidCellPadding ),
     572                                                                                        setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; },
     573                                                                                        getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); },
    571574                                                                                        setup : function( selectedTable )
    572575                                                                                        {
    573                                                                                                 this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );
     576                                                                                                this.setValue( selectedTable.getAttribute( 'cellPadding' ) );
    574577                                                                                        },
    575578                                                                                        commit : function( data, selectedTable )
    576579                                                                                        {
    577                                                                                                 if ( this.getValue() )
    578                                                                                                         selectedTable.setAttribute( 'cellPadding', this.getValue() );
    579                                                                                                 else
    580                                                                                                         selectedTable.removeAttribute( 'cellPadding' );
     580                                                                                                var val = this.getValue();
     581                                                                                                val ? selectedTable.setAttribute( 'cellPadding', val )
     582                                                                                                                : selectedTable.removeAttribute( 'cellPadding' );
    581583                                                                                        }
    582584                                                                                }
    583585                                                                        ]
  • _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