Ticket #7114: 7114_2.patch

File 7114_2.patch, 8.7 KB (added by Sa'ar Zac Elias, 12 years ago)
  • _source/lang/en.js

     
    606606                toolbar         : 'IFrame',
    607607                noUrl           : 'Please type the iframe URL',
    608608                scrolling       : 'Enable scrollbars',
    609                 border          : 'Show frame border'
     609                border          : 'Show frame border',
     610                widthPx         : 'pixels',
     611                widthPc         : 'percent',
     612                widthUnit               : 'width unit'
    610613        },
    611614
    612615        font :
  • _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 ),
    29                                                         width = match && match[1];
     28                                                var matchWidth = /(?:^|\s)width\s*:\s*(\d+)(%)?/i.exec( style ),
     29                                                        width = matchWidth && matchWidth[1];
    3030
    3131                                                // Get the height from the style.
    32                                                 match = /(?:^|\s)height\s*:\s*(\d+)/i.exec( style );
    33                                                 var height = match && match[1];
     32                                                var matchHeight = /(?:^|\s)height\s*:\s*(\d+)(%)?/i.exec( style ),
     33                                                        height = matchHeight && matchHeight[1];
    3434
    3535                                                if ( width )
    36                                                         realElement.attributes.width = width;
     36                                                        realElement.attributes.width = width + ( matchWidth[ 2 ] || '' );
    3737
    3838                                                if ( height )
    39                                                         realElement.attributes.height = height;
     39                                                        realElement.attributes.height = height + ( matchHeight[ 2 ] || '' );
    4040                                        }
    4141                                }
    4242
  • _source/plugins/iframe/dialogs/iframe.js

     
    1111        {
    1212                scrolling : { 'true' : 'yes', 'false' : 'no' },
    1313                frameborder : { 'true' : '1', 'false' : '0' }
    14         };
     14        },
     15        widthPattern = /^(\d+(?:\.\d+)?)(px|%)$/;
    1516
    1617        function loadValue( iframeNode )
    1718        {
     
    2627                }
    2728        }
    2829
    29         function commitValue( iframeNode )
     30        function commitValue( iframeNode, value )
    3031        {
    3132                var isRemove = this.getValue() === '',
    32                         isCheckbox = this instanceof CKEDITOR.ui.dialog.checkbox,
    33                         value = this.getValue();
     33                        isCheckbox = this instanceof CKEDITOR.ui.dialog.checkbox;
     34                value = typeof value == 'string' ? value : this.getValue();
     35
    3436                if ( isRemove )
    3537                        iframeNode.removeAttribute( this.att || this.id );
    3638                else if ( isCheckbox )
     
    115117                                                },
    116118                                                {
    117119                                                        type : 'hbox',
     120                                                        widths : [ '50%', '50%' ],
    118121                                                        children :
    119122                                                        [
    120123                                                                {
    121                                                                         id : 'width',
    122                                                                         type : 'text',
    123                                                                         style : 'width:100%',
    124                                                                         labelLayout : 'vertical',
    125                                                                         label : commonLang.width,
    126                                                                         validate : CKEDITOR.dialog.validate.integer( commonLang.invalidWidth ),
    127                                                                         setup : function( iframeNode, fakeImage )
    128                                                                         {
    129                                                                                 loadValue.apply( this, arguments );
    130                                                                                 if ( fakeImage )
     124                                                                        type : 'vbox',
     125                                                                        children :
     126                                                                        [
    131127                                                                                {
    132                                                                                         var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
    133                                                                                         if ( !isNaN( fakeImageWidth ) )
    134                                                                                                 this.setValue( fakeImageWidth );
    135                                                                                 }
    136                                                                         },
    137                                                                         commit : function( iframeNode, extraStyles )
    138                                                                         {
    139                                                                                 commitValue.apply( this, arguments );
    140                                                                                 if ( this.getValue() )
    141                                                                                         extraStyles.width = this.getValue() + 'px';
    142                                                                         }
    143                                                                 },
    144                                                                 {
    145                                                                         id : 'height',
    146                                                                         type : 'text',
    147                                                                         style : 'width:100%',
    148                                                                         labelLayout : 'vertical',
    149                                                                         label : commonLang.height,
    150                                                                         validate : CKEDITOR.dialog.validate.integer( commonLang.invalidHeight ),
    151                                                                         setup : function( iframeNode, fakeImage )
    152                                                                         {
    153                                                                                 loadValue.apply( this, arguments );
    154                                                                                 if ( fakeImage )
     128                                                                                        type : 'hbox',
     129                                                                                        padding : 1,
     130                                                                                        children :
     131                                                                                        [
     132                                                                                                {
     133                                                                                                        id : 'width',
     134                                                                                                        type : 'text',
     135                                                                                                        labelLayout : 'vertical',
     136                                                                                                        label : commonLang.width,
     137                                                                                                        validate : CKEDITOR.dialog.validate.integer( commonLang.invalidWidth ),
     138
     139                                                                                                        // Extra labelling of width unit type.
     140                                                                                                        onLoad : function()
     141                                                                                                        {
     142                                                                                                                var labelElement = this.getDialog().getContentElement( 'info', 'widthType' ).getElement(),
     143                                                                                                                        inputElement = this.getInputElement(),
     144                                                                                                                        ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
     145
     146                                                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
     147                                                                                                        },
     148                                                                                                        setup : function( iframeNode, fakeImage )
     149                                                                                                        {
     150                                                                                                                loadValue.apply( this, arguments );
     151                                                                                                                if ( fakeImage )
     152                                                                                                                {
     153                                                                                                                        var widthMatch = widthPattern.exec( fakeImage.$.style.width );
     154                                                                                                                        if ( widthMatch )
     155                                                                                                                        {
     156                                                                                                                                this.setValue( widthMatch[ 1 ] );
     157                                                                                                                                var type = this.getDialog().getContentElement( 'info', 'widthType' );
     158                                                                                                                                type && type.setValue( widthMatch[ 2 ] == '%' ? 'percents' : 'pixels' );
     159                                                                                                                        }
     160                                                                                                                }
     161                                                                                                        },
     162                                                                                                        commit : function( iframeNode, extraStyles )
     163                                                                                                        {
     164                                                                                                                var type = this.getDialog().getContentElement( 'info', 'widthType' ),
     165                                                                                                                        value = this.getValue();
     166                                                                                                                if ( value )
     167                                                                                                                {
     168                                                                                                                        var suffix = !type || type.getValue() == 'pixels' ? 'px' : '%';
     169                                                                                                                        extraStyles.width = this.getValue() + suffix;
     170                                                                                                                        value += ( suffix == 'px' ? '' : '%' );
     171                                                                                                                }
     172                                                                                                                commitValue.call( this, iframeNode, value );
     173                                                                                                        }
     174                                                                                                },
     175                                                                                                {
     176                                                                                                        id : 'widthType',
     177                                                                                                        type : 'select',
     178                                                                                                        label : iframeLang.widthUnit,
     179                                                                                                        labelStyle: 'visibility:hidden',
     180                                                                                                        'default' : 'pixels',
     181                                                                                                        items :
     182                                                                                                        [
     183                                                                                                                [ iframeLang.widthPx , 'pixels' ],
     184                                                                                                                [ iframeLang.widthPc , 'percents' ]
     185                                                                                                        ]
     186                                                                                                }
     187                                                                                        ]
     188                                                                                },
    155189                                                                                {
    156                                                                                         var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
    157                                                                                         if ( !isNaN( fakeImageHeight ) )
    158                                                                                                 this.setValue( fakeImageHeight );
     190                                                                                        type : 'hbox',
     191                                                                                        padding : 1,
     192                                                                                        children :
     193                                                                                        [
     194                                                                                                {
     195                                                                                                        id : 'height',
     196                                                                                                        type : 'text',
     197                                                                                                        labelLayout : 'vertical',
     198                                                                                                        label : commonLang.height,
     199                                                                                                        validate : CKEDITOR.dialog.validate.integer( commonLang.invalidHeight ),
     200
     201                                                                                                        // Extra labelling of height unit type.
     202                                                                                                        onLoad : function()
     203                                                                                                        {
     204                                                                                                                var labelElement = this.getDialog().getContentElement( 'info', 'heightType' ).getElement(),
     205                                                                                                                        inputElement = this.getInputElement(),
     206                                                                                                                        ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
     207
     208                                                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
     209                                                                                                        },
     210                                                                                                        setup : function( iframeNode, fakeImage )
     211                                                                                                        {
     212                                                                                                                loadValue.apply( this, arguments );
     213                                                                                                                if ( fakeImage )
     214                                                                                                                {
     215                                                                                                                        var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
     216                                                                                                                        if ( !isNaN( fakeImageHeight ) )
     217                                                                                                                                this.setValue( fakeImageHeight );
     218                                                                                                                }
     219                                                                                                        },
     220                                                                                                        commit : function( iframeNode, extraStyles )
     221                                                                                                        {
     222                                                                                                                commitValue.apply( this, arguments );
     223                                                                                                                if ( this.getValue() )
     224                                                                                                                        extraStyles.height = this.getValue() + 'px';
     225                                                                                                        }
     226                                                                                                },
     227                                                                                                {
     228                                                                                                        id : 'heightType',
     229                                                                                                        type : 'html',
     230                                                                                                        html : '<div><br />' + iframeLang.widthPx + '</div>'
     231                                                                                                }
     232                                                                                        ]
    159233                                                                                }
    160                                                                         },
    161                                                                         commit : function( iframeNode, extraStyles )
    162                                                                         {
    163                                                                                 commitValue.apply( this, arguments );
    164                                                                                 if ( this.getValue() )
    165                                                                                         extraStyles.height = this.getValue() + 'px';
    166                                                                         }
     234                                                                        ]
    167235                                                                },
    168236                                                                {
    169237                                                                        id : 'align',
     
    178246                                                                                [ commonLang.alignMiddle , 'middle' ],
    179247                                                                                [ commonLang.alignBottom , 'bottom' ]
    180248                                                                        ],
    181                                                                         style : 'width:100%',
    182249                                                                        labelLayout : 'vertical',
    183250                                                                        label : commonLang.align,
    184251                                                                        setup : function( iframeNode, fakeImage )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy