Ticket #7981: 7981_2.patch

File 7981_2.patch, 7.7 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/pastefromword/filter/default.js

     
    261261                                                                        {
    262262                                                                                // Deal with component/short-hand form.
    263263                                                                                var values = margin.split( ' ' );
    264                                                                                 margin = plugin.utils.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );
    265                                                                                 margin = parseInt( margin, 10 );
     264                                                                                margin = CKEDITOR.tools.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );
    266265
    267266                                                                                // Figure out the indent unit by checking the first time of incrementation.
    268267                                                                                if ( !listBaseIndent && previousListItemMargin !== null && margin > previousListItemMargin )
     
    310309                                return false;
    311310                        },
    312311
    313                         // Convert various length units to 'px' in ignorance of DPI.
    314                         convertToPx : ( function ()
    315                         {
    316                                 var calculator = CKEDITOR.dom.element.createFromHtml(
    317                                                                 '<div style="position:absolute;left:-9999px;' +
    318                                                                 'top:-9999px;margin:0px;padding:0px;border:0px;"' +
    319                                                                 '></div>', CKEDITOR.document );
    320                                 CKEDITOR.document.getBody().append( calculator );
    321 
    322                                 return function( cssLength )
    323                                 {
    324                                         if ( cssLengthRelativeUnit.test( cssLength ) )
    325                                         {
    326                                                 calculator.setStyle( 'width', cssLength );
    327                                                 return calculator.$.clientWidth + 'px';
    328                                         }
    329 
    330                                         return cssLength;
    331                                 };
    332                         } )(),
    333 
    334312                        // Providing a shorthand style then retrieve one or more style component values.
    335313                        getStyleComponents : ( function()
    336314                        {
     
    423401                                                                                [ 'tab-stops', null, function( val )
    424402                                                                                {
    425403                                                                                        var margin = val.split( ' ' )[ 1 ].match( cssLengthRelativeUnit );
    426                                                                                         margin && ( previousListItemMargin = parseInt( plugin.utils.convertToPx( margin[ 0 ] ), 10 ) );
     404                                                                                        margin && ( previousListItemMargin = CKEDITOR.tools.convertToPx( margin[ 0 ] ) );
    427405                                                                                } ],
    428406                                                                                ( level == 1 ? [ 'mso-list', null, function( val )
    429407                                                                                {
     
    779757                                isListBulletIndicator = this.utils.isListBulletIndicator,
    780758                                containsNothingButSpaces = this.utils.isContainingOnlySpaces,
    781759                                resolveListItem = this.utils.resolveList,
    782                                 convertToPx = this.utils.convertToPx,
     760                                convertToPx = function( value )
     761                                        {
     762                                                value = CKEDITOR.tools.convertToPx( value );
     763                                                return isNaN( value ) ? value : value + 'px';
     764                                        },
    783765                                getStyleComponents = this.utils.getStyleComponents,
    784766                                listDtdParents = this.utils.listDtdParents,
    785767                                removeFontStyles = config.pasteFromWordRemoveFontStyles !== false,
  • _source/plugins/iframe/dialogs/iframe.js

     
    5050                        title : iframeLang.title,
    5151                        minWidth : 350,
    5252                        minHeight : 260,
    53                         onLoad : function()
    54                         {
    55                                 var dialog = this,
    56                                         styles = dialog.getContentElement( 'advanced', 'advStyles' );
    57 
    58                                 styles && styles.on( 'change', function()
    59                                         {
    60                                                 // Synchronize width value.
    61                                                 var width = this.getStyle( 'width', '' ),
    62                                                         txtWidth = dialog.getContentElement( 'info', 'width' );
    63 
    64                                                 txtWidth && txtWidth.setValue( width, true );
    65 
    66                                                 // Synchronize height value.
    67                                                 var height = this.getStyle( 'height', '' ),
    68                                                         txtHeight = dialog.getContentElement( 'info', 'height' );
    69 
    70                                                 txtHeight && txtHeight.setValue( height, true );
    71                                         });
    72                         },
    7353                        onShow : function()
    7454                        {
    7555                                // Clear previously saved elements.
     
    8363                                        var iframeNode = editor.restoreRealElement( fakeImage );
    8464                                        this.iframeNode = iframeNode;
    8565
    86                                         this.setupContent( iframeNode, fakeImage );
     66                                        this.setupContent( iframeNode );
    8767                                }
    88 
    89                                 // Call the onChange method for the widht and height fields so
    90                                 // they get reflected into the Advanced tab.
    91                                 var widthInput = this.getContentElement( 'info', 'width' ),
    92                                         heightInput = this.getContentElement( 'info', 'height' );
    93                                 widthInput && widthInput.onChange();
    94                                 heightInput && heightInput.onChange();
    9568                        },
    9669                        onOk : function()
    9770                        {
     
    152125                                                                        style : 'width:100%',
    153126                                                                        labelLayout : 'vertical',
    154127                                                                        label : commonLang.width,
    155                                                                         validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
     128                                                                        validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ),
    156129                                                                        getValue : defaultToPixel,
    157130                                                                        setup : function( iframeNode, fakeImage )
    158131                                                                        {
     
    164137                                                                                commitValue.apply( this, arguments );
    165138                                                                                var val = this.getValue();
    166139                                                                                val && ( extraStyles.width = val );
    167                                                                         },
    168                                                                         onChange : function()
    169                                                                         {
    170                                                                                 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ),
    171                                                                                         value = this.getValue();
    172                                                                                 styles && styles.updateStyle( 'width', value );
    173140                                                                        }
    174141                                                                },
    175142                                                                {
     
    178145                                                                        style : 'width:100%',
    179146                                                                        labelLayout : 'vertical',
    180147                                                                        label : commonLang.height,
    181                                                                         validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ),
     148                                                                        validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ),
    182149                                                                        getValue : defaultToPixel,
    183150                                                                        setup : function( iframeNode, fakeImage )
    184151                                                                        {
     
    190157                                                                                commitValue.apply( this, arguments );
    191158                                                                                var val = this.getValue();
    192159                                                                                val && ( extraStyles.height = val );
    193                                                                         },
    194                                                                         onChange : function()
    195                                                                         {
    196                                                                                 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ),
    197                                                                                         value = this.getValue();
    198                                                                                 styles && styles.updateStyle( 'height', value );
    199160                                                                        }
    200161                                                                },
    201162                                                                {
  • _source/plugins/fakeobjects/plugin.js

     
    3333                                                var height = match && match[1];
    3434
    3535                                                if ( width )
    36                                                         realElement.attributes.width = width;
     36                                                        realElement.attributes.width = CKEDITOR.tools.convertToPx( width );
    3737
    3838                                                if ( height )
    39                                                         realElement.attributes.height = height;
     39                                                        realElement.attributes.height = CKEDITOR.tools.convertToPx( height );
    4040                                        }
    4141                                }
    4242
  • _source/core/tools.js

     
    687687                })(),
    688688
    689689                /**
     690                 * Convert the specified CSS length value to the calculated pixel length inside this page.
     691                 * <strong>Note:</strong> Percentage based value is left intact.
     692                 * @param {String} cssLength CSS length value.
     693                 */
     694                convertToPx : ( function ()
     695                        {
     696                                var calculator;
     697
     698                                return function( cssLength )
     699                                {
     700                                        if ( !calculator )
     701                                        {
     702                                                calculator = CKEDITOR.dom.element.createFromHtml(
     703                                                                '<div style="position:absolute;left:-9999px;' +
     704                                                                'top:-9999px;margin:0px;padding:0px;border:0px;"' +
     705                                                                '></div>', CKEDITOR.document );
     706                                                CKEDITOR.document.getBody().append( calculator );
     707                                        }
     708
     709                                        if ( !/%$/.test( cssLength ) )
     710                                        {
     711                                                calculator.setStyle( 'width', cssLength );
     712                                                return calculator.$.clientWidth;
     713                                        }
     714
     715                                        return cssLength;
     716                                };
     717                        } )(),
     718
     719                /**
    690720                 * String specified by {@param str} repeats {@param times} times.
    691721                 * @param str
    692722                 * @param times
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy