Ticket #7114: 7114.patch

File 7114.patch, 6.3 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 )
     
    4648                        dialogadvtab = editor.plugins.dialogadvtab;
    4749                return {
    4850                        title : iframeLang.title,
    49                         minWidth : 350,
     51                        minWidth : 400,
    5052                        minHeight : 260,
    5153                        onShow : function()
    5254                        {
     
    115117                                                },
    116118                                                {
    117119                                                        type : 'hbox',
     120                                                        padding : 1,
    118121                                                        children :
    119122                                                        [
    120123                                                                {
    121124                                                                        id : 'width',
    122125                                                                        type : 'text',
    123                                                                         style : 'width:100%',
    124126                                                                        labelLayout : 'vertical',
    125127                                                                        label : commonLang.width,
    126128                                                                        validate : CKEDITOR.dialog.validate.integer( commonLang.invalidWidth ),
     129
     130                                                                        // Extra labelling of width unit type.
     131                                                                        onLoad : function()
     132                                                                        {
     133                                                                                var labelElement = this.getDialog().getContentElement( 'info', 'widthType' ).getElement(),
     134                                                                                        inputElement = this.getInputElement(),
     135                                                                                        ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
     136
     137                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
     138                                                                        },
    127139                                                                        setup : function( iframeNode, fakeImage )
    128140                                                                        {
    129141                                                                                loadValue.apply( this, arguments );
    130142                                                                                if ( fakeImage )
    131143                                                                                {
    132                                                                                         var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
    133                                                                                         if ( !isNaN( fakeImageWidth ) )
    134                                                                                                 this.setValue( fakeImageWidth );
     144                                                                                        var widthMatch = widthPattern.exec( fakeImage.$.style.width );
     145                                                                                        if ( widthMatch )
     146                                                                                        {
     147                                                                                                this.setValue( widthMatch[ 1 ] );
     148                                                                                                var type = this.getDialog().getContentElement( 'info', 'widthType' );
     149                                                                                                type && type.setValue( widthMatch[ 2 ] == '%' ? 'percents' : 'pixels' );
     150                                                                                        }
    135151                                                                                }
    136152                                                                        },
    137153                                                                        commit : function( iframeNode, extraStyles )
    138154                                                                        {
    139                                                                                 commitValue.apply( this, arguments );
    140                                                                                 if ( this.getValue() )
    141                                                                                         extraStyles.width = this.getValue() + 'px';
     155                                                                                var type = this.getDialog().getContentElement( 'info', 'widthType' ),
     156                                                                                        value = this.getValue();
     157                                                                                if ( value )
     158                                                                                {
     159                                                                                        var suffix = !type || type.getValue() == 'pixels' ? 'px' : '%';
     160                                                                                        extraStyles.width = this.getValue() + suffix;
     161                                                                                        value += ( suffix == 'px' ? '' : '%' );
     162                                                                                }
     163                                                                                commitValue.call( this, iframeNode, value );
    142164                                                                        }
    143165                                                                },
    144166                                                                {
     167                                                                        id : 'widthType',
     168                                                                        type : 'select',
     169                                                                        label : iframeLang.widthUnit,
     170                                                                        labelStyle: 'visibility:hidden',
     171                                                                        'default' : 'pixels',
     172                                                                        items :
     173                                                                        [
     174                                                                                [ iframeLang.widthPx , 'pixels' ],
     175                                                                                [ iframeLang.widthPc , 'percents' ]
     176                                                                        ]
     177                                                                },
     178                                                                {
    145179                                                                        id : 'height',
    146180                                                                        type : 'text',
    147                                                                         style : 'width:100%',
    148181                                                                        labelLayout : 'vertical',
    149182                                                                        label : commonLang.height,
    150183                                                                        validate : CKEDITOR.dialog.validate.integer( commonLang.invalidHeight ),
     184
     185                                                                        // Extra labelling of height unit type.
     186                                                                        onLoad : function()
     187                                                                        {
     188                                                                                var labelElement = this.getDialog().getContentElement( 'info', 'heightType' ).getElement(),
     189                                                                                        inputElement = this.getInputElement(),
     190                                                                                        ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
     191
     192                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
     193                                                                        },
    151194                                                                        setup : function( iframeNode, fakeImage )
    152195                                                                        {
    153196                                                                                loadValue.apply( this, arguments );
     
    166209                                                                        }
    167210                                                                },
    168211                                                                {
     212                                                                        id : 'heightType',
     213                                                                        type : 'html',
     214                                                                        html : '<div><br />' + iframeLang.widthPx + '</div>'
     215                                                                },
     216                                                                {
    169217                                                                        id : 'align',
    170218                                                                        type : 'select',
    171219                                                                        'default' : '',
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy