Ticket #5418: 5418_9.patch

File 5418_9.patch, 15.2 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/core/config.js

     
    243243         * @type String
    244244         * @example
    245245         */
    246         plugins : 'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     246        plugins : 'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,dialogadvtab,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    247247
    248248        /**
    249249         * List of additional plugins to be loaded. This is a tool setting which
  • _source/lang/en.js

     
    105105                targetTop               : 'Topmost Window (_top)',
    106106                targetSelf              : 'Same Window (_self)',
    107107                targetParent    : 'Parent Window (_parent)',
     108                advanced                : 'Advanced',
     109                langDirLTR              : 'Left to Right (LTR)',
     110                langDirRTL              : 'Right to Left (RTL)',
     111                styles                  : 'Style',
     112                cssClasses              : 'Stylesheet Classes',
    108113
    109114                // Put the voice-only part of the label in the span.
    110115                unavailable             : '%1<span class="cke_accessibility">, unavailable</span>'
  • _source/plugins/dialog/plugin.js

     
    472472
    473473                // Insert the tabs and contents.
    474474                for ( var i = 0 ; i < definition.contents.length ; i++ )
    475                         this.addPage( definition.contents[i] );
     475                {
     476                        var page = definition.contents[i];
     477                        page && this.addPage( page );
     478                }
    476479
    477480                this.parts['tabs'].on( 'click', function( evt )
    478481                                {
     
    13861389                // Transform the contents entries in contentObjects.
    13871390                var contents = dialogDefinition.contents;
    13881391                for ( var i = 0, content ; ( content = contents[i] ) ; i++ )
    1389                         contents[ i ] = new contentObject( dialog, content );
     1392                        contents[ i ] = content && new contentObject( dialog, content );
    13901393
    13911394                CKEDITOR.tools.extend( this, dialogDefinition );
    13921395        };
  • _source/plugins/dialogadvtab/plugin.js

    Property changes on: _source\plugins\dialogadvtab
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.ckeditor.com/ticket/%BUGID%
    Added: webviewer:pathrevision
       + http://dev.fckeditor.net/browser/%PATH%?rev=%REVISION% 
    Added: webviewer:revision
       + http://dev.fckeditor.net/changeset/%REVISION%
    Added: bugtraq:logregex
       + (?:ticket: *|#)(\d+) *(?:, *(\d+))*
    
    
     
     1/*
     2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6(function()
     7{
     8       
     9function setupAdvParams( element )
     10{
     11        var attrName = this.att;
     12
     13        var value = element && element.hasAttribute( attrName ) && element.getAttribute( attrName ) || '';
     14
     15        if ( value !== undefined )
     16                this.setValue( value );
     17}
     18
     19function commitAdvParams()
     20{
     21        // Dialogs may use different parameters in the commit list, so, by
     22        // definition, we take the first CKEDITOR.dom.element available.
     23        var element;
     24       
     25        for ( var i = 0 ; i < arguments.length ; i++ )
     26        {
     27                if ( arguments[ i ] instanceof CKEDITOR.dom.element )
     28                {
     29                        element = arguments[ i ];
     30                        break;
     31                }
     32        }
     33
     34        if ( element )
     35        {
     36                var attrName = this.att,
     37                        value = this.getValue();
     38
     39                if ( value )
     40                        element.setAttribute( attrName, value );
     41                else
     42                        element.removeAttribute( attrName, value );
     43        }
     44}
     45
     46var isUpdating;
     47
     48CKEDITOR.plugins.add( 'dialogadvtab',
     49{
     50        /**
     51         *
     52         * @param tabConfig
     53         * id, dir, classes, styles
     54         */
     55        createAdvancedTab : function( editor, tabConfig )
     56        {
     57                if ( !tabConfig )
     58                        tabConfig = { id:1, dir:1, classes:1, styles:1 };
     59
     60                var lang = editor.lang.common;
     61
     62                var result =
     63                {
     64                        id : 'advanced',
     65                        label : lang.advanced,
     66                        title : lang.advanced,
     67                        elements :
     68                                [
     69                                        {
     70                                                type : 'vbox',
     71                                                padding : 1,
     72                                                children : []
     73                                        }
     74                                ]
     75                };
     76
     77                var contents = [];
     78
     79                if ( tabConfig.id || tabConfig.dir )
     80                {
     81                        if ( tabConfig.id )
     82                        {
     83                                contents.push(
     84                                        {
     85                                                id : 'advId',
     86                                                att : 'id',
     87                                                type : 'text',
     88                                                label : lang.id,
     89                                                setup : setupAdvParams,
     90                                                commit : commitAdvParams
     91                                        });
     92                        }
     93
     94                        if ( tabConfig.dir )
     95                        {
     96                                contents.push(
     97                                        {
     98                                                id : 'advLangDir',
     99                                                att : 'dir',
     100                                                type : 'select',
     101                                                label : lang.langDir,
     102                                                'default' : '',
     103                                                style : 'width:110px',
     104                                                items :
     105                                                [
     106                                                        [ lang.notSet, '' ],
     107                                                        [ lang.langDirLTR, 'ltr' ],
     108                                                        [ lang.langDirRTL, 'rtl' ]
     109                                                ],
     110                                                setup : setupAdvParams,
     111                                                commit : commitAdvParams
     112                                        });
     113                        }
     114
     115                        result.elements[ 0 ].children.push(
     116                                {
     117                                        type : 'hbox',
     118                                        widths : [ '50%', '50%' ],
     119                                        children : [].concat( contents )
     120                                });
     121                }
     122
     123                if ( tabConfig.styles || tabConfig.classes )
     124                {
     125                        contents = [];
     126
     127                        if ( tabConfig.id )
     128                        {
     129                                contents.push(
     130                                        {
     131                                                id : 'advStyles',
     132                                                att : 'style',
     133                                                type : 'text',
     134                                                label : lang.styles,
     135                                                'default' : '',
     136                                               
     137                                                onChange : function(){},
     138
     139                                                getStyle : function( name, defaultValue )
     140                                                {
     141                                                        var match = this.getValue().match( new RegExp( name + '\\s*:\s*([^;]*)', 'i') );
     142                                                        return match ? match[ 1 ] : defaultValue;
     143                                                },
     144                                               
     145                                                updateStyle : function( name, value )
     146                                                {
     147                                                        if ( isUpdating )
     148                                                                return;
     149                                                       
     150                                                        // Flag to avoid recursion.
     151                                                        isUpdating = 1;
     152
     153                                                        var styles = this.getValue();
     154
     155                                                        // Remove the current value.
     156                                                        if ( styles )
     157                                                        {
     158                                                                styles = styles
     159                                                                        .replace( new RegExp( '\\s*' + name + '\s*:[^;]*(?:$|;\s*)', 'i' ), '' )
     160                                                                        .replace( /^[;\s]+/, '' )
     161                                                                        .replace( /\s+$/, '' );
     162                                                        }
     163
     164                                                        if ( value )
     165                                                        {
     166                                                                styles && !(/;\s*$/).test( styles ) && ( styles += '; ' );
     167                                                                styles += name + ': ' + value;
     168                                                        }
     169                                                       
     170                                                        this.setValue( styles );
     171                                                       
     172                                                        isUpdating = 0;
     173                                                },
     174
     175                                                setup : setupAdvParams,
     176
     177                                                commit : commitAdvParams
     178
     179                                        });
     180                        }
     181
     182                        if ( tabConfig.classes )
     183                        {
     184                                contents.push(
     185                                        {
     186                                                type : 'hbox',
     187                                                widths : [ '45%', '55%' ],
     188                                                children :
     189                                                [
     190                                                        {
     191                                                                id : 'advCSSClasses',
     192                                                                att : 'class',
     193                                                                type : 'text',
     194                                                                label : lang.cssClasses,
     195                                                                'default' : '',
     196                                                                setup : setupAdvParams,
     197                                                                commit : commitAdvParams
     198
     199                                                        }
     200                                                ]
     201                                        });
     202                        }
     203
     204                        result.elements[ 0 ].children.push(
     205                                {
     206                                        type : 'hbox',
     207                                        widths : [ '50%', '50%' ],
     208                                        children : [].concat( contents )
     209                                });
     210                }
     211
     212                return result;
     213        }
     214});
     215
     216})();
  • _source/plugins/filebrowser/plugin.js

     
    388388                // Associate filebrowser to elements with 'filebrowser' attribute.
    389389                for ( var i in definition.contents )
    390390                {
    391                         element = definition.contents[ i ] ;
    392                         attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
    393                         if ( element.hidden && element.filebrowser )
     391                        if ( ( element = definition.contents[ i ] ) )
    394392                        {
    395                                 element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
     393                                attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
     394                                if ( element.hidden && element.filebrowser )
     395                                {
     396                                        element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
     397                                }
    396398                        }
    397399                }
    398400        } );
  • _source/plugins/showborders/plugin.js

     
    153153                                                selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName );
    154154                                        };
    155155                        } );
     156
     157                        var advTab = dialogDefinition.getContents( 'advanced' ),
     158                                classField = advTab && advTab.get( 'advCSSClasses' );
     159
     160                        if ( classField )
     161                        {
     162                                classField.setup = CKEDITOR.tools.override( classField.setup, function( originalSetup )
     163                                        {
     164                                                return function()
     165                                                        {
     166                                                                originalSetup.apply( this, arguments );
     167                                                                this.setValue( this.getValue().replace( /cke_show_border/, '' ) );
     168                                                        };
     169                                        });
     170
     171                                classField.commit = CKEDITOR.tools.override( classField.commit, function( originalCommit )
     172                                        {
     173                                                return function( data, element )
     174                                                        {
     175                                                                originalCommit.apply( this, arguments );
     176                                                               
     177                                                                if ( !parseInt( element.getAttribute( 'border' ), 10 ) )
     178                                                                        element.addClass( 'cke_show_border' );
     179                                                        };
     180                                        });
     181                        }
    156182                }
    157183        });
    158184
  • _source/plugins/table/dialogs/table.js

     
    1818
    1919        function tableDialog( editor, command )
    2020        {
    21                 var makeElement = function( name ){ return new CKEDITOR.dom.element( name, editor.document ); };
     21                var makeElement = function( name )
     22                        {
     23                                return new CKEDITOR.dom.element( name, editor.document );
     24                        };
    2225
     26                var dialogadvtab = editor.plugins.dialogadvtab;
     27
    2328                return {
    2429                        title : editor.lang.table.title,
    2530                        minWidth : 310,
    2631                        minHeight : CKEDITOR.env.ie ? 310 : 280,
     32
     33                        onLoad : function()
     34                        {
     35                                var dialog = this,
     36                                        isUpdating;
     37                                       
     38                                var styles = dialog.getContentElement( 'advanced', 'advStyles' );
     39
     40                                if ( styles )
     41                                {
     42                                        styles.on( 'change', function( evt )
     43                                                {
     44                                                        if ( isUpdating )
     45                                                                return;
     46                                                       
     47                                                        // Flag to avoid recursion.
     48                                                        isUpdating = 1;
     49                                                       
     50                                                        // Synchronize width value.
     51                                                        var width = this.getStyle( 'width', '' ),
     52                                                                txtWidth = dialog.getContentElement( 'info', 'txtWidth' ),
     53                                                                cmbWidthType = dialog.getContentElement( 'info', 'cmbWidthType' );
     54
     55                                                                isPx = 1;
     56
     57                                                        if ( width )
     58                                                        {
     59                                                                isPx = ( width.length < 3 || width.substr( width.length - 1 ) != '%' );
     60                                                                width = parseInt( width, 10 );
     61                                                        }
     62
     63                                                        txtWidth && txtWidth.setValue( width );
     64                                                        cmbWidthType && cmbWidthType.setValue( isPx ? 'pixels' : 'percents' );
     65                                                       
     66                                                        // Synchronize height value.
     67                                                        var height = this.getStyle( 'height', '' ),
     68                                                                txtHeight = dialog.getContentElement( 'info', 'txtHeight' );
     69
     70                                                        height && ( height = parseInt( height, 10 ) );
     71                                                        txtHeight && txtHeight.setValue( height );
     72
     73                                                        isUpdating = 0;
     74                                                });
     75                                }
     76                        },
     77
    2778                        onShow : function()
    2879                        {
    2980                                // Detect if there's a selected table.
     
    3384
    3485                                var rowsInput = this.getContentElement( 'info', 'txtRows' ),
    3586                                        colsInput = this.getContentElement( 'info', 'txtCols' ),
    36                                         widthInput = this.getContentElement( 'info', 'txtWidth' );
     87                                        widthInput = this.getContentElement( 'info', 'txtWidth' ),
     88                                        heightInput = this.getContentElement( 'info', 'txtHeight' );
     89
    3790                                if ( command == 'tableProperties' )
    3891                                {
    3992                                        if ( ( selectedTable = editor.getSelection().getSelectedElement() ) )
     
    70123                                        colsInput && colsInput.enable();
    71124                                        rowsInput && rowsInput.select();
    72125                                }
     126
     127                                // Call the onChange method for the widht and height fields so
     128                                // they get reflected into the Advanced tab.
     129                                widthInput && widthInput.onChange();
     130                                heightInput && heightInput.onChange();
    73131                        },
    74132                        onOk : function()
    75133                        {
     
    378436                                                                                                        id : 'txtWidth',
    379437                                                                                                        style : 'width:5em',
    380438                                                                                                        label : editor.lang.table.width,
    381                                                                                                         'default' : 200,
     439                                                                                                        'default' : 500,
    382440                                                                                                        validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidWidth ),
    383441
    384442                                                                                                        // Extra labelling of width unit type.
     
    392450                                                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
    393451                                                                                                        },
    394452
     453                                                                                                        onChange : function()
     454                                                                                                        {
     455                                                                                                                var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' );
     456
     457                                                                                                                if ( styles )
     458                                                                                                                {
     459                                                                                                                        var value = this.getValue();
     460                                                                                                                       
     461                                                                                                                        if ( value )
     462                                                                                                                                value += this.getDialog().getContentElement( 'info', 'cmbWidthType' ).getValue() == 'percents' ? '%' : 'px';
     463
     464                                                                                                                        styles.updateStyle( 'width', value );
     465                                                                                                                }
     466                                                                                                        },
     467
    395468                                                                                                        setup : function( selectedTable )
    396469                                                                                                        {
    397470                                                                                                                var widthMatch = widthPattern.exec( selectedTable.$.style.width );
     
    419492                                                                                                                if ( widthMatch )
    420493                                                                                                                        this.setValue( widthMatch[2] == 'px' ? 'pixels' : 'percents' );
    421494                                                                                                        },
     495                                                                                                        onChange : function()
     496                                                                                                        {
     497                                                                                                                this.getDialog().getContentElement( 'info', 'txtWidth' ).onChange();
     498                                                                                                        },
    422499                                                                                                        commit : commitValue
    423500                                                                                                }
    424501                                                                                        ]
     
    447524                                                                                                                inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
    448525                                                                                                        },
    449526
     527                                                                                                        onChange : function()
     528                                                                                                        {
     529                                                                                                                var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' );
     530                                                                                                               
     531                                                                                                                if ( styles )
     532                                                                                                                {
     533                                                                                                                        var value = this.getValue();
     534                                                                                                                        styles.updateStyle( 'height', value && ( value + 'px' ) );
     535                                                                                                                }
     536                                                                                                        },
     537
    450538                                                                                                        setup : function( selectedTable )
    451539                                                                                                        {
    452540                                                                                                                var heightMatch = heightPattern.exec( selectedTable.$.style.height );
     
    580668                                                        ]
    581669                                                }
    582670                                        ]
    583                                 }
     671                                },
     672                                dialogadvtab && dialogadvtab.createAdvancedTab( editor )
    584673                        ]
    585674                };
    586675        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy