Ticket #4358: 4358_3.patch

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

     
    188188                name            : 'Anchor Name',
    189189                errorName       : 'Please type the anchor name'
    190190        },
    191 
     191       
     192        // List style dialog
     193        list:
     194        {
     195                numberedTitle           : 'Numbered List Properties',
     196                bulletedTitle           : 'Bulleted List Properties',
     197                type                            : 'Type',
     198                start                           : 'Start',
     199                circle                          : 'Circle',
     200                disc                            : 'Disc',
     201                square                          : 'Square',
     202                none                            : 'None',
     203                notset                          : '<not set>',
     204                'default'                       : 'Default',
     205                armenian                        : 'Armenian numbering',
     206                georgian                        : 'Georgian numbering (an, ban, gan, etc.)',
     207                lowerRoman                      : 'Lower Roman (i, ii, iii, iv, v, etc.)',
     208                upperRoman                      : 'Upper Roman (I, II, III, IV, V, etc.)',
     209                lowerAlpha                      : 'Lower Alpha (a, b, c, d, e, etc.)',
     210                upperAlpha                      : 'Upper Alpha (A, B, C, D, E, etc.)',
     211                lowerGreek                      : 'Lower Greek (alpha, beta, gamma, etc.)',
     212                decimal                         : 'Decimal (1, 2, 3, etc.)',
     213                decimalLeadingZero      : 'Decimal leading zero (01, 02, 03, etc.)'
     214        },
     215       
    192216        // Find And Replace Dialog
    193217        findAndReplace :
    194218        {
  • _source/plugins/liststyle/dialogs/liststyle.js

    Property changes on: _source\plugins\liststyle
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.fckeditor.net/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+))*
    
    
    
    Property changes on: _source\plugins\liststyle\dialogs
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.fckeditor.net/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(function()
     2{
     3        function getListElement( editor, listTag )
     4        {
     5                var range;
     6                try { range  = editor.getSelection().getRanges()[ 0 ]; }
     7                catch( e ) { return null; }
     8                               
     9                range.shrink( CKEDITOR.SHRINK_TEXT );
     10                return range.getCommonAncestor().getAscendant( listTag, true );
     11        }
     12       
     13        var mapListStyle = {
     14                'decimal' : 1,
     15                'lower-alpha' : 'a',
     16                'upper-alpha' : 'A',
     17                'lower-roman' : 'i',
     18                'upper-roman' : 'I'
     19        };
     20       
     21        function listStyle( editor, startupPage )
     22        {
     23                if ( startupPage == 'bulletedListStyle' )
     24                {
     25                        return {
     26                                title : editor.lang.list.bulletedTitle,
     27                                minWidth : 300,
     28                                minHeight : 50,
     29                                contents :
     30                                [
     31                                        {
     32                                                elements :
     33                                                [
     34                                                        {
     35                                                                type : 'select',
     36                                                                label : editor.lang.list.type,
     37                                                                id: 'type',
     38                                                                style: 'width: 150px; margin: auto',
     39                                                                items :
     40                                                                [
     41                                                                        [ editor.lang.list.notset, 'notset' ],
     42                                                                        [ editor.lang.list.circle, 'circle' ],
     43                                                                        [ editor.lang.list.disc,  'disc' ],
     44                                                                        [ editor.lang.list.square, 'square' ]
     45                                                                ],
     46                                                                setup : function( element )
     47                                                                {
     48                                                                        var value = element.getStyle( 'list-style-type' ) ||
     49                                                                                                element.getAttribute( 'type' ) ||  'notset';
     50
     51                                                                        this.setValue( value );
     52                                                                },
     53                                                                commit : function( element )
     54                                                                {
     55                                                                        var value = this.getValue();
     56                                                                        if ( value != 'notset' )
     57                                                                        {
     58                                                                                element.setStyle( 'list-style-type', value );
     59                                                                                element.setAttribute( 'type', value );
     60                                                                        }
     61                                                                        else
     62                                                                        {
     63                                                                                element.removeAttribute( 'type' );
     64                                                                                element.removeStyle( 'list-style-type' );
     65                                                                        }
     66                                                                }
     67                                                        }
     68                                                ]
     69                                        }
     70                                ],
     71                                onShow: function()
     72                                {
     73                                        var editor = this.getParentEditor(),
     74                                                element = getListElement( editor, 'ul' );
     75                                       
     76                                        element && this.setupContent( element );
     77                                },
     78                                onOk: function()
     79                                {
     80                                        var editor = this.getParentEditor(),
     81                                                element = getListElement( editor, 'ul' );
     82                                       
     83                                        element && this.commitContent( element );
     84                                }
     85                        }
     86                }
     87                else if ( startupPage == 'numberedListStyle'  )
     88                {
     89                        return {
     90                                title : editor.lang.list.numberedTitle,
     91                                minWidth : 300,
     92                                minHeight : 50,
     93                                contents :
     94                                [
     95                                        {
     96                                                elements :
     97                                                [
     98                                                        {
     99                                                                type : 'hbox',
     100                                                                widths : [ '25%', '75%' ],
     101                                                                children :
     102                                                                [
     103                                                                        {
     104                                                                                label: editor.lang.list.start,
     105                                                                                type: 'text',
     106                                                                                setup : function( element )
     107                                                                                {
     108                                                                                        var value = element.getAttribute( 'start' ) || 1;
     109                                                                                        value && this.setValue( value );
     110                                                                                },
     111                                                                                commit : function( element )
     112                                                                                {
     113                                                                                        element.setAttribute( 'start', this.getValue() );
     114                                                                                }
     115                                                                        },
     116                                                                        {
     117                                                                                type : 'select',
     118                                                                                label : editor.lang.list.type,
     119                                                                                style: 'width: 100%',
     120                                                                                items :
     121                                                                                [
     122                                                                                        [ editor.lang.list.notset, 'notset' ],
     123                                                                                        [ editor.lang.list.armenian, 'armenian' ],
     124                                                                                        [ editor.lang.list.georgian, 'georgian' ],
     125                                                                                        [ editor.lang.list.lowerRoman, 'lower-roman' ],
     126                                                                                        [ editor.lang.list.upperRoman, 'upper-roman' ],
     127                                                                                        [ editor.lang.list.lowerAlpha, 'lower-alpha' ],
     128                                                                                        [ editor.lang.list.upperAlpha, 'upper-alpha' ],
     129                                                                                        [ editor.lang.list.lowerGreek, 'lower-greek' ],
     130                                                                                        [ editor.lang.list.decimal, 'decimal' ],
     131                                                                                        [ editor.lang.list.decimalLeadingZero, 'decimal-leading-zero' ],
     132                                                                                ],
     133                                                                                setup : function( element )
     134                                                                                {
     135                                                                                        var value = element.getStyle( 'list-style-type' ) ||
     136                                                                                                                element.getAttribute( 'type' ) ||  'notset';
     137
     138                                                                                        this.setValue( value );
     139                                                                                },
     140                                                                                commit : function( element )
     141                                                                                {
     142                                                                                        var value = this.getValue();
     143                                                                                        // Reset style.
     144                                                                                        element.removeAttribute( 'type' );
     145                                                                                        element.removeStyle( 'list-style-type' );
     146                                                                                       
     147                                                                                        if ( value != 'notset' )
     148                                                                                                element.setStyle( 'list-style-type', value );
     149                                                                                       
     150                                                                                        if ( value in mapListStyle )
     151                                                                                                element.setAttribute( 'type', mapListStyle[value] );
     152                                                                                       
     153                                                                                }
     154                                                                        }
     155                                                                ]
     156                                                        }
     157                                                ]
     158                                        }
     159                                ],
     160                                onShow: function()
     161                                {
     162                                        var editor = this.getParentEditor(),
     163                                                element = getListElement( editor, 'ol' );
     164
     165                                        element && this.setupContent( element );
     166                                },
     167                                onOk: function()
     168                                {
     169                                        var editor = this.getParentEditor(),
     170                                                element = getListElement( editor, 'ol' );
     171                                       
     172                                        element && this.commitContent( element );
     173                                }
     174                        }
     175                }
     176        };
     177       
     178        CKEDITOR.dialog.add( 'numberedListStyle', function( editor )
     179                {
     180                        return listStyle( editor, 'numberedListStyle' );
     181                });
     182
     183        CKEDITOR.dialog.add( 'bulletedListStyle', function( editor )
     184                {
     185                        return listStyle( editor, 'bulletedListStyle' );
     186                });
     187})();
     188 No newline at end of file
  • _source/plugins/liststyle/plugin.js

     
     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        CKEDITOR.plugins.liststyle =
     9        {
     10                init : function( editor )
     11                {
     12
     13                        editor.addCommand( 'numberedListStyle', new CKEDITOR.dialogCommand( 'numberedListStyle' ) );
     14                        CKEDITOR.dialog.add( 'numberedListStyle', this.path + 'dialogs/liststyle.js' );
     15                        editor.addCommand( 'bulletedListStyle', new CKEDITOR.dialogCommand( 'bulletedListStyle' ) );
     16                        CKEDITOR.dialog.add( 'bulletedListStyle', this.path + 'dialogs/liststyle.js' );
     17
     18                        //Register map group;
     19                        editor.addMenuGroup("list", 108);
     20                        // If the "menu" plugin is loaded, register the menu items.
     21                        if ( editor.addMenuItems )
     22                        {
     23                                editor.addMenuItems(
     24                                        {
     25                                                numberedlist :
     26                                                {
     27                                                        label : editor.lang.list.numberedTitle,
     28                                                        group : 'list',
     29                                                        command: 'numberedListStyle'
     30                                                },
     31                                                bulletedlist :
     32                                                {
     33                                                        label : editor.lang.list.bulletedTitle,
     34                                                        group : 'list',
     35                                                        command: 'bulletedListStyle'
     36                                                }
     37                                        });
     38                        }
     39               
     40                        // If the "contextmenu" plugin is loaded, register the listeners.
     41                        if ( editor.contextMenu )
     42                        {
     43                                editor.contextMenu.addListener( function( element, selection )
     44                                        {
     45                                                if ( !element )
     46                                                        return null;
     47                                               
     48                                                if ( element.getAscendant( 'ol') ) {
     49                                                        return { numberedlist: CKEDITOR.TRISTATE_OFF }
     50                                                }
     51                                                if ( element.getAscendant( 'ul' ) ) {
     52                                                        return { bulletedlist: CKEDITOR.TRISTATE_OFF }
     53                                                }
     54                                        } );
     55                        }
     56                }
     57
     58        };
     59       
     60        CKEDITOR.plugins.add( 'liststyle', CKEDITOR.plugins.liststyle );
     61})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy