Ticket #5500: 5500_3.patch

File 5500_3.patch, 4.9 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/element.js

     
    452452                                                }
    453453
    454454                                                case 'hspace':
    455                                                         return this.$.hspace;
     455                                                case 'value':
     456                                                        return this.$[ name ];
    456457
    457458                                                case 'style':
    458459                                                        // IE does not return inline styles via getAttribute(). See #2947.
  • _source/plugins/forms/plugin.js

     
    275275                                        return !!this.$.checked;
    276276                                case 'value' :
    277277                                        var type = this.getAttribute( 'type' );
    278                                         if ( type == 'checkbox' || type == 'radio' )
    279                                                 return this.$.value != 'on';
    280                                         break;
    281                                 default:
     278                                        return type == 'checkbox' || type == 'radio' ? this.$.value != 'on' : this.$.value;
    282279                        }
    283280                }
    284281
  • _source/plugins/forms/dialogs/button.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
    55CKEDITOR.dialog.add( 'button', function( editor )
    66{
     7        function commitAttributes( element )
     8        {
     9                var val = this.getValue();
     10                if ( val )
     11                {
     12                        element.attributes[ this.id ] = val;
     13                        if ( this.id == 'name' )
     14                                element.attributes[ 'data-cke-saved-name' ] = val;
     15                }
     16                else
     17                {
     18                        delete element.attributes[ this.id ];
     19                        if ( this.id == 'name' )
     20                                delete element.attributes[ 'data-cke-saved-name' ];
     21                }
     22        }
     23
    724        return {
    825                title : editor.lang.button.title,
    926                minWidth : 350,
     
    2441                },
    2542                onOk : function()
    2643                {
    27                         var editor,
     44                        var editor = this.getParentEditor(),
    2845                                element = this.button,
    2946                                isInsertMode = !element;
    3047
     48                        var fake = element ? CKEDITOR.htmlParser.fragment.fromHtml( element.getOuterHtml() ).children[ 0 ]
     49                                        : new CKEDITOR.htmlParser.element( 'input' );
     50                        this.commitContent( fake );
     51
     52                        var writer = new CKEDITOR.htmlParser.basicWriter();
     53                        fake.writeHtml( writer );
     54                        var newElement = CKEDITOR.dom.element.createFromHtml( writer.getHtml(), editor.document );
     55
    3156                        if ( isInsertMode )
     57                                editor.insertElement( newElement );
     58                        else
    3259                        {
    33                                 editor = this.getParentEditor();
    34                                 element = editor.document.createElement( 'input' );
     60                                newElement.replace( element );
     61                                editor.getSelection().selectElement( newElement );
    3562                        }
    36 
    37                         if ( isInsertMode )
    38                                 editor.insertElement( element );
    39                         this.commitContent( { element : element } );
    4063                },
    4164                contents : [
    4265                        {
     
    4568                                title : editor.lang.button.title,
    4669                                elements : [
    4770                                        {
    48                                                 id : '_cke_saved_name',
     71                                                id : 'name',
    4972                                                type : 'text',
    5073                                                label : editor.lang.common.name,
    5174                                                'default' : '',
     
    5679                                                                        element.getAttribute( 'name' ) ||
    5780                                                                        '' );
    5881                                                },
    59                                                 commit : function( data )
    60                                                 {
    61                                                         var element = data.element;
    62 
    63                                                         if ( this.getValue() )
    64                                                                 element.data( 'cke-saved-name', this.getValue() );
    65                                                         else
    66                                                         {
    67                                                                 element.data( 'cke-saved-name', false );
    68                                                                 element.removeAttribute( 'name' );
    69                                                         }
    70                                                 }
     82                                                commit : commitAttributes
    7183                                        },
    7284                                        {
    7385                                                id : 'value',
     
    7991                                                {
    8092                                                        this.setValue( element.getAttribute( 'value' ) || '' );
    8193                                                },
    82                                                 commit : function( data )
    83                                                 {
    84                                                         var element = data.element;
    85 
    86                                                         if ( this.getValue() )
    87                                                                 element.setAttribute( 'value', this.getValue() );
    88                                                         else
    89                                                                 element.removeAttribute( 'value' );
    90                                                 }
     94                                                commit : commitAttributes
    9195                                        },
    9296                                        {
    9397                                                id : 'type',
     
    105109                                                {
    106110                                                        this.setValue( element.getAttribute( 'type' ) || '' );
    107111                                                },
    108                                                 commit : function( data )
    109                                                 {
    110                                                         var element = data.element;
    111 
    112                                                         if ( CKEDITOR.env.ie )
    113                                                         {
    114                                                                 var elementType = element.getAttribute( 'type' );
    115                                                                 var currentType = this.getValue();
    116 
    117                                                                 if ( currentType != elementType )
    118                                                                 {
    119                                                                         var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + currentType +
    120                                                                                 '"></input>', editor.document );
    121                                                                         element.copyAttributes( replace, { type : 1 } );
    122                                                                         replace.replace( element );
    123                                                                         editor.getSelection().selectElement( replace );
    124                                                                         data.element = replace;
    125                                                                 }
    126                                                         }
    127                                                         else
    128                                                                 element.setAttribute( 'type', this.getValue() );
    129                                                 }
    130                                         }
     112                                                commit : commitAttributes
     113                                        }
    131114                                ]
    132115                        }
    133116                ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy