Ticket #4056: 4056.patch

File 4056.patch, 5.1 KB (added by Minh Nguyen, 14 years ago)
  • _source/lang/en.js

     
    679679
    680680        fakeobjects :
    681681        {
    682                 anchor  : 'Anchor',
    683                 flash   : 'Flash Animation',
    684                 div             : 'Page Break',
    685                 unknown : 'Unknown Object'
     682                anchor          : 'Anchor',
     683                hiddenfield     : 'Hidden',
     684                flash           : 'Flash Animation',
     685                div                     : 'Page Break',
     686                unknown         : 'Unknown Object'
    686687        },
    687688
    688689        resize : 'Drag to resize',
  • _source/plugins/forms/dialogs/hiddenfield.js

     
    66{
    77        return {
    88                title : editor.lang.hidden.title,
     9                hiddenField : null,
    910                minWidth : 350,
    1011                minHeight : 110,
    1112                onShow : function()
    1213                {
    1314                        delete this.hiddenField;
    14 
    15                         var element = this.getParentEditor().getSelection().getSelectedElement();
    16                         if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "checkbox" )
     15                        var editor = this.getParentEditor(),
     16                                selection = editor.getSelection();
     17                                element = selection.getSelectedElement();
     18                       
     19                        if ( element && element.getAttribute( '_cke_real_element_type' ) && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )
    1720                        {
    1821                                this.hiddenField = element;
    19                                 this.setupContent( element );
     22                                element = editor.restoreRealElement( this.hiddenField );
     23
     24                                this.setValueOf( 'info', '_cke_saved_name', element.getAttribute( 'name' ) || '' );
     25                                this.setValueOf( 'info', 'value', element.getAttribute( 'value' ) || '' );
     26                               
     27                                selection.selectElement( this.hiddenField );
    2028                        }
     29
    2130                },
    2231                onOk : function()
    2332                {
    24                         var editor,
    25                                 element = this.hiddenField,
    26                                 isInsertMode = !element;
    27 
    28                         if ( isInsertMode )
     33                       
     34                        var name = this.getValueOf( 'info', '_cke_saved_name' ),
     35                                value = this.getValueOf( 'info', 'value' ),
     36                                editor = this.getParentEditor(),
     37                                element = CKEDITOR.env.ie ?
     38                                                        editor.document.createElement( '<input name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) :
     39                                                                editor.document.createElement( 'input' );
     40                       
     41                        if (this.hiddenField) {
     42                                this.hiddenField.copyAttributes( element, { name : 1 } );
     43                                this.hiddenField.moveChildren( element );
     44                        }
     45                       
     46                        element.setAttribute( 'name', name );
     47                        element.setAttribute( 'value', value );
     48                        element.setAttribute( 'type', 'hidden');
     49                       
     50                        var fakeElement = editor.createFakeElement( element, 'cke_hidden', 'hiddenfield' );
     51                       
     52                        if ( !this.hiddenField )
     53                                editor.insertElement( fakeElement );
     54                        else
    2955                        {
    30                                 editor = this.getParentEditor();
    31                                 element = editor.document.createElement( 'input' );
    32                                 element.setAttribute( 'type', 'hidden' );
     56                                fakeElement.replace( this.hiddenField );
     57                                editor.getSelection().selectElement( fakeElement );     
    3358                        }
    34 
    35                         if ( isInsertMode )
    36                                 editor.insertElement( element );
    37                         this.commitContent( element );
     59                        return true;
    3860                },
    3961                contents : [
    4062                        {
     
    4769                                                type : 'text',
    4870                                                label : editor.lang.hidden.name,
    4971                                                'default' : '',
    50                                                 accessKey : 'N',
    51                                                 setup : function( element )
    52                                                 {
    53                                                         this.setValue(
    54                                                                         element.getAttribute( '_cke_saved_name' ) ||
    55                                                                         element.getAttribute( 'name' ) ||
    56                                                                         '' );
    57                                                 },
    58                                                 commit : function( element )
    59                                                 {
    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                                                         }
    67                                                 }
     72                                                accessKey : 'N'
    6873                                        },
    6974                                        {
    7075                                                id : 'value',
    7176                                                type : 'text',
    7277                                                label : editor.lang.hidden.value,
    7378                                                'default' : '',
    74                                                 accessKey : 'V',
    75                                                 setup : function( element )
    76                                                 {
    77                                                         this.setValue( element.getAttribute( 'value' ) || '' );
    78                                                 },
    79                                                 commit : function( element )
    80                                                 {
    81                                                         if ( this.getValue() )
    82                                                                 element.setAttribute( 'value', this.getValue() );
    83                                                         else
    84                                                                 element.removeAttribute( 'value' );
    85                                                 }
     79                                                accessKey : 'V'
    8680                                        }
    8781                                ]
    8882                        }
  • _source/plugins/forms/plugin.js

     
    1919                                'border: 1px dotted #FF0000;' +
    2020                                'padding: 2px;' +
    2121                        '}' );
     22               
     23                // Add the CSS styles for hiddenfield placeholders.
     24                editor.addCss(
     25                        'img.cke_hidden' +
     26                        '{' +
     27                                'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/hidden.gif' ) + ');' +
     28                                'background-position: center center;' +
     29                                'background-repeat: no-repeat;' +
     30                                'border: 1px solid #a9a9a9;' +
     31                                'width: 16px;' +
     32                                'height: 16px;' +
     33                        '}\n' );
    2234
    2335                // All buttons use the same code to register. So, to avoid
    2436                // duplications, let's use this tool function.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy