Ticket #3008: 3008_2.patch

File 3008_2.patch, 33.7 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/htmldataprocessor/plugin.js

     
    7070
    7171                                        if ( attribs._cke_saved_href )
    7272                                                delete attribs.href;
     73                                },
     74                               
     75                                /**
     76                                 * IE sucks with dynamic 'name' attribute after element is created, '_cke_saved_name' is used instead for this attribute.   
     77                                 */                             
     78                                input : function( element )
     79                                {
     80                                        var attribs = element.attributes;
     81
     82                                        if ( attribs._cke_saved_name )
     83                                                delete attribs.name;
    7384                                }
    7485                        },
    7586
     
    93104                };
    94105        }
    95106
    96         var protectUrlTagRegex = /<(?:a|area|img).*?\s((?:href|src)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;
    97 
    98         function protectUrls( html )
     107        var protectAttributeRegex = /<(?:a|area|img|input).*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;
     108       
     109        function protectAttributes( html )
    99110        {
    100                 return html.replace( protectUrlTagRegex, '$& _cke_saved_$1' );
     111                return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );
    101112        }
    102113
    103114        CKEDITOR.plugins.add( 'htmldataprocessor',
     
    132143                        // Before anything, we must protect the URL attributes as the
    133144                        // browser may changing them when setting the innerHTML later in
    134145                        // the code.
    135                         data = protectUrls( data );
     146                        data = protectAttributes( data );
    136147
    137148                        // Call the browser to help us fixing a possibly invalid HTML
    138149                        // structure.
  • _source/plugins/forms/dialogs/checkbox.js

     
    3131                                element.setAttribute( 'type', 'checkbox' );
    3232                        }
    3333
    34                         this.commitContent( element );
    35 
    3634                        if ( isInsertMode )
    3735                                editor.insertElement( element );
     36                        this.commitContent( { element : element } );
    3837                },
    3938                contents : [
    4039                        {
     
    5150                                                accessKey : 'N',
    5251                                                setup : function( element )
    5352                                                {
    54                                                         this.setValue( element.getAttribute( 'name' ) );
     53                                                        this.setValue( element.getAttribute( '_cke_saved_name' ) || '' );
    5554                                                },
    56                                                 commit : function( element )
     55                                                commit : function( data )
    5756                                                {
    58                                                         if ( this.getValue() || this.isChanged() )
    59                                                                 element.setAttribute( 'name', this.getValue() );
     57                                                        var element = data.element;
     58
     59                                                        // IE failed to update 'name' property on input elements, protect it now.
     60                                                        if ( this.getValue() )
     61                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     62                                                        else
     63                                                        {
     64                                                                element.removeAttribute( '_cke_saved_name' );
     65                                                                element.removeAttribute( 'name' );
     66                                                        }
    6067                                                }
    6168                                        },
    6269                                        {
     
    6774                                                accessKey : 'V',
    6875                                                setup : function( element )
    6976                                                {
    70                                                         this.setValue( element.getAttribute( 'value' ) );
     77                                                        this.setValue( element.getAttribute( 'value' ) || '' );
    7178                                                },
    72                                                 commit : function( element )
     79                                                commit : function( data )
    7380                                                {
    74                                                         if ( this.getValue() || this.isChanged() )
     81                                                        var element = data.element;
     82
     83                                                        if ( this.getValue() )
    7584                                                                element.setAttribute( 'value', this.getValue() );
     85                                                        else
     86                                                                element.removeAttribute( 'value' );
    7687                                                }
    7788                                        },
    7889                                        {
     
    8697                                                {
    8798                                                        this.setValue( element.getAttribute( 'checked' ) );
    8899                                                },
    89                                                 commit : function( element )
     100                                                commit : function( data )
    90101                                                {
    91                                                         if ( this.getValue() || this.isChanged() )
    92                                                                 element.setAttribute( 'checked', this.getValue() );
     102                                                        var element = data.element;
     103
     104                                                        if ( CKEDITOR.env.ie )
     105                                                        {
     106                                                                var isElementChecked = !!element.getAttribute( 'checked' );
     107                                                                var isChecked = !!this.getValue();
     108
     109                                                                if ( isElementChecked != isChecked )
     110                                                                {
     111                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="checkbox"'
     112                                                                                   + ( isChecked ? ' checked="checked"' : '' )
     113                                                                                   + '></input>', editor.document );
     114                                                                        element.copyAttributes( replace, { type : 1, checked : 1 } );
     115                                                                        replace.replace( element );
     116                                                                        editor.getSelection().selectElement( replace );
     117                                                                        data.element = replace;
     118                                                                }
     119                                                        }
     120                                                        else
     121                                                        {
     122                                                                if ( this.getValue() )
     123                                                                        element.setAttribute( 'checked', this.getValue() );
     124                                                                else
     125                                                                        element.removeAttribute( 'checked' );
     126                                                        }
    93127                                                }
    94128                                        }
    95129                                ]
  • _source/plugins/forms/dialogs/textfield.js

     
    44*/
    55CKEDITOR.dialog.add( 'textfield', function( editor )
    66{
     7        var autoAttributes =
     8        {
     9                value : 1,
     10                size : 1,
     11                maxLength : 1
     12        };
     13
     14        var ieDefaults =
     15        {
     16                size : 20,
     17                maxLength : 0x7fffffff
     18        };
     19
     20        var acceptedTypes =
     21        {
     22                text : 1,
     23                password : 1
     24        };
     25
    726        return {
    827                title : editor.lang.textfield.title,
    928                minWidth : 350,
     
    1130                onShow : function()
    1231                {
    1332                        var element = this.getParentEditor().getSelection().getSelectedElement();
    14                         if ( element && element.getName() == "input" && ( element.getAttribute( 'type' ) == "text" || !element.getAttribute( 'type' ) ) )
     33                        if ( element && element.getName() == "input" &&
     34                                        ( acceptedTypes[ element.getAttribute( 'type' ) ] || !element.getAttribute( 'type' ) ) )
    1535                        {
    1636                                this._element = element;
    1737                                this.setupContent( element );
     
    2949                                element = editor.document.createElement( 'input' );
    3050                                element.setAttribute( 'type', 'text' );
    3151                        }
    32                         this.commitContent( element );
    3352
    3453                        if ( isInsertMode )
    3554                                editor.insertElement( element );
     55                        this.commitContent( { element : element } );
    3656                },
     57                onLoad : function()
     58                {
     59                        var autoSetup = function( element )
     60                        {
     61                                var value = element.getAttribute( this.id );
     62                                if ( CKEDITOR.env.ie && ( this.id in ieDefaults ) && ieDefaults[ this.id ] == value )
     63                                        this.setValue( '' );
     64                                else
     65                                        this.setValue( element.getAttribute( this.id ) || '' );
     66                        };
     67
     68                        var autoCommit = function( data )
     69                        {
     70                                var element = data.element;
     71                                var value = this.getValue();
     72
     73                                if ( value )
     74                                        element.setAttribute( this.id, value );
     75                                else
     76                                        element.removeAttribute( this.id );
     77                        };
     78
     79                        this.foreach( function( contentObj )
     80                                {
     81                                        if ( autoAttributes[ contentObj.id ] )
     82                                        {
     83                                                contentObj.setup = autoSetup;
     84                                                contentObj.commit = autoCommit;
     85                                        }
     86                                } );
     87                },
    3788                contents : [
    3889                        {
    3990                                id : 'info',
     
    4697                                                children :
    4798                                                [
    4899                                                        {
    49                                                                 id : 'txtName',
     100                                                                id : '_cke_saved_name',
    50101                                                                type : 'text',
    51102                                                                label : editor.lang.textfield.name,
    52103                                                                'default' : '',
    53104                                                                accessKey : 'N',
    54105                                                                setup : function( element )
    55106                                                                {
    56                                                                         this.setValue( element.getAttribute( 'name' ) );
    57                                                                         this.focus();
     107                                                                        this.setValue(
     108                                                                                        element.getAttribute( '_cke_saved_name' ) ||
     109                                                                                        element.getAttribute( 'name' ) ||
     110                                                                                        '' );
    58111                                                                },
    59                                                                 commit : function( element )
     112                                                                commit : function( data )
    60113                                                                {
    61                                                                         if ( this.getValue() || this.isChanged() )
    62                                                                                 element.setAttribute( 'name', this.getValue() );
     114                                                                        var element = data.element;
     115
     116                                                                        if ( this.getValue() )
     117                                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     118                                                                        else
     119                                                                        {
     120                                                                                element.removeAttribute( '_cke_saved_name' );
     121                                                                                element.removeAttribute( 'name' );
     122                                                                        }
    63123                                                                }
    64124                                                        },
    65125                                                        {
    66                                                                 id : 'txtValue',
     126                                                                id : 'value',
    67127                                                                type : 'text',
    68128                                                                label : editor.lang.textfield.value,
    69129                                                                'default' : '',
    70                                                                 accessKey : 'V',
    71                                                                 setup : function( element )
    72                                                                 {
    73                                                                         this.setValue( element.getAttribute( 'value' ) );
    74                                                                 },
    75                                                                 commit : function( element )
    76                                                                 {
    77                                                                         if ( this.getValue() || this.isChanged() )
    78                                                                                 element.setAttribute( 'value', this.getValue() );
    79                                                                 }
     130                                                                accessKey : 'V'
    80131                                                        }
    81132                                                ]
    82133                                        },
     
    86137                                                children :
    87138                                                [
    88139                                                        {
    89                                                                 id : 'txtTextCharWidth',
     140                                                                id : 'size',
    90141                                                                type : 'text',
    91142                                                                label : editor.lang.textfield.charWidth,
    92143                                                                'default' : '',
    93144                                                                accessKey : 'C',
    94145                                                                style : 'width:50px',
    95                                                                 validate: function()
    96                                                                 {
    97                                                                         var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
    98                                                                         return func.apply( this );
    99                                                                 },
    100                                                                 setup : function( element )
    101                                                                 {
    102                                                                         this.setValue( element.getAttribute( 'size' ) );
    103                                                                 },
    104                                                                 commit : function( element )
    105                                                                 {
    106                                                                         if ( this.getValue() || this.isChanged() )
    107                                                                                 element.setAttribute( 'size', this.getValue() );
    108                                                                 }
     146                                                                validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )
    109147                                                        },
    110148                                                        {
    111                                                                 id : 'txtMaxChars',
     149                                                                id : 'maxLength',
    112150                                                                type : 'text',
    113151                                                                label : editor.lang.textfield.maxChars,
    114152                                                                'default' : '',
    115153                                                                accessKey : 'M',
    116154                                                                style : 'width:50px',
    117                                                                 validate: function()
    118                                                                 {
    119                                                                         var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
    120                                                                         return func.apply( this );
    121                                                                 },
    122                                                                 setup : function( element )
    123                                                                 {
    124                                                                         this.setValue( element.getAttribute( 'maxlength' ) );
    125                                                                 },
    126                                                                 commit : function( element )
    127                                                                 {
    128                                                                         if ( this.getValue() || this.isChanged() )
    129                                                                                 element.setAttribute( 'maxlength', this.getValue() );
    130                                                                 }
     155                                                                validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )
    131156                                                        }
    132157                                                ]
    133158                                        },
    134159                                        {
    135                                                 id : 'cmbType',
     160                                                id : 'type',
    136161                                                type : 'select',
    137162                                                label : editor.lang.textfield.type,
    138163                                                'default' : 'text',
     
    140165                                                items :
    141166                                                [
    142167                                                        [ editor.lang.textfield.typeText, 'text' ],
    143                                                         [ editor.lang.textfield.typePass, 'pass' ]
     168                                                        [ editor.lang.textfield.typePass, 'password' ]
    144169                                                ],
    145170                                                setup : function( element )
    146171                                                {
    147172                                                        this.setValue( element.getAttribute( 'type' ) );
    148173                                                },
    149                                                 commit : function( element )
     174                                                commit : function( data )
    150175                                                {
    151                                                         element.setAttribute( 'type', this.getValue() );
     176                                                        var element = data.element;
     177
     178                                                        if ( CKEDITOR.env.ie )
     179                                                        {
     180                                                                var elementType = element.getAttribute( 'type' );
     181                                                                var myType = this.getValue();
     182
     183                                                                if ( elementType != myType )
     184                                                                {
     185                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + myType + '"></input>', editor.document );
     186                                                                        element.copyAttributes( replace, { type : 1 } );
     187                                                                        replace.replace( element );
     188                                                                        editor.getSelection().selectElement( replace );
     189                                                                        data.element = element;
     190                                                                }
     191                                                        }
     192                                                        else
     193                                                                element.setAttribute( 'type', this.getValue() );
    152194                                                }
    153195                                        }
    154196                                ]
  • _source/plugins/forms/dialogs/button.js

     
    3232                                editor = this.getParentEditor();
    3333                                element = editor.document.createElement( 'input' );
    3434                        }
    35                         this.commitContent( element );
    3635
    3736                        if ( isInsertMode )
    3837                                editor.insertElement( element );
     38                        this.commitContent( { element : element } );
    3939                },
    4040                contents : [
    4141                        {
     
    4444                                title : editor.lang.button.title,
    4545                                elements : [
    4646                                        {
    47                                                 id : 'txtName',
     47                                                id : '_cke_saved_name',
    4848                                                type : 'text',
    4949                                                label : editor.lang.common.name,
    5050                                                'default' : '',
    5151                                                setup : function( element )
    5252                                                {
    53                                                         this.setValue( element.getAttribute( 'name' ) );
    54                                                         this.focus();
     53                                                        this.setValue(
     54                                                                        element.getAttribute( '_cke_saved_name' ) ||
     55                                                                        element.getAttribute( 'name' ) ||
     56                                                                        '' );
    5557                                                },
    56                                                 commit : function( element )
     58                                                commit : function( data )
    5759                                                {
    58                                                         if ( this.getValue() || this.isChanged() )
    59                                                                 element.setAttribute( 'name', this.getValue() );
     60                                                        var element = data.element;
     61
     62                                                        if ( this.getValue() )
     63                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     64                                                        else
     65                                                        {
     66                                                                element.removeAttribute( '_cke_saved_name' );
     67                                                                element.removeAttribute( 'name' );
     68                                                        }
    6069                                                }
    6170                                        },
    6271                                        {
    63                                                 id : 'txtValue',
     72                                                id : 'value',
    6473                                                type : 'text',
    6574                                                label : editor.lang.button.text,
    6675                                                accessKey : 'V',
    6776                                                'default' : '',
    6877                                                setup : function( element )
    6978                                                {
    70                                                         this.setValue( element.getAttribute( 'value' ) );
     79                                                        this.setValue( element.getAttribute( 'value' ) || '' );
    7180                                                },
    72                                                 commit : function( element )
     81                                                commit : function( data )
    7382                                                {
    74                                                         if ( this.getValue() || this.isChanged() )
     83                                                        var element = data.element;
     84
     85                                                        if ( this.getValue() )
    7586                                                                element.setAttribute( 'value', this.getValue() );
     87                                                        else
     88                                                                element.removeAttribute( 'value' );
    7689                                                }
    7790                                        },
    7891                                        {
    79                                                 id : 'txtType',
     92                                                id : 'type',
    8093                                                type : 'select',
    8194                                                label : editor.lang.button.type,
    8295                                                'default' : 'button',
     
    89102                                                ],
    90103                                                setup : function( element )
    91104                                                {
    92                                                         this.setValue( element.getAttribute( 'type' ) );
     105                                                        this.setValue( element.getAttribute( 'type' ) || '' );
    93106                                                },
    94                                                 commit : function( element )
     107                                                commit : function( data )
    95108                                                {
    96                                                         element.setAttribute( 'type', this.getValue() );
     109                                                        var element = data.element;
     110
     111                                                        if ( CKEDITOR.env.ie )
     112                                                        {
     113                                                                var elementType = element.getAttribute( 'type' );
     114                                                                var currentType = this.getValue();
     115
     116                                                                if ( currentType != elementType )
     117                                                                {
     118                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + currentType +
     119                                                                                '"></input>', editor.document );
     120                                                                        element.copyAttributes( replace, { type : 1 } );
     121                                                                        replace.replace( element );
     122                                                                        editor.getSelection().selectElement( replace );
     123                                                                        data.element = replace;
     124                                                                }
     125                                                        }
     126                                                        else
     127                                                                element.setAttribute( 'type', this.getValue() );
    97128                                                }
    98129                                        }
    99130                                ]
  • _source/plugins/forms/dialogs/textarea.js

     
    4040                                title : editor.lang.textarea.title,
    4141                                elements : [
    4242                                        {
    43                                                 id : 'txtName',
     43                                                id : '_cke_saved_name',
    4444                                                type : 'text',
    4545                                                label : editor.lang.common.name,
    4646                                                'default' : '',
    4747                                                accessKey : 'N',
    4848                                                setup : function( element )
    4949                                                {
    50                                                         this.setValue( element.getAttribute( 'name' ) );
    51                                                         this.focus();
     50                                                        this.setValue( element.getAttribute( '_cke_saved_name' ) );
    5251                                                },
    5352                                                commit : function( element )
    5453                                                {
    55                                                         if ( this.getValue() || this.isChanged() )
    56                                                                 element.setAttribute( 'name', this.getValue() );
     54                                                        if ( this.getValue() )
     55                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     56                                                        else
     57                                                        {
     58                                                                element.removeAttribute( '_cke_saved_name' );
     59                                                                element.removeAttribute( 'name' );
     60                                                        }
    5761                                                }
    5862                                        },
    5963                                        {
    60                                                 id : 'txtColumns',
     64                                                id : 'cols',
    6165                                                type : 'text',
    6266                                                label : editor.lang.textarea.cols,
    6367                                                'default' : '',
    6468                                                accessKey : 'C',
    6569                                                style : 'width:50px',
    66                                                 validate: function()
    67                                                 {
    68                                                         var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
    69                                                         return func.apply( this );
    70                                                 },
     70                                                validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
    7171                                                setup : function( element )
    7272                                                {
    73                                                         this.setValue( element.getAttribute( 'cols' ) );
     73                                                        var ieDefault = 20;
     74                                                        var value = element.getAttribute( 'cols' );
     75                                                        this.setValue( ( CKEDITOR.env.ie && ( value == ieDefault ) ? '' : value ) || '' );
    7476                                                },
    7577                                                commit : function( element )
    7678                                                {
    77                                                         if ( this.getValue() || this.isChanged() )
     79                                                        if ( this.getValue() )
    7880                                                                element.setAttribute( 'cols', this.getValue() );
     81                                                        else
     82                                                                element.removeAttribute( 'cols' );
    7983                                                }
    8084                                        },
    8185                                        {
    82                                                 id : 'txtRows',
     86                                                id : 'rows',
    8387                                                type : 'text',
    8488                                                label : editor.lang.textarea.rows,
    8589                                                'default' : '',
    8690                                                accessKey : 'R',
    8791                                                style : 'width:50px',
    88                                                 validate: function()
    89                                                 {
    90                                                         var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
    91                                                         return func.apply( this );
    92                                                 },
     92                                                validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
    9393                                                setup : function( element )
    9494                                                {
    95                                                         this.setValue( element.getAttribute( 'rows' ) );
     95                                                        var ieDefault = 2;
     96                                                        var value = element.getAttribute( 'rows' );
     97                                                        this.setValue( ( CKEDITOR.env.ie && ( value == ieDefault ) ? '' : value ) || '' );
    9698                                                },
    9799                                                commit : function( element )
    98100                                                {
    99                                                         if ( this.getValue() || this.isChanged() )
     101                                                        if ( this.getValue() )
    100102                                                                element.setAttribute( 'rows', this.getValue() );
     103                                                        else
     104                                                                element.removeAttribute( 'rows' );
    101105                                                }
    102106                                        }
    103107                                ]
  • _source/plugins/forms/dialogs/radio.js

     
    2929                                element = editor.document.createElement( 'input' );
    3030                                element.setAttribute( 'type', 'radio' );
    3131                        }
    32                         this.commitContent( element );
    3332
    3433                        if ( isInsertMode )
    3534                                editor.insertElement( element );
     35                        this.commitContent( { element : element } );
    3636                },
    3737                contents : [
    3838                        {
     
    4141                                title : editor.lang.checkboxAndRadio.radioTitle,
    4242                                elements : [
    4343                                        {
    44                                                 id : 'txtName',
     44                                                id : 'name',
    4545                                                type : 'text',
    4646                                                label : editor.lang.common.name,
    4747                                                'default' : '',
    4848                                                accessKey : 'N',
    4949                                                setup : function( element )
    5050                                                {
    51                                                         this.setValue( element.getAttribute( 'name' ) );
    52                                                         this.focus();
     51                                                        this.setValue( element.getAttribute( '_cke_saved_name' ) || '' );
    5352                                                },
    54                                                 commit : function( element )
     53                                                commit : function( data )
    5554                                                {
    56                                                         if ( this.getValue() || this.isChanged() )
    57                                                                 element.setAttribute( 'name', this.getValue() );
     55                                                        var element = data.element;
     56
     57                                                        if ( this.getValue() )
     58                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     59                                                        else
     60                                                        {
     61                                                                element.removeAttribute( '_cke_saved_name' );
     62                                                                element.removeAttribute( 'name' );
     63                                                        }
    5864                                                }
    5965                                        },
    6066                                        {
    61                                                 id : 'txtValue',
     67                                                id : 'value',
    6268                                                type : 'text',
    6369                                                label : editor.lang.checkboxAndRadio.value,
    6470                                                'default' : '',
    6571                                                accessKey : 'V',
    6672                                                setup : function( element )
    6773                                                {
    68                                                         this.setValue( element.getAttribute( 'value' ) );
     74                                                        this.setValue( element.getAttribute( 'value' ) || '' );
    6975                                                },
    70                                                 commit : function( element )
     76                                                commit : function( data )
    7177                                                {
    72                                                         if ( this.getValue() || this.isChanged() )
     78                                                        var element = data.element;
     79
     80                                                        if ( this.getValue() )
    7381                                                                element.setAttribute( 'value', this.getValue() );
     82                                                        else
     83                                                                element.removeAttribute( 'value' );
    7484                                                }
    7585                                        },
    7686                                        {
    77                                                 id : 'cmbSelected',
     87                                                id : 'checked',
    7888                                                type : 'checkbox',
    7989                                                label : editor.lang.checkboxAndRadio.selected,
    8090                                                'default' : '',
     
    8494                                                {
    8595                                                        this.setValue( element.getAttribute( 'checked' ) );
    8696                                                },
    87                                                 commit : function( element )
     97                                                commit : function( data )
    8898                                                {
    89                                                         if ( this.getValue() || this.isChanged() )
    90                                                                 element.setAttribute( 'checked', this.getValue() );
     99                                                        var element = data.element;
     100
     101                                                        if ( !CKEDITOR.env.ie )
     102                                                        {
     103                                                                if ( this.getValue() )
     104                                                                        element.setAttribute( 'checked', 'checked' );
     105                                                                else
     106                                                                        element.removeAttribute( 'checked' );
     107                                                        }
     108                                                        else
     109                                                        {
     110                                                                var isElementChecked = element.getAttribute( 'checked' );
     111                                                                var isChecked = !!this.getValue();
     112
     113                                                                if ( isElementChecked != isChecked )
     114                                                                {
     115                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="radio"'
     116                                                                                        + ( isChecked ? ' checked="checked"' : '' )
     117                                                                                        + '></input>', editor.document );
     118                                                                        element.copyAttributes( replace, { type : 1, checked : 1 } );
     119                                                                        replace.replace( element );
     120                                                                        editor.getSelection().selectElement( replace );
     121                                                                        data.element = replace;
     122                                                                }
     123                                                        }
    91124                                                }
    92125                                        }
    93126                                ]
  • _source/plugins/forms/dialogs/hiddenfield.js

     
    2929                                element = editor.document.createElement( 'input' );
    3030                                element.setAttribute( 'type', 'hidden' );
    3131                        }
    32                         this.commitContent( element );
    33 
     32                       
    3433                        if ( isInsertMode )
    3534                                editor.insertElement( element );
     35                        this.commitContent( element );
    3636                },
    3737                contents : [
    3838                        {
     
    4141                                title : editor.lang.hidden.title,
    4242                                elements : [
    4343                                        {
    44                                                 id : 'txtName',
     44                                                id : '_cke_saved_name',
    4545                                                type : 'text',
    4646                                                label : editor.lang.hidden.name,
    4747                                                'default' : '',
    4848                                                accessKey : 'N',
    4949                                                setup : function( element )
    5050                                                {
    51                                                         this.setValue( element.getAttribute( 'name' ) );
    52                                                         this.focus();
     51                                                        this.setValue(
     52                                                                        element.getAttribute( '_cke_saved_name' ) ||
     53                                                                        element.getAttribute( 'name' ) ||
     54                                                                        '' );
    5355                                                },
    5456                                                commit : function( element )
    5557                                                {
    56                                                         if ( this.getValue() || this.isChanged() )
    57                                                                 element.setAttribute( 'name', this.getValue() );
     58                                                        if ( this.getValue() )
     59                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     60                                                        else
     61                                                        {
     62                                                                element.removeAttribute( '_cke_saved_name' );
     63                                                                element.removeAttribute( 'name' );
     64                                                        }
    5865                                                }
    5966                                        },
    6067                                        {
    61                                                 id : 'txtValue',
     68                                                id : 'value',
    6269                                                type : 'text',
    6370                                                label : editor.lang.hidden.value,
    6471                                                'default' : '',
    6572                                                accessKey : 'V',
    6673                                                setup : function( element )
    6774                                                {
    68                                                         this.setValue( element.getAttribute( 'value' ) );
     75                                                        this.setValue( element.getAttribute( 'value' ) || '' );
    6976                                                },
    7077                                                commit : function( element )
    7178                                                {
    72                                                         if ( this.getValue() || this.isChanged() )
     79                                                        if ( this.getValue() )
    7380                                                                element.setAttribute( 'value', this.getValue() );
     81                                                        else
     82                                                                element.removeAttribute( 'value' );
    7483                                                }
    7584                                        }
    7685                                ]
  • _source/plugins/forms/dialogs/select.js

     
    132132        return {
    133133                title : editor.lang.select.title,
    134134                minWidth : 375,
    135                 minHeight : 270,
     135                minHeight : 290,
    136136                onShow : function()
    137137                {
    138138                        this.setupContent( 'clear' );
     
    142142                                this._element = element;
    143143                                this.setupContent( element.getName(), element );
    144144
    145                                 //Load Options into dialog.
     145                                // Load Options into dialog.
    146146                                var objOptions = getOptions( element );
    147147                                for ( var i = 0 ; i < objOptions.count() ; i++ )
    148148                                        this.setupContent( 'option', objOptions.getItem( i ) );
     
    180180                                                style : 'width:350px',
    181181                                                setup : function( name, element )
    182182                                                {
    183                                                         if ( name == 'select' )
    184                                                         {
    185                                                                 this.setValue( element.getAttribute( 'name' ) );
    186                                                                 this.focus();
    187                                                         }
     183                                                        if ( name == 'clear' )
     184                                                                this.setValue( '' );
     185                                                        else if ( name == 'select' )
     186                                                                this.setValue( element.getAttribute( '_cke_saved_name' ) || '' );
    188187                                                },
    189188                                                commit : function( element )
    190189                                                {
    191                                                         if ( this.getValue() || this.isChanged() )
    192                                                                 element.setAttribute( 'name', this.getValue() );
     190                                                        if ( this.getValue() )
     191                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     192                                                        else
     193                                                        {
     194                                                                element.removeAttribute( '_cke_saved_name' ) ;
     195                                                                element.removeAttribute( 'name' );
     196                                                        }
    193197                                                }
    194198                                        },
    195199                                        {
     
    200204                                                label : editor.lang.select.value,
    201205                                                style : 'width:350px',
    202206                                                'default' : '',
    203                                                 readonly : true,                // TODO: make it readonly somehow.
    204                                                 disabled : true
     207                                                onLoad : function()
     208                                                {
     209                                                        this.getInputElement().setAttribute( 'readOnly', true );
     210                                                },
     211                                                setup : function( name, element )
     212                                                {
     213                                                        if ( name == 'clear' )
     214                                                                this.setValue( '' );
     215                                                        else if ( name == 'option' && element.getAttribute( 'selected' ) )
     216                                                                this.setValue( element.$.value );
     217                                                }
    205218                                        },
    206219                                        {
    207220                                                type : 'hbox',
     
    226239                                                                setup : function( name, element )
    227240                                                                {
    228241                                                                        if ( name == 'select' )
    229                                                                                 this.setValue( element.getAttribute( 'size' ) );
     242                                                                                this.setValue( element.getAttribute( 'size' ) || '' );
    230243                                                                },
    231244                                                                commit : function( element )
    232245                                                                {
    233                                                                         if ( this.getValue() || this.isChanged() )
     246                                                                        if ( this.getValue() )
    234247                                                                                element.setAttribute( 'size', this.getValue() );
     248                                                                        else
     249                                                                                element.removeAttribute( 'size' );
    235250                                                                }
    236251                                                        },
    237252                                                        {
     
    504519                                                                },
    505520                                                                commit : function( element )
    506521                                                                {
    507                                                                         if ( this.getValue() || this.isChanged() )
     522                                                                        if ( this.getValue() )
    508523                                                                                element.setAttribute( 'multiple', this.getValue() );
     524                                                                        else
     525                                                                                element.removeAttribute( 'multiple' );
    509526                                                                }
    510527                                                        }
    511528                                                ]
  • _source/plugins/forms/dialogs/form.js

     
    44*/
    55CKEDITOR.dialog.add( 'form', function( editor )
    66{
     7        var autoAttributes =
     8        {
     9                action : 1,
     10                id : 1,
     11                method : 1,
     12                encoding : 1,
     13                target : 1
     14        };
     15
    716        return {
    817                title : editor.lang.form.title,
    918                minWidth : 350,
    1019                minHeight : 190,
    1120                onShow : function()
    1221                {
    13                         var element = this.getParentEditor().getSelection().getSelectedElement();
    14                         if ( element && element.getName() == "form" )
     22                        var element = this.getParentEditor().getSelection().getStartElement();
     23                        var form = element && element.getAscendant( 'form', true );
     24                        if ( form )
    1525                        {
    16                                 this._element = element;
    17                                 this.setupContent( element );
     26                                this._element = form;
     27                                this.setupContent( form );
    1828                        }
    1929                },
    2030                onOk : function()
     
    2939                                element = editor.document.createElement( 'form' );
    3040                                element.append( editor.document.createElement( 'br' ) );
    3141                        }
    32                         this.commitContent( element );
    3342
    3443                        if ( isInsertMode )
    3544                                editor.insertElement( element );
     45                        this.commitContent( element );
    3646                },
     47                onLoad : function()
     48                {
     49                        function autoSetup( element )
     50                        {
     51                                this.setValue( element.getAttribute( this.id ) || '' );
     52                        }
     53
     54                        function autoCommit( element )
     55                        {
     56                                if ( this.getValue() )
     57                                        element.setAttribute( this.id, this.getValue() );
     58                                else
     59                                        element.removeAttribute( this.id );
     60                        }
     61
     62                        this.foreach( function( contentObj )
     63                                {
     64                                        if ( autoAttributes[ contentObj.id ] )
     65                                        {
     66                                                contentObj.setup = autoSetup;
     67                                                contentObj.commit = autoCommit;
     68                                        }
     69                                } );
     70                },
    3771                contents : [
    3872                        {
    3973                                id : 'info',
     
    4882                                                accessKey : 'N',
    4983                                                setup : function( element )
    5084                                                {
    51                                                         this.setValue( element.getAttribute( 'name' ) );
    52                                                         this.focus();
     85                                                        this.setValue( element.getAttribute( '_cke_saved_name' ) ||
     86                                                                        element.getAttribute( 'name' ) ||
     87                                                                        '' );
    5388                                                },
    5489                                                commit : function( element )
    5590                                                {
    56                                                         if ( this.getValue() || this.isChanged() )
    57                                                                 element.setAttribute( 'name', this.getValue() );
     91                                                        if ( this.getValue() )
     92                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     93                                                        else
     94                                                        {
     95                                                                element.removeAttribute( '_cke_saved_name' );
     96                                                                element.removeAttribute( 'name' );
     97                                                        }
    5898                                                }
    5999                                        },
    60100                                        {
    61                                                 id : 'txtAction',
     101                                                id : 'action',
    62102                                                type : 'text',
    63103                                                label : editor.lang.form.action,
    64104                                                'default' : '',
    65                                                 accessKey : 'A',
    66                                                 setup : function( element )
    67                                                 {
    68                                                         this.setValue( element.getAttribute( 'action' ) );
    69                                                 },
    70                                                 commit : function( element )
    71                                                 {
    72                                                         if ( this.getValue() || this.isChanged() )
    73                                                                 element.setAttribute( 'action', this.getValue() );
    74                                                 }
     105                                                accessKey : 'A'
    75106                                        },
    76107                                        {
    77108                                                type : 'hbox',
     
    79110                                                children :
    80111                                                [
    81112                                                        {
    82                                                                 id : 'txtId',
     113                                                                id : 'id',
    83114                                                                type : 'text',
    84115                                                                label : editor.lang.common.id,
    85116                                                                'default' : '',
    86                                                                 accessKey : 'I',
    87                                                                 setup : function( element )
    88                                                                 {
    89                                                                         this.setValue( element.getAttribute( 'id' ) );
    90                                                                 },
    91                                                                 commit : function( element )
    92                                                                 {
    93                                                                         if ( this.getValue() || this.isChanged() )
    94                                                                                 element.setAttribute( 'id', this.getValue() );
    95                                                                 }
     117                                                                accessKey : 'I'
    96118                                                        },
    97119                                                        {
    98                                                                 id : 'cmbEncoding',
     120                                                                id : 'encoding',
    99121                                                                type : 'select',
    100122                                                                label : editor.lang.form.encoding,
    101123                                                                style : 'width:100%',
     
    107129                                                                        [ 'text/plain' ],
    108130                                                                        [ 'multipart/form-data' ],
    109131                                                                        [ 'application/x-www-form-urlencoded' ]
    110                                                                 ],
    111                                                                 setup : function( element )
    112                                                                 {
    113                                                                         this.setValue( element.getAttribute( 'encoding' ) );
    114                                                                 },
    115                                                                 commit : function( element )
    116                                                                 {
    117                                                                         if ( this.getValue() || this.isChanged() )
    118                                                                                 element.setAttribute( 'encoding', this.getValue() );
    119                                                                 }
     132                                                                ]
    120133                                                        }
    121134                                                ]
    122135                                        },
     
    126139                                                children :
    127140                                                [
    128141                                                        {
    129                                                                 id : 'cmbTarget',
     142                                                                id : 'target',
    130143                                                                type : 'select',
    131144                                                                label : editor.lang.form.target,
    132145                                                                style : 'width:100%',
     
    139152                                                                        [ editor.lang.form.targetTop, '_top' ],
    140153                                                                        [ editor.lang.form.targetSelf, '_self' ],
    141154                                                                        [ editor.lang.form.targetParent, '_parent' ]
    142                                                                 ],
    143                                                                 setup : function( element )
    144                                                                 {
    145                                                                         this.setValue( element.getAttribute( 'target' ) );
    146                                                                 },
    147                                                                 commit : function( element )
    148                                                                 {
    149                                                                         if ( this.getValue() || this.isChanged() )
    150                                                                                 element.setAttribute( 'target', this.getValue() );
    151                                                                 }
     155                                                                ]
    152156                                                        },
    153157                                                        {
    154                                                                 id : 'cmbMethod',
     158                                                                id : 'method',
    155159                                                                type : 'select',
    156160                                                                label : editor.lang.form.method,
    157161                                                                accessKey : 'M',
     
    160164                                                                [
    161165                                                                        [ 'GET', 'get' ],
    162166                                                                        [ 'POST', 'post' ]
    163                                                                 ],
    164                                                                 setup : function( element )
    165                                                                 {
    166                                                                         this.setValue( element.getAttribute( 'method' ) );
    167                                                                 },
    168                                                                 commit : function( element )
    169                                                                 {
    170                                                                         element.setAttribute( 'method', this.getValue() );
    171                                                                 }
     167                                                                ]
    172168                                                        }
    173169                                                ]
    174170                                        }
  • _source/core/dom/element.js

     
    421421                                                        return tabIndex;
    422422                                                        break;
    423423
     424                                                case 'checked':
     425                                                        return this.$.checked;
     426                                                        break;
     427
    424428                                                case 'style':
    425429                                                        // IE does not return inline styles via getAttribute(). See #2947.
    426430                                                        return this.$.style.cssText;
     
    828832                        }
    829833                },
    830834
    831                 copyAttributes : function( target, skip )
    832                 {
    833                         skip || ( skip = {} );
    834                         var attributes = this.$.attributes;
    835 
    836                         for ( var n = 0 ; n < attributes.length ; n++ )
    837                         {
    838                                 var attr = attributes[n];
    839 
    840                                 if ( attr.specified )
    841                                 {
    842                                         var attrName = attr.nodeName;
    843                                         if ( attrName in skip )
    844                                                 continue;
    845 
    846                                         var attrValue = this.getAttribute( attrName );
    847                                         if ( !attrValue )
    848                                                 attrValue = attr.nodeValue;
    849 
    850                                         target.setAttribute( attrName, attrValue );
    851                                 }
    852                         }
    853 
    854                         if ( this.$.style.cssText !== '' )
    855                                 target.$.style.cssText = this.$.style.cssText;
    856                 },
    857 
    858835                /**
    859836                 * Shows this element (display it).
    860837                 * @example
     
    12781255                        {
    12791256                                var attribute = attributes[n];
    12801257
    1281                                 if ( attribute.specified )
     1258                                // IE BUG: value attribute is never specified even if it exists.
     1259                                if ( attribute.specified ||
     1260                                  ( CKEDITOR.env.ie && attribute.nodeValue && attribute.nodeName.toLowerCase() == 'value' ) )
    12821261                                {
    12831262                                        var attrName = attribute.nodeName;
    12841263                                        // We can set the type only once, so do it with the proper value, not copying it.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy