Ticket #4415: 4415.patch

File 4415.patch, 53.8 KB (added by Wiktor Walc, 14 years ago)
  • _source/includes/io.js

     
    191191                        }
    192192                },
    193193
    194                 copy : function( sourceLocation, targetLocation )
     194                copy : function( sourceLocation, targetLocation, extraIgnoredPaths )
    195195                {
    196                         if ( CKRELEASER.release.isIgnoredPath( sourceLocation.getAbsolutePath() ) )
     196                        if ( CKRELEASER.release.isIgnoredPath( sourceLocation.getAbsolutePath(), extraIgnoredPaths ) )
    197197                                return;
    198198
    199199                        if ( CKRELEASER.verbose )
     
    209209                                var children = sourceLocation.list();
    210210                                for ( var i = 0 ; i < children.length ; i++ )
    211211                                {
    212                                         this.copy( new File( sourceLocation, children[i] ), new File( targetLocation, children[i] ) );
     212                                        this.copy( new File( sourceLocation, children[i] ), new File( targetLocation, children[i] ), extraIgnoredPaths );
    213213                                }
     214
     215                                if ( !targetLocation.list().length )
     216                                {
     217                                        targetLocation['delete']();
     218                                }
    214219                        }
    215220                        else
    216221                        {
  • _source/includes/releaser.js

     
    3434                this.header = "";
    3535        }
    3636
    37         release.prototype.isIgnoredPath = function( path )
     37        release.prototype.isIgnoredPath = function( path, extraIgnoredPaths )
    3838        {
     39                if ( extraIgnoredPaths && extraIgnoredPaths.length )
     40                {
     41                        for ( var i = 0 ; i < extraIgnoredPaths.length ; i++ )
     42                        {
     43                                if ( path.replace( "\\", "/" ).endsWith( extraIgnoredPaths[i] ) )
     44                                        return true;
     45                        }
     46                }
     47
    3948                if ( !this.ignore )
    4049                        return false;
    4150
     
    8897
    8998        function copyFiles()
    9099        {
     100                var sourceLocation, targetLocation;
     101
    91102                for ( var i = 0 ; i < CKRELEASER.release.copy.length ; i++ )
    92103                {
    93104                        try
    94105                        {
    95                                 var sourceLocation = new File( CKRELEASER.releaseDir, CKRELEASER.release.copy[i].source );
    96                                 var targetLocation = new File( CKRELEASER.releaseDir, CKRELEASER.release.copy[i].target );
    97                                 CKRELEASER.io.copy( sourceLocation, targetLocation );
     106                                var ignoredFiles = [];
     107                                if ( CKRELEASER.release.copy[i].ignore )
     108                                {
     109                                        var packFile = new File( CKRELEASER.sourceDir, CKRELEASER.release.copy[i].ignore.sourcePackage );
     110                                        if ( !packFile.exists() )
     111                                                throw 'Package file ' + CKRELEASER.release.packages[i] + ' defined in ' + CKRELEASER.releaseFile
     112                                                  + ' not found (' + packFile.getCanonicalPath() + ')';
     113                                       
     114                                        var object = loadFile( packFile.getCanonicalPath() );
     115                                        ignoredFiles = eval('object.' + CKRELEASER.release.copy[i].ignore.files) || [];
     116                                }
     117
     118                                sourceLocation = new File( CKRELEASER.releaseDir, CKRELEASER.release.copy[i].source );
     119                                targetLocation = new File( CKRELEASER.releaseDir, CKRELEASER.release.copy[i].target );
     120                                CKRELEASER.io.copy( sourceLocation, targetLocation, ignoredFiles );
    98121                        }
    99122                        catch ( e )
    100123                        {
     
    334357                }
    335358        }
    336359
     360        function loadFile( filePath )
     361        {
     362                var file = new File( filePath );
     363
     364                var releaseCode = 'var object = { ' + CKRELEASER.io.readFile( file ) + '\n};';
     365                var cx = Context.enter(), scope = cx.initStandardObjects();
     366
     367                try
     368                {
     369                        cx.evaluateString( scope, releaseCode, file.getName(), 1, null );
     370                }
     371                catch ( e )
     372                {
     373                        if ( CKRELEASER.verbose && typeof ( e.rhinoException ) != 'undefined' )
     374                                e.rhinoException.printStackTrace();
     375
     376                        error( '\nParsing release file failed:\n    Error: ' + e.message + '\n    File: ' + file.getAbsolutePath()
     377                                        + '\n    Line: ' + e.lineNumber );
     378                }
     379
     380                return scope.object;
     381        }
     382
    337383        function fixLineEndings( file )
    338384        {
    339385                if ( file.isDirectory() )
     
    350396
    351397        CKRELEASER.releaser.prototype =
    352398        {
     399                copyFiles : copyFiles,
     400
    353401                loadDefinitionFile : function( filePath )
    354402                {
    355                         var file = new File( filePath );
    356 
    357                         var releaseCode = 'var release = { ' + CKRELEASER.io.readFile( file ) + '\n};';
    358                         var cx = Context.enter(), scope = cx.initStandardObjects();
    359 
    360                         try
    361                         {
    362                                 cx.evaluateString( scope, releaseCode, file.getName(), 1, null );
    363                         }
    364                         catch ( e )
    365                         {
    366                                 if ( CKRELEASER.verbose && typeof ( e.rhinoException ) != 'undefined' )
    367                                         e.rhinoException.printStackTrace();
    368 
    369                                 error( '\nParsing release file failed:\n    Error: ' + e.message + '\n    File: ' + file.getAbsolutePath()
    370                                                 + '\n    Line: ' + e.lineNumber );
    371                         }
    372 
    373                         this.loadDefinition( scope.release );
     403                        this.loadDefinition( loadFile( filePath ) );
    374404                },
    375405
    376406                loadDefinition : function( definitionObject )
  • test/_assets/plugins/font/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6(function()
     7{
     8        function addCombo( editor, comboName, styleType, lang, entries, defaultLabel, styleDefinition )
     9        {
     10                var config = editor.config;
     11
     12                // Gets the list of fonts from the settings.
     13                var names = entries.split( ';' ),
     14                        values = [];
     15
     16                // Create style objects for all fonts.
     17                var styles = {};
     18                for ( var i = 0 ; i < names.length ; i++ )
     19                {
     20                        var vars = {};
     21                        var parts = names[ i ].split( '/' );
     22
     23                        var name = names[ i ] = parts[ 0 ];
     24                        vars[ styleType ] = values[ i ] = parts[ 1 ] || name;
     25
     26                        styles[ name ] = new CKEDITOR.style( styleDefinition, vars );
     27                }
     28
     29                editor.ui.addRichCombo( comboName,
     30                        {
     31                                label : lang.label,
     32                                title : lang.panelTitle,
     33                                voiceLabel : lang.voiceLabel,
     34                                className : 'cke_' + ( styleType == 'size' ? 'fontSize' : 'font' ),
     35                                multiSelect : false,
     36
     37                                panel :
     38                                {
     39                                        css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
     40                                        voiceLabel : lang.panelVoiceLabel
     41                                },
     42
     43                                init : function()
     44                                {
     45                                        this.startGroup( lang.panelTitle );
     46
     47                                        for ( var i = 0 ; i < names.length ; i++ )
     48                                        {
     49                                                var name = names[ i ];
     50
     51                                                // Add the tag entry to the panel list.
     52                                                this.add( name, '<span style="font-' + styleType + ':' + values[ i ] + '">' + name + '</span>', name );
     53                                        }
     54                                },
     55
     56                                onClick : function( value )
     57                                {
     58                                        editor.focus();
     59                                        editor.fire( 'saveSnapshot' );
     60
     61                                        var style = styles[ value ];
     62
     63                                        if ( this.getValue() == value )
     64                                                style.remove( editor.document );
     65                                        else
     66                                                style.apply( editor.document );
     67
     68                                        editor.fire( 'saveSnapshot' );
     69                                },
     70
     71                                onRender : function()
     72                                {
     73                                        editor.on( 'selectionChange', function( ev )
     74                                                {
     75                                                        var currentValue = this.getValue();
     76
     77                                                        var elementPath = ev.data.path,
     78                                                                elements = elementPath.elements;
     79
     80                                                        // For each element into the elements path.
     81                                                        for ( var i = 0, element ; i < elements.length ; i++ )
     82                                                        {
     83                                                                element = elements[i];
     84
     85                                                                // Check if the element is removable by any of
     86                                                                // the styles.
     87                                                                for ( var value in styles )
     88                                                                {
     89                                                                        if ( styles[ value ].checkElementRemovable( element, true ) )
     90                                                                        {
     91                                                                                if ( value != currentValue )
     92                                                                                        this.setValue( value );
     93                                                                                return;
     94                                                                        }
     95                                                                }
     96                                                        }
     97
     98                                                        // If no styles match, just empty it.
     99                                                        this.setValue( '', defaultLabel );
     100                                                },
     101                                                this);
     102                                }
     103                        });
     104        }
     105
     106        CKEDITOR.plugins.add( 'font',
     107        {
     108                requires : [ 'richcombo', 'styles' ],
     109
     110                init : function( editor )
     111                {
     112                        var config = editor.config;
     113
     114                        addCombo( editor, 'Font', 'family', editor.lang.font, config.font_names, config.font_defaultLabel, config.font_style );
     115                        addCombo( editor, 'FontSize', 'size', editor.lang.fontSize, config.fontSize_sizes, config.fontSize_defaultLabel, config.fontSize_style );
     116                }
     117        });
     118})();
     119
     120/**
     121 * The list of fonts names to be displayed in the Font combo in the toolbar.
     122 * Entries are separated by semi-colons (;), while it's possible to have more
     123 * than one font for each entry, in the HTML way (separated by comma).
     124 *
     125 * A display name may be optionally defined by prefixing the entries with the
     126 * name and the slash character. For example, "Arial/Arial, Helvetica, sans-serif"
     127 * will be displayed as "Arial" in the list, but will be outputted as
     128 * "Arial, Helvetica, sans-serif".
     129 * @type String
     130 * @example
     131 * config.font_names =
     132 *     'Arial/Arial, Helvetica, sans-serif;' +
     133 *     'Times New Roman/Times New Roman, Times, serif;' +
     134 *     'Verdana';
     135 * @example
     136 * config.font_names = 'Arial;Times New Roman;Verdana';
     137 */
     138CKEDITOR.config.font_names =
     139        'Arial/Arial, Helvetica, sans-serif;' +
     140        'Comic Sans MS/Comic Sans MS, cursive;' +
     141        'Courier New/Courier New, Courier, monospace;' +
     142        'Georgia/Georgia, serif;' +
     143        'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' +
     144        'Tahoma/Tahoma, Geneva, sans-serif;' +
     145        'Times New Roman/Times New Roman, Times, serif;' +
     146        'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' +
     147        'Verdana/Verdana, Geneva, sans-serif';
     148
     149/**
     150 * The text to be displayed in the Font combo is none of the available values
     151 * matches the current cursor position or text selection.
     152 * @type String
     153 * @example
     154 * // If the default site font is Arial, we may making it more explicit to the end user.
     155 * config.font_defaultLabel = 'Arial';
     156 */
     157CKEDITOR.config.font_defaultLabel = '';
     158
     159/**
     160 * The style definition to be used to apply the font in the text.
     161 * @type Object
     162 * @example
     163 * // This is actually the default value for it.
     164 * config.font_style =
     165 *     {
     166 *         element              : 'span',
     167 *         styles               : { 'font-family' : '#(family)' },
     168 *         overrides    : [ { element : 'font', attributes : { 'face' : null } } ]
     169 *     };
     170 */
     171CKEDITOR.config.font_style =
     172        {
     173                element         : 'span',
     174                styles          : { 'font-family' : '#(family)' },
     175                overrides       : [ { element : 'font', attributes : { 'face' : null } } ]
     176        };
     177
     178/**
     179 * The list of fonts size to be displayed in the Font Size combo in the
     180 * toolbar. Entries are separated by semi-colons (;).
     181 *
     182 * Any kind of "CSS like" size can be used, like "12px", "2.3em", "130%",
     183 * "larger" or "x-small".
     184 *
     185 * A display name may be optionally defined by prefixing the entries with the
     186 * name and the slash character. For example, "Bigger Font/14px" will be
     187 * displayed as "Bigger Font" in the list, but will be outputted as "14px".
     188 * @type String
     189 * @default '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px'
     190 * @example
     191 * config.fontSize_sizes = '16/16px;24/24px;48/48px;';
     192 * @example
     193 * config.fontSize_sizes = '12px;2.3em;130%;larger;x-small';
     194 * @example
     195 * config.fontSize_sizes = '12 Pixels/12px;Big/2.3em;30 Percent More/130%;Bigger/larger;Very Small/x-small';
     196 */
     197CKEDITOR.config.fontSize_sizes =
     198        '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px';
     199
     200/**
     201 * The text to be displayed in the Font Size combo is none of the available
     202 * values matches the current cursor position or text selection.
     203 * @type String
     204 * @example
     205 * // If the default site font size is 12px, we may making it more explicit to the end user.
     206 * config.fontSize_defaultLabel = '12px';
     207 */
     208CKEDITOR.config.fontSize_defaultLabel = '';
     209
     210/**
     211 * The style definition to be used to apply the font size in the text.
     212 * @type Object
     213 * @example
     214 * // This is actually the default value for it.
     215 * config.fontSize_style =
     216 *     {
     217 *         element              : 'span',
     218 *         styles               : { 'font-size' : '#(size)' },
     219 *         overrides    : [ { element : 'font', attributes : { 'size' : null } } ]
     220 *     };
     221 */
     222CKEDITOR.config.fontSize_style =
     223        {
     224                element         : 'span',
     225                styles          : { 'font-size' : '#(size)' },
     226                overrides       : [ { element : 'font', attributes : { 'size' : null } } ]
     227        };
  • test/_assets/plugins/format/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'format',
     7{
     8        requires : [ 'richcombo', 'styles' ],
     9
     10        init : function( editor )
     11        {
     12                var config = editor.config,
     13                        lang = editor.lang.format;
     14
     15                // Gets the list of tags from the settings.
     16                var tags = config.format_tags.split( ';' );
     17
     18                // Create style objects for all defined styles.
     19                var styles = {};
     20                for ( var i = 0 ; i < tags.length ; i++ )
     21                {
     22                        var tag = tags[ i ];
     23                        styles[ tag ] = new CKEDITOR.style( config[ 'format_' + tag ] );
     24                }
     25
     26                editor.ui.addRichCombo( 'Format',
     27                        {
     28                                label : lang.label,
     29                                title : lang.panelTitle,
     30                                voiceLabel : lang.voiceLabel,
     31                                className : 'cke_format',
     32                                multiSelect : false,
     33
     34                                panel :
     35                                {
     36                                        css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
     37                                        voiceLabel : lang.panelVoiceLabel
     38                                },
     39
     40                                init : function()
     41                                {
     42                                        this.startGroup( lang.panelTitle );
     43
     44                                        for ( var tag in styles )
     45                                        {
     46                                                var label = lang[ 'tag_' + tag ];
     47
     48                                                // Add the tag entry to the panel list.
     49                                                this.add( tag, '<' + tag + '>' + label + '</' + tag + '>', label );
     50                                        }
     51                                },
     52
     53                                onClick : function( value )
     54                                {
     55                                        editor.focus();
     56                                        editor.fire( 'saveSnapshot' );
     57
     58                                        styles[ value ].apply( editor.document );
     59
     60                                        editor.fire( 'saveSnapshot' );
     61                                },
     62
     63                                onRender : function()
     64                                {
     65                                        editor.on( 'selectionChange', function( ev )
     66                                                {
     67                                                        var currentTag = this.getValue();
     68
     69                                                        var elementPath = ev.data.path;
     70
     71                                                        for ( var tag in styles )
     72                                                        {
     73                                                                if ( styles[ tag ].checkActive( elementPath ) )
     74                                                                {
     75                                                                        if ( tag != currentTag )
     76                                                                                this.setValue( tag, editor.lang.format[ 'tag_' + tag ] );
     77                                                                        return;
     78                                                                }
     79                                                        }
     80
     81                                                        // If no styles match, just empty it.
     82                                                        this.setValue( '' );
     83                                                },
     84                                                this);
     85                                }
     86                        });
     87        }
     88});
     89
     90/**
     91 * A list of semi colon separated style names (by default tags) representing
     92 * the style definition for each entry to be displayed in the Format combo in
     93 * the toolbar. Each entry must have its relative definition configuration in a
     94 * setting named "format_(tagName)". For example, the "p" entry has its
     95 * definition taken from config.format_p.
     96 * @type String
     97 * @default 'p;h1;h2;h3;h4;h5;h6;pre;address;div'
     98 * @example
     99 * config.format_tags = 'p;h2;h3;pre'
     100 */
     101CKEDITOR.config.format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address;div';
     102
     103/**
     104 * The style definition to be used to apply the "Normal" format.
     105 * @type Object
     106 * @default { element : 'p' }
     107 * @example
     108 * config.format_p = { element : 'p', attributes : { class : 'normalPara' } };
     109 */
     110CKEDITOR.config.format_p = { element : 'p' };
     111
     112/**
     113 * The style definition to be used to apply the "Normal (DIV)" format.
     114 * @type Object
     115 * @default { element : 'div' }
     116 * @example
     117 * config.format_div = { element : 'div', attributes : { class : 'normalDiv' } };
     118 */
     119CKEDITOR.config.format_div = { element : 'div' };
     120
     121/**
     122 * The style definition to be used to apply the "Formatted" format.
     123 * @type Object
     124 * @default { element : 'pre' }
     125 * @example
     126 * config.format_pre = { element : 'pre', attributes : { class : 'code' } };
     127 */
     128CKEDITOR.config.format_pre = { element : 'pre' };
     129
     130/**
     131 * The style definition to be used to apply the "Address" format.
     132 * @type Object
     133 * @default { element : 'address' }
     134 * @example
     135 * config.format_address = { element : 'address', attributes : { class : 'styledAddress' } };
     136 */
     137CKEDITOR.config.format_address = { element : 'address' };
     138
     139/**
     140 * The style definition to be used to apply the "Heading 1" format.
     141 * @type Object
     142 * @default { element : 'h1' }
     143 * @example
     144 * config.format_h1 = { element : 'h1', attributes : { class : 'contentTitle1' } };
     145 */
     146CKEDITOR.config.format_h1 = { element : 'h1' };
     147
     148/**
     149 * The style definition to be used to apply the "Heading 1" format.
     150 * @type Object
     151 * @default { element : 'h2' }
     152 * @example
     153 * config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle2' } };
     154 */
     155CKEDITOR.config.format_h2 = { element : 'h2' };
     156
     157/**
     158 * The style definition to be used to apply the "Heading 1" format.
     159 * @type Object
     160 * @default { element : 'h3' }
     161 * @example
     162 * config.format_h3 = { element : 'h3', attributes : { class : 'contentTitle3' } };
     163 */
     164CKEDITOR.config.format_h3 = { element : 'h3' };
     165
     166/**
     167 * The style definition to be used to apply the "Heading 1" format.
     168 * @type Object
     169 * @default { element : 'h4' }
     170 * @example
     171 * config.format_h4 = { element : 'h4', attributes : { class : 'contentTitle4' } };
     172 */
     173CKEDITOR.config.format_h4 = { element : 'h4' };
     174
     175/**
     176 * The style definition to be used to apply the "Heading 1" format.
     177 * @type Object
     178 * @default { element : 'h5' }
     179 * @example
     180 * config.format_h5 = { element : 'h5', attributes : { class : 'contentTitle5' } };
     181 */
     182CKEDITOR.config.format_h5 = { element : 'h5' };
     183
     184/**
     185 * The style definition to be used to apply the "Heading 1" format.
     186 * @type Object
     187 * @default { element : 'h6' }
     188 * @example
     189 * config.format_h6 = { element : 'h6', attributes : { class : 'contentTitle6' } };
     190 */
     191CKEDITOR.config.format_h6 = { element : 'h6' };
  • test/_assets/plugins/forms/dialogs/button.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5CKEDITOR.dialog.add( 'button', function( editor )
     6{
     7        return {
     8                title : editor.lang.button.title,
     9                minWidth : 350,
     10                minHeight : 150,
     11                onShow : function()
     12                {
     13                        delete this.button;
     14                        var element = this.getParentEditor().getSelection().getSelectedElement();
     15                        if ( element && element.getName() == "input" )
     16                        {
     17                                var type = element.getAttribute( 'type' );
     18                                if ( type == "button" || type == "reset" || type == "submit" )
     19                                {
     20                                        this.button = element;
     21                                        this.setupContent( element );
     22                                }
     23                        }
     24                },
     25                onOk : function()
     26                {
     27                        var editor,
     28                                element = this.button,
     29                                isInsertMode = !element;
     30
     31                        if ( isInsertMode )
     32                        {
     33                                editor = this.getParentEditor();
     34                                element = editor.document.createElement( 'input' );
     35                        }
     36
     37                        if ( isInsertMode )
     38                                editor.insertElement( element );
     39                        this.commitContent( { element : element } );
     40                },
     41                contents : [
     42                        {
     43                                id : 'info',
     44                                label : editor.lang.button.title,
     45                                title : editor.lang.button.title,
     46                                elements : [
     47                                        {
     48                                                id : '_cke_saved_name',
     49                                                type : 'text',
     50                                                label : editor.lang.common.name,
     51                                                'default' : '',
     52                                                setup : function( element )
     53                                                {
     54                                                        this.setValue(
     55                                                                        element.getAttribute( '_cke_saved_name' ) ||
     56                                                                        element.getAttribute( 'name' ) ||
     57                                                                        '' );
     58                                                },
     59                                                commit : function( data )
     60                                                {
     61                                                        var element = data.element;
     62
     63                                                        if ( this.getValue() )
     64                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     65                                                        else
     66                                                        {
     67                                                                element.removeAttribute( '_cke_saved_name' );
     68                                                                element.removeAttribute( 'name' );
     69                                                        }
     70                                                }
     71                                        },
     72                                        {
     73                                                id : 'value',
     74                                                type : 'text',
     75                                                label : editor.lang.button.text,
     76                                                accessKey : 'V',
     77                                                'default' : '',
     78                                                setup : function( element )
     79                                                {
     80                                                        this.setValue( element.getAttribute( 'value' ) || '' );
     81                                                },
     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                                                }
     91                                        },
     92                                        {
     93                                                id : 'type',
     94                                                type : 'select',
     95                                                label : editor.lang.button.type,
     96                                                'default' : 'button',
     97                                                accessKey : 'T',
     98                                                items :
     99                                                [
     100                                                        [ editor.lang.button.typeBtn, 'button' ],
     101                                                        [ editor.lang.button.typeSbm, 'submit' ],
     102                                                        [ editor.lang.button.typeRst, 'reset' ]
     103                                                ],
     104                                                setup : function( element )
     105                                                {
     106                                                        this.setValue( element.getAttribute( 'type' ) || '' );
     107                                                },
     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                                        }
     131                                ]
     132                        }
     133                ]
     134        };
     135});
  • test/_assets/plugins/forms/dialogs/checkbox.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5CKEDITOR.dialog.add( 'checkbox', function( editor )
     6{
     7        return {
     8                title : editor.lang.checkboxAndRadio.checkboxTitle,
     9                minWidth : 350,
     10                minHeight : 140,
     11                onShow : function()
     12                {
     13                        delete this.checkbox;
     14
     15                        var element = this.getParentEditor().getSelection().getSelectedElement();
     16
     17                        if ( element && element.getAttribute( 'type' ) == "checkbox" )
     18                        {
     19                                this.checkbox = element;
     20                                this.setupContent( element );
     21                        }
     22                },
     23                onOk : function()
     24                {
     25                        var editor,
     26                                element = this.checkbox,
     27                                isInsertMode = !element;
     28
     29                        if ( isInsertMode )
     30                        {
     31                                editor = this.getParentEditor();
     32                                element = editor.document.createElement( 'input' );
     33                                element.setAttribute( 'type', 'checkbox' );
     34                        }
     35
     36                        if ( isInsertMode )
     37                                editor.insertElement( element );
     38                        this.commitContent( { element : element } );
     39                },
     40                contents : [
     41                        {
     42                                id : 'info',
     43                                label : editor.lang.checkboxAndRadio.checkboxTitle,
     44                                title : editor.lang.checkboxAndRadio.checkboxTitle,
     45                                startupFocus : 'txtName',
     46                                elements : [
     47                                        {
     48                                                id : 'txtName',
     49                                                type : 'text',
     50                                                label : editor.lang.common.name,
     51                                                'default' : '',
     52                                                accessKey : 'N',
     53                                                setup : function( element )
     54                                                {
     55                                                        this.setValue(
     56                                                                        element.getAttribute( '_cke_saved_name' ) ||
     57                                                                        element.getAttribute( 'name' ) ||
     58                                                                        '' );
     59                                                },
     60                                                commit : function( data )
     61                                                {
     62                                                        var element = data.element;
     63
     64                                                        // IE failed to update 'name' property on input elements, protect it now.
     65                                                        if ( this.getValue() )
     66                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     67                                                        else
     68                                                        {
     69                                                                element.removeAttribute( '_cke_saved_name' );
     70                                                                element.removeAttribute( 'name' );
     71                                                        }
     72                                                }
     73                                        },
     74                                        {
     75                                                id : 'txtValue',
     76                                                type : 'text',
     77                                                label : editor.lang.checkboxAndRadio.value,
     78                                                'default' : '',
     79                                                accessKey : 'V',
     80                                                setup : function( element )
     81                                                {
     82                                                        this.setValue( element.getAttribute( 'value' ) || '' );
     83                                                },
     84                                                commit : function( data )
     85                                                {
     86                                                        var element = data.element;
     87
     88                                                        if ( this.getValue() )
     89                                                                element.setAttribute( 'value', this.getValue() );
     90                                                        else
     91                                                                element.removeAttribute( 'value' );
     92                                                }
     93                                        },
     94                                        {
     95                                                id : 'cmbSelected',
     96                                                type : 'checkbox',
     97                                                label : editor.lang.checkboxAndRadio.selected,
     98                                                'default' : '',
     99                                                accessKey : 'S',
     100                                                value : "checked",
     101                                                setup : function( element )
     102                                                {
     103                                                        this.setValue( element.getAttribute( 'checked' ) );
     104                                                },
     105                                                commit : function( data )
     106                                                {
     107                                                        var element = data.element;
     108
     109                                                        if ( CKEDITOR.env.ie )
     110                                                        {
     111                                                                var isElementChecked = !!element.getAttribute( 'checked' );
     112                                                                var isChecked = !!this.getValue();
     113
     114                                                                if ( isElementChecked != isChecked )
     115                                                                {
     116                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="checkbox"'
     117                                                                                   + ( isChecked ? ' checked="checked"' : '' )
     118                                                                                   + '></input>', editor.document );
     119                                                                        element.copyAttributes( replace, { type : 1, checked : 1 } );
     120                                                                        replace.replace( element );
     121                                                                        editor.getSelection().selectElement( replace );
     122                                                                        data.element = replace;
     123                                                                }
     124                                                        }
     125                                                        else
     126                                                        {
     127                                                                if ( this.getValue() )
     128                                                                        element.setAttribute( 'checked', this.getValue() );
     129                                                                else
     130                                                                        element.removeAttribute( 'checked' );
     131                                                        }
     132                                                }
     133                                        }
     134                                ]
     135                        }
     136                ]
     137        };
     138});
  • test/_assets/plugins/forms/dialogs/form.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5CKEDITOR.dialog.add( 'form', function( editor )
     6{
     7        var autoAttributes =
     8        {
     9                action : 1,
     10                id : 1,
     11                method : 1,
     12                enctype : 1,
     13                target : 1
     14        };
     15
     16        return {
     17                title : editor.lang.form.title,
     18                minWidth : 350,
     19                minHeight : 200,
     20                onShow : function()
     21                {
     22                        delete this.form;
     23
     24                        var element = this.getParentEditor().getSelection().getStartElement();
     25                        var form = element && element.getAscendant( 'form', true );
     26                        if ( form )
     27                        {
     28                                this.form = form;
     29                                this.setupContent( form );
     30                        }
     31                },
     32                onOk : function()
     33                {
     34                        var editor,
     35                                element = this.form,
     36                                isInsertMode = !element;
     37
     38                        if ( isInsertMode )
     39                        {
     40                                editor = this.getParentEditor();
     41                                element = editor.document.createElement( 'form' );
     42                                element.append( editor.document.createElement( 'br' ) );
     43                        }
     44
     45                        if ( isInsertMode )
     46                                editor.insertElement( element );
     47                        this.commitContent( element );
     48                },
     49                onLoad : function()
     50                {
     51                        function autoSetup( element )
     52                        {
     53                                this.setValue( element.getAttribute( this.id ) || '' );
     54                        }
     55
     56                        function autoCommit( element )
     57                        {
     58                                if ( this.getValue() )
     59                                        element.setAttribute( this.id, this.getValue() );
     60                                else
     61                                        element.removeAttribute( this.id );
     62                        }
     63
     64                        this.foreach( function( contentObj )
     65                                {
     66                                        if ( autoAttributes[ contentObj.id ] )
     67                                        {
     68                                                contentObj.setup = autoSetup;
     69                                                contentObj.commit = autoCommit;
     70                                        }
     71                                } );
     72                },
     73                contents : [
     74                        {
     75                                id : 'info',
     76                                label : editor.lang.form.title,
     77                                title : editor.lang.form.title,
     78                                elements : [
     79                                        {
     80                                                id : 'txtName',
     81                                                type : 'text',
     82                                                label : editor.lang.common.name,
     83                                                'default' : '',
     84                                                accessKey : 'N',
     85                                                setup : function( element )
     86                                                {
     87                                                        this.setValue( element.getAttribute( '_cke_saved_name' ) ||
     88                                                                        element.getAttribute( 'name' ) ||
     89                                                                        '' );
     90                                                },
     91                                                commit : function( element )
     92                                                {
     93                                                        if ( this.getValue() )
     94                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
     95                                                        else
     96                                                        {
     97                                                                element.removeAttribute( '_cke_saved_name' );
     98                                                                element.removeAttribute( 'name' );
     99                                                        }
     100                                                }
     101                                        },
     102                                        {
     103                                                id : 'action',
     104                                                type : 'text',
     105                                                label : editor.lang.form.action,
     106                                                'default' : '',
     107                                                accessKey : 'A'
     108                                        },
     109                                        {
     110                                                type : 'hbox',
     111                                                widths : [ '45%', '55%' ],
     112                                                children :
     113                                                [
     114                                                        {
     115                                                                id : 'id',
     116                                                                type : 'text',
     117                                                                label : editor.lang.common.id,
     118                                                                'default' : '',
     119                                                                accessKey : 'I'
     120                                                        },
     121                                                        {
     122                                                                id : 'enctype',
     123                                                                type : 'select',
     124                                                                label : editor.lang.form.encoding,
     125                                                                style : 'width:100%',
     126                                                                accessKey : 'E',
     127                                                                'default' : '',
     128                                                                items :
     129                                                                [
     130                                                                        [ '' ],
     131                                                                        [ 'text/plain' ],
     132                                                                        [ 'multipart/form-data' ],
     133                                                                        [ 'application/x-www-form-urlencoded' ]
     134                                                                ]
     135                                                        }
     136                                                ]
     137                                        },
     138                                        {
     139                                                type : 'hbox',
     140                                                widths : [ '45%', '55%' ],
     141                                                children :
     142                                                [
     143                                                        {
     144                                                                id : 'target',
     145                                                                type : 'select',
     146                                                                label : editor.lang.form.target,
     147                                                                style : 'width:100%',
     148                                                                accessKey : 'M',
     149                                                                'default' : '',
     150                                                                items :
     151                                                                [
     152                                                                        [ editor.lang.form.targetNotSet, '' ],
     153                                                                        [ editor.lang.form.targetNew, '_blank' ],
     154                                                                        [ editor.lang.form.targetTop, '_top' ],
     155                                                                        [ editor.lang.form.targetSelf, '_self' ],
     156                                                                        [ editor.lang.form.targetParent, '_parent' ]
     157                                                                ]
     158                                                        },
     159                                                        {
     160                                                                id : 'method',
     161                                                                type : 'select',
     162                                                                label : editor.lang.form.method,
     163                                                                accessKey : 'M',
     164                                                                'default' : 'GET',
     165                                                                items :
     166                                                                [
     167                                                                        [ 'GET', 'get' ],
     168                                                                        [ 'POST', 'post' ]
     169                                                                ]
     170                                                        }
     171                                                ]
     172                                        }
     173                                ]
     174                        }
     175                ]
     176        };
     177});
  • test/_assets/plugins/forms/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @file Forms Plugin
     8 */
     9
     10CKEDITOR.plugins.add( 'forms',
     11{
     12        init : function( editor )
     13        {
     14                var lang = editor.lang;
     15
     16                editor.addCss(
     17                        'form' +
     18                        '{' +
     19                                'border: 1px dotted #FF0000;' +
     20                                'padding: 2px;' +
     21                        '}' );
     22
     23                // All buttons use the same code to register. So, to avoid
     24                // duplications, let's use this tool function.
     25                var addButtonCommand = function( buttonName, commandName, dialogFile )
     26                {
     27                        editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) );
     28
     29                        editor.ui.addButton( buttonName,
     30                                {
     31                                        label : lang.common[ buttonName.charAt(0).toLowerCase() + buttonName.slice(1) ],
     32                                        command : commandName
     33                                });
     34                        CKEDITOR.dialog.add( commandName, dialogFile );
     35                };
     36
     37                var dialogPath = this.path + 'dialogs/';
     38                addButtonCommand( 'Form',                       'form',                 dialogPath + 'form.js' );
     39                addButtonCommand( 'Checkbox',           'checkbox',             dialogPath + 'checkbox.js' );
     40                addButtonCommand( 'Radio',                      'radio',                dialogPath + 'radio.js' );
     41                addButtonCommand( 'TextField',          'textfield',    dialogPath + 'textfield.js' );
     42                addButtonCommand( 'Textarea',           'textarea',             dialogPath + 'textarea.js' );
     43                addButtonCommand( 'Select',                     'select',               dialogPath + 'select.js' );
     44                addButtonCommand( 'Button',                     'button',               dialogPath + 'button.js' );
     45                addButtonCommand( 'ImageButton',        'imagebutton',  CKEDITOR.plugins.getPath('image') + 'dialogs/image.js' );
     46                addButtonCommand( 'HiddenField',        'hiddenfield',  dialogPath + 'hiddenfield.js' );
     47
     48                // If the "menu" plugin is loaded, register the menu items.
     49                if ( editor.addMenuItems )
     50                {
     51                        editor.addMenuItems(
     52                                {
     53                                        form :
     54                                        {
     55                                                label : lang.form.menu,
     56                                                command : 'form',
     57                                                group : 'form'
     58                                        },
     59
     60                                        checkbox :
     61                                        {
     62                                                label : lang.checkboxAndRadio.checkboxTitle,
     63                                                command : 'checkbox',
     64                                                group : 'checkbox'
     65                                        },
     66
     67                                        radio :
     68                                        {
     69                                                label : lang.checkboxAndRadio.radioTitle,
     70                                                command : 'radio',
     71                                                group : 'radio'
     72                                        },
     73
     74                                        textfield :
     75                                        {
     76                                                label : lang.textfield.title,
     77                                                command : 'textfield',
     78                                                group : 'textfield'
     79                                        },
     80
     81                                        hiddenfield :
     82                                        {
     83                                                label : lang.hidden.title,
     84                                                command : 'hiddenfield',
     85                                                group : 'hiddenfield'
     86                                        },
     87
     88                                        imagebutton :
     89                                        {
     90                                                label : lang.image.titleButton,
     91                                                command : 'imagebutton',
     92                                                group : 'imagebutton'
     93                                        },
     94
     95                                        button :
     96                                        {
     97                                                label : lang.button.title,
     98                                                command : 'button',
     99                                                group : 'button'
     100                                        },
     101
     102                                        select :
     103                                        {
     104                                                label : lang.select.title,
     105                                                command : 'select',
     106                                                group : 'select'
     107                                        },
     108
     109                                        textarea :
     110                                        {
     111                                                label : lang.textarea.title,
     112                                                command : 'textarea',
     113                                                group : 'textarea'
     114                                        }
     115                                });
     116                }
     117
     118                // If the "contextmenu" plugin is loaded, register the listeners.
     119                if ( editor.contextMenu )
     120                {
     121                        editor.contextMenu.addListener( function( element )
     122                                {
     123                                        if ( element && element.hasAscendant( 'form', true ) )
     124                                                return { form : CKEDITOR.TRISTATE_OFF };
     125                                });
     126
     127                        editor.contextMenu.addListener( function( element )
     128                                {
     129                                        if ( element )
     130                                        {
     131                                                var name = element.getName();
     132
     133                                                if ( name == 'select' )
     134                                                        return { select : CKEDITOR.TRISTATE_OFF };
     135
     136                                                if ( name == 'textarea' )
     137                                                        return { textarea : CKEDITOR.TRISTATE_OFF };
     138
     139                                                if ( name == 'input' )
     140                                                {
     141                                                        var type = element.getAttribute( 'type' );
     142
     143                                                        if ( type == 'text' || type == 'password' )
     144                                                                return { textfield : CKEDITOR.TRISTATE_OFF };
     145
     146                                                        if ( type == 'button' || type == 'submit' || type == 'reset' )
     147                                                                return { button : CKEDITOR.TRISTATE_OFF };
     148
     149                                                        if ( type == 'checkbox' )
     150                                                                return { checkbox : CKEDITOR.TRISTATE_OFF };
     151
     152                                                        if ( type == 'radio' )
     153                                                                return { radio : CKEDITOR.TRISTATE_OFF };
     154
     155                                                        if ( type == 'image' )
     156                                                                return { imagebutton : CKEDITOR.TRISTATE_OFF };
     157                                                }
     158
     159                                                if ( name == 'img' && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )
     160                                                        return { hiddenfield : CKEDITOR.TRISTATE_OFF };
     161                                        }
     162                                });
     163                }
     164        },
     165        requires : [ 'image' ]
     166} );
     167
     168if ( CKEDITOR.env.ie )
     169{
     170        CKEDITOR.dom.element.prototype.hasAttribute = function( name )
     171        {
     172                var $attr = this.$.attributes.getNamedItem( name );
     173
     174                if ( this.getName() == 'input' )
     175                {
     176                        switch ( name )
     177                        {
     178                                case 'class' :
     179                                        return this.$.className.length > 0;
     180                                case 'checked' :
     181                                        return !!this.$.checked;
     182                                case 'value' :
     183                                        var type = this.getAttribute( 'type' );
     184                                        if ( type == 'checkbox' || type == 'radio' )
     185                                                return this.$.value != 'on';
     186                                        break;
     187                                default:
     188                        }
     189                }
     190
     191                return !!( $attr && $attr.specified );
     192        };
     193}
  • test/_assets/plugins/horizontalrule/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @file Horizontal Rule plugin.
     8 */
     9
     10(function()
     11{
     12        var horizontalruleCmd =
     13        {
     14                canUndo : false,    // The undo snapshot will be handled by 'insertElement'.
     15                exec : function( editor )
     16                {
     17                        editor.insertElement( editor.document.createElement( 'hr' ) );
     18                }
     19        };
     20
     21        var pluginName = 'horizontalrule';
     22
     23        // Register a plugin named "horizontalrule".
     24        CKEDITOR.plugins.add( pluginName,
     25        {
     26                init : function( editor )
     27                {
     28                        editor.addCommand( pluginName, horizontalruleCmd );
     29                        editor.ui.addButton( 'HorizontalRule',
     30                                {
     31                                        label : editor.lang.horizontalrule,
     32                                        command : pluginName
     33                                });
     34                }
     35        });
     36})();
  • test/_assets/plugins/specialchar/dialogs/specialchar.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.dialog.add( 'specialchar', function( editor )
     7{
     8        /**
     9         * Simulate "this" of a dialog for non-dialog events.
     10         * @type {CKEDITOR.dialog}
     11         */
     12        var dialog;
     13        var onChoice = function( evt )
     14        {
     15                var target, value;
     16                if ( evt.data )
     17                        target = evt.data.getTarget();
     18                else
     19                        target = new CKEDITOR.dom.element( evt );
     20
     21                if ( target.getName() == 'a' && ( value = target.getChild( 0 ).getHtml() ) )
     22                {
     23                        target.removeClass( "cke_light_background" );
     24                        dialog.hide();
     25                        editor.insertHtml( value );
     26                }
     27        };
     28
     29        var onClick = CKEDITOR.tools.addFunction( onChoice );
     30
     31        var focusedNode;
     32
     33        var onFocus = function( evt, target )
     34        {
     35                var value;
     36                target = target || evt.data.getTarget();
     37
     38                if ( target.getName() == 'span' )
     39                        target = target.getParent();
     40
     41                if ( target.getName() == 'a' && ( value = target.getChild( 0 ).getHtml() ) )
     42                {
     43                        // Trigger blur manually if there is focused node.
     44                        if ( focusedNode )
     45                                onBlur( null, focusedNode );
     46
     47                        var htmlPreview = dialog.getContentElement( 'info', 'htmlPreview' ).getElement();
     48
     49                        dialog.getContentElement( 'info', 'charPreview' ).getElement().setHtml( value );
     50                        htmlPreview.setHtml( CKEDITOR.tools.htmlEncode( value ) );
     51                        target.getParent().addClass( "cke_light_background" );
     52
     53                        // Memorize focused node.
     54                        focusedNode = target;
     55                }
     56        };
     57
     58        var onBlur = function( evt, target )
     59        {
     60                target = target || evt.data.getTarget();
     61
     62                if ( target.getName() == 'span' )
     63                        target = target.getParent();
     64
     65                if ( target.getName() == 'a' )
     66                {
     67                        dialog.getContentElement( 'info', 'charPreview' ).getElement().setHtml( '&nbsp;' );
     68                        dialog.getContentElement( 'info', 'htmlPreview' ).getElement().setHtml( '&nbsp;' );
     69                        target.getParent().removeClass( "cke_light_background" );
     70
     71                        focusedNode = undefined;
     72                }
     73        };
     74
     75        var onKeydown = CKEDITOR.tools.addFunction( function( ev )
     76        {
     77                ev = new CKEDITOR.dom.event( ev );
     78
     79                // Get an Anchor element.
     80                var element = ev.getTarget();
     81                var relative, nodeToMove;
     82                var keystroke = ev.getKeystroke();
     83
     84                switch ( keystroke )
     85                {
     86                        // RIGHT-ARROW
     87                        case 39 :
     88                                // relative is TD
     89                                if ( ( relative = element.getParent().getNext() ) )
     90                                {
     91                                        nodeToMove = relative.getChild( 0 );
     92                                        if ( nodeToMove.type == 1 )
     93                                        {
     94                                                nodeToMove.focus();
     95                                                onBlur( null, element );
     96                                                onFocus( null, nodeToMove );
     97                                        }
     98                                }
     99                                ev.preventDefault();
     100                                break;
     101                        // LEFT-ARROW
     102                        case 37 :
     103                                // relative is TD
     104                                if ( ( relative = element.getParent().getPrevious() ) )
     105                                {
     106                                        nodeToMove = relative.getChild( 0 );
     107                                        nodeToMove.focus();
     108                                        onBlur( null, element );
     109                                        onFocus( null, nodeToMove );
     110                                }
     111                                ev.preventDefault();
     112                                break;
     113                        // UP-ARROW
     114                        case 38 :
     115                                // relative is TR
     116                                if ( ( relative = element.getParent().getParent().getPrevious() ) )
     117                                {
     118                                        nodeToMove = relative.getChild( [element.getParent().getIndex(), 0] );
     119                                        nodeToMove.focus();
     120                                        onBlur( null, element );
     121                                        onFocus( null, nodeToMove );
     122                                }
     123                                ev.preventDefault();
     124                                break;
     125                        // DOWN-ARROW
     126                        case 40 :
     127                                // relative is TR
     128                                if ( ( relative = element.getParent().getParent().getNext() ) )
     129                                {
     130                                        nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] );
     131                                        if ( nodeToMove && nodeToMove.type == 1 )
     132                                        {
     133                                                nodeToMove.focus();
     134                                                onBlur( null, element );
     135                                                onFocus( null, nodeToMove );
     136                                        }
     137                                }
     138                                ev.preventDefault();
     139                                break;
     140                        // SPACE
     141                        // ENTER is already handled as onClick
     142                        case 32 :
     143                                onChoice( { data: ev } );
     144                                ev.preventDefault();
     145                                break;
     146                        // TAB
     147                        case 9 :
     148                                // relative is TD
     149                                if ( ( relative = element.getParent().getNext() ) )
     150                                {
     151                                        nodeToMove = relative.getChild( 0 );
     152                                        if ( nodeToMove.type == 1 )
     153                                        {
     154                                                nodeToMove.focus();
     155                                                onBlur( null, element );
     156                                                onFocus( null, nodeToMove );
     157                                                ev.preventDefault( true );
     158                                        }
     159                                        else
     160                                                onBlur( null, element );
     161                                }
     162                                // relative is TR
     163                                else if ( ( relative = element.getParent().getParent().getNext() ) )
     164                                {
     165                                        nodeToMove = relative.getChild( [ 0, 0 ] );
     166                                        if ( nodeToMove && nodeToMove.type == 1 )
     167                                        {
     168                                                nodeToMove.focus();
     169                                                onBlur( null, element );
     170                                                onFocus( null, nodeToMove );
     171                                                ev.preventDefault( true );
     172                                        }
     173                                        else
     174                                                onBlur( null, element );
     175                                }
     176                                break;
     177                        // SHIFT + TAB
     178                        case CKEDITOR.SHIFT + 9 :
     179                                // relative is TD
     180                                if ( ( relative = element.getParent().getPrevious() ) )
     181                                {
     182                                        nodeToMove = relative.getChild( 0 );
     183                                        nodeToMove.focus();
     184                                        onBlur( null, element );
     185                                        onFocus( null, nodeToMove );
     186                                        ev.preventDefault( true );
     187                                }
     188                                // relative is TR
     189                                else if ( ( relative = element.getParent().getParent().getPrevious() ) )
     190                                {
     191                                        nodeToMove = relative.getLast().getChild( 0 );
     192                                        nodeToMove.focus();
     193                                        onBlur( null, element );
     194                                        onFocus( null, nodeToMove );
     195                                        ev.preventDefault( true );
     196                                }
     197                                else
     198                                        onBlur( null, element );
     199                                break;
     200                        default :
     201                                // Do not stop not handled events.
     202                                return;
     203                }
     204        });
     205
     206        return {
     207                title : editor.lang.specialChar.title,
     208                minWidth : 430,
     209                minHeight : 280,
     210                buttons : [ CKEDITOR.dialog.cancelButton ],
     211                charColumns : 17,
     212                chars :
     213                        [
     214                                '!','&quot;','#','$','%','&amp;',"'",'(',')','*','+','-','.','/',
     215                                '0','1','2','3','4','5','6','7','8','9',':',';',
     216                                '&lt;','=','&gt;','?','@',
     217                                'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
     218                                'P','Q','R','S','T','U','V','W','X','Y','Z',
     219                                '[',']','^','_','`',
     220                                'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
     221                                'q','r','s','t','u','v','w','x','y','z',
     222                                '{','|','}','~','&euro;','&lsquo;','&rsquo;','&rsquo;','&ldquo;',
     223                                '&rdquo;','&ndash;','&mdash;','&iexcl;','&cent;','&pound;',
     224                                '&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;',
     225                                '&laquo;','&not;','&reg;','&macr;','&deg;','&plusmn;','&sup2;',
     226                                '&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;',
     227                                '&sup1;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;',
     228                                '&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;',
     229                                '&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;',
     230                                '&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;',
     231                                '&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;',
     232                                '&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;',
     233                                '&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;',
     234                                '&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;',
     235                                '&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;',
     236                                '&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;',
     237                                '&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;',
     238                                '&ucirc;','&uuml;','&uuml;','&yacute;','&thorn;','&yuml;',
     239                                '&OElig;','&oelig;','&#372;','&#374','&#373','&#375;','&sbquo;',
     240                                '&#8219;','&bdquo;','&hellip;','&trade;','&#9658;','&bull;',
     241                                '&rarr;','&rArr;','&hArr;','&diams;','&asymp;'
     242                        ],
     243                onLoad :  function()
     244                {
     245                        var columns = this.definition.charColumns,
     246                                chars = this.definition.chars;
     247
     248                        var html = [ '<table style="width: 320px; height: 100%; border-collapse: separate;" align="center" cellspacing="2" cellpadding="2" border="0">' ];
     249
     250                        var i = 0 ;
     251                        while ( i < chars.length )
     252                        {
     253                                html.push( '<tr>' ) ;
     254
     255                                for( var j = 0 ; j < columns ; j++, i++ )
     256                                {
     257                                        if ( chars[ i ] )
     258                                        {
     259                                                html.push(
     260                                                        '<td class="cke_dark_background" style="cursor: default">' +
     261                                                        '<a href="javascript: void(0);" style="cursor: inherit; display: block; height: 1.25em; margin-top: 0.25em; text-align: center;" title="', chars[i].replace( /&/g, '&amp;' ), '"' +
     262                                                        ' onkeydown="CKEDITOR.tools.callFunction( ' + onKeydown + ', event, this )"' +
     263                                                        ' onclick="CKEDITOR.tools.callFunction(' + onClick + ', this); return false;"' +
     264                                                        ' tabindex="-1">' +
     265                                                        '<span style="margin: 0 auto;cursor: inherit">' +
     266                                                        chars[i] +
     267                                                        '</span></a>');
     268                                        }
     269                                        else
     270                                                html.push( '<td class="cke_dark_background">&nbsp;' );
     271
     272                                        html.push( '</td>' );
     273                                }
     274                                html.push( '</tr>' );
     275                        }
     276
     277                        html.push( '</tbody></table>' );
     278
     279                        this.getContentElement( 'info', 'charContainer' ).getElement().setHtml( html.join( '' ) );
     280                },
     281                contents : [
     282                        {
     283                                id : 'info',
     284                                label : editor.lang.common.generalTab,
     285                                title : editor.lang.common.generalTab,
     286                                padding : 0,
     287                                align : 'top',
     288                                elements : [
     289                                        {
     290                                                type : 'hbox',
     291                                                align : 'top',
     292                                                widths : [ '320px', '90px' ],
     293                                                children :
     294                                                [
     295                                                        {
     296                                                                type : 'html',
     297                                                                id : 'charContainer',
     298                                                                html : '',
     299                                                                onMouseover : onFocus,
     300                                                                onMouseout : onBlur,
     301                                                                focus : function()
     302                                                                {
     303                                                                        var firstChar = this.getElement().getChild( [0, 0, 0, 0, 0] );
     304                                                                        setTimeout(function()
     305                                                                        {
     306                                                                                firstChar.focus();
     307                                                                                onFocus( null, firstChar );
     308                                                                        });
     309                                                                },
     310                                                                // Needed only for webkit.
     311                                                                onShow : function()
     312                                                                {
     313                                                                        var firstChar = this.getElement().getChild( [0, 0, 0, 0, 0] );
     314                                                                        setTimeout(function()
     315                                                                        {
     316                                                                                firstChar.focus();
     317                                                                                onFocus( null, firstChar );
     318                                                                        });
     319                                                                },
     320                                                                onLoad : function( event )
     321                                                                {
     322                                                                        dialog = event.sender;
     323                                                                }
     324                                                        },
     325                                                        {
     326                                                                type : 'hbox',
     327                                                                align : 'top',
     328                                                                widths : [ '100%' ],
     329                                                                children :
     330                                                                [
     331                                                                        {
     332                                                                                type : 'vbox',
     333                                                                                align : 'top',
     334                                                                                children :
     335                                                                                [
     336                                                                                        {
     337                                                                                                type : 'html',
     338                                                                                                html : '<div></div>'
     339                                                                                        },
     340                                                                                        {
     341                                                                                                type : 'html',
     342                                                                                                id : 'charPreview',
     343                                                                                                style : 'border:1px solid #eeeeee;background-color:#EAEAD1;font-size:28px;height:40px;width:70px;padding-top:9px;font-family:\'Microsoft Sans Serif\',Arial,Helvetica,Verdana;text-align:center;',
     344                                                                                                html : '<div>&nbsp;</div>'
     345                                                                                        },
     346                                                                                        {
     347                                                                                                type : 'html',
     348                                                                                                id : 'htmlPreview',
     349                                                                                                style : 'border:1px solid #eeeeee;background-color:#EAEAD1;font-size:14px;height:20px;width:70px;padding-top:2px;font-family:\'Microsoft Sans Serif\',Arial,Helvetica,Verdana;text-align:center;',
     350                                                                                                html : '<div>&nbsp;</div>'
     351                                                                                        }
     352                                                                                ]
     353                                                                        }
     354                                                                ]
     355                                                        }
     356                                                ]
     357                                        }
     358                                ]
     359                        }
     360                ]
     361        };
     362} );
  • test/_assets/plugins/specialchar/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @file Special Character plugin
     8 */
     9
     10CKEDITOR.plugins.add( 'specialchar',
     11{
     12        init : function( editor )
     13        {
     14                var pluginName = 'specialchar';
     15
     16                // Register the dialog.
     17                CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/specialchar.js' );
     18
     19                // Register the command.
     20                editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );
     21
     22                // Register the toolbar button.
     23                editor.ui.addButton( 'SpecialChar',
     24                        {
     25                                label : editor.lang.specialChar.toolbar,
     26                                command : pluginName
     27                        });
     28        }
     29} );
  • test/test.js

     
    5252                if ( !tempDir.mkdir() )
    5353                        error( "Can't create temp directory: " + tempDir );
    5454
    55                 var tests = [ 'directives', 'skins', 'samples', 'bom', 'lineendings' ];
     55                var tests = [ 'directives', 'skins', 'samples', 'bom', 'lineendings', 'plugins' ];
    5656
    5757                for ( var i = 0 ; i < tests.length ; i++ )
    5858                {
     
    283283                                        'releaser.directives[' + testName + ']' );
    284284                }
    285285        }
    286        
     286
     287        function listFiles( file )
     288        {
     289                var result = [];
     290
     291                if ( file.isDirectory() )
     292                {
     293                        var children = file.list();
     294                        if ( !children.length )
     295                        {
     296                                result.push( file );
     297                        }
     298                        else
     299                        {
     300                                for ( var i = 0 ; i < children.length ; i++ )
     301                                {
     302                                        result.push( listFiles( new File( file, children[i] ) ) );
     303                                }
     304                        }
     305                }
     306                else
     307                {
     308                        result.push( file );
     309                }
     310
     311                return result;
     312        }
     313
     314        function testCopyFiles()
     315        {
     316                print( "\nTesting copying files...\n" );
     317                var releaser = new CKRELEASER.releaser();
     318                CKRELEASER.sourceDir = ".";
     319                CKRELEASER.releaseDir = ".";
     320                CKRELEASER.release.ignore = [ '.svn' ];
     321                CKRELEASER.release.copy =
     322                [
     323                        {
     324                                source : '_assets/plugins',
     325                                target : 'tmp/plugins',
     326                                ignore : {
     327                                        sourcePackage : 'test.pack',
     328                                        files : 'packages[1].files'
     329                                }
     330                        }
     331                ];
     332                releaser.copyFiles();
     333                var files = listFiles(new File(".", "tmp/plugins"));
     334                var validResult = [
     335                        './tmp/plugins/forms/dialogs/button.js',
     336                        './tmp/plugins/forms/dialogs/checkbox.js',
     337                        './tmp/plugins/forms/dialogs/form.js',
     338                        './tmp/plugins/forms/plugin.js',
     339                        './tmp/plugins/horizontalrule/plugin.js',
     340                        './tmp/plugins/specialchar/dialogs/specialchar.js'];
     341
     342                assertEquals( files.length, 3, "Comparing plugins directories (same number of subfolders/files?)" );
     343                var areEqual = files.toString().replace(/\\/g, "/") == validResult.toString();
     344                assertEquals( true, areEqual, "Comparing plugins directories (are equal?)" );
     345        }
    287346        prepareTempDirs();
    288347        testDirectives();
    289348        testSkins();
     
    291350        testRemoveComments();
    292351        testBom();
    293352        testLineEndings();
     353        testCopyFiles();
    294354
    295355        print( '' );
    296356        print( 'Finished: ' + passCount + ' passed / ' + failCount + ' failed' );
  • test/test.pack

     
     1/*
     2 * CKPackager - Sample Package file
     3 */
     4
     5header :
     6        '/*'                                                                                                                                                    + '\n' +
     7        'Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.'   + '\n' +
     8        'For licensing, see LICENSE.html or http://ckeditor.com/license'                                + '\n' +
     9        '*/'                                                                                                                                                    + '\n' +
     10        '\n',
     11
     12noCheck : false,
     13
     14constants :
     15        {
     16                'CKEDITOR.ELEMENT_MODE_NONE' : 0,
     17                'CKEDITOR.ELEMENT_MODE_REPLACE' : 1,
     18                'CKEDITOR.ELEMENT_MODE_APPENDTO' : 2,
     19                'CKEDITOR.CTRL' : 1000,
     20                'CKEDITOR.SHIFT' : 2000,
     21                'CKEDITOR.ALT' : 4000,
     22                'CKEDITOR.NODE_ELEMENT' : 1,
     23                'CKEDITOR.NODE_TEXT' : 3,
     24                'CKEDITOR.NODE_COMMENT' : 8,
     25                'CKEDITOR.NODE_DOCUMENT_FRAGMENT' : 11,
     26                'CKEDITOR.POSITION_IDENTICAL' : 0,
     27                'CKEDITOR.POSITION_DISCONNECTED' : 1,
     28                'CKEDITOR.POSITION_FOLLOWING' : 2,
     29                'CKEDITOR.POSITION_PRECEDING' : 4,
     30                'CKEDITOR.POSITION_IS_CONTAINED' : 8,
     31                'CKEDITOR.POSITION_CONTAINS' : 16,
     32                'CKEDITOR.ENTER_P' : 1,
     33                'CKEDITOR.ENTER_BR' : 2,
     34                'CKEDITOR.ENTER_DIV' : 3,
     35                'CKEDITOR.TRISTATE_ON' : 1,
     36                'CKEDITOR.TRISTATE_OFF' : 2,
     37                'CKEDITOR.TRISTATE_DISABLED' : 0,
     38                'CKEDITOR.POSITION_AFTER_START' : 1,
     39                'CKEDITOR.POSITION_BEFORE_END' : 2,
     40                'CKEDITOR.POSITION_BEFORE_START' : 3,
     41                'CKEDITOR.POSITION_AFTER_END' : 4,
     42                'CKEDITOR.ENLARGE_ELEMENT' : 1,
     43                'CKEDITOR.ENLARGE_BLOCK_CONTENTS' : 2,
     44                'CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS' : 3,
     45                'CKEDITOR.START' : 1,
     46                'CKEDITOR.END' : 2,
     47                'CKEDITOR.STARTEND' : 3,
     48                'CKEDITOR.UI_BUTTON' : 1,
     49                'CKEDITOR.STYLE_BLOCK' : 1,
     50                'CKEDITOR.STYLE_INLINE' : 2,
     51                'CKEDITOR.STYLE_OBJECT' : 3,
     52                'CKEDITOR.UI_PANELBUTTON' : 4,
     53                'CKEDITOR.SELECTION_NONE' : 1,
     54                'CKEDITOR.SELECTION_TEXT' : 2,
     55                'CKEDITOR.SELECTION_ELEMENT' : 3,
     56                'CKEDITOR.UI_RICHCOMBO' : 3,
     57                'CKEDITOR.UI_MENUBUTTON' : 5,
     58                'CKEDITOR.DIALOG_RESIZE_NONE' : 0,
     59                'CKEDITOR.DIALOG_RESIZE_WIDTH' : 1,
     60                'CKEDITOR.DIALOG_RESIZE_HEIGHT' : 2,
     61                'CKEDITOR.DIALOG_RESIZE_BOTH' : 3,
     62                'CKEDITOR.VALIDATE_OR' : 1,
     63                'CKEDITOR.VALIDATE_AND' : 2,
     64                'CKEDITOR.UI_PANEL' : 2
     65        },
     66
     67packages :
     68        [
     69                {
     70                        output : 'ckeditor_basic.js',
     71                        wrap : true,
     72                        files :
     73                                [
     74                                        '_source/core/ckeditor_base.js',
     75                                        '_source/core/event.js',
     76                                        '_source/core/editor_basic.js',
     77                                        '_source/core/env.js',
     78                                        '_source/core/ckeditor_basic.js'
     79                                ]
     80                },
     81
     82                {
     83                        output : 'ckeditor.js',
     84                        wrap : true,
     85                        files :
     86                                [
     87                                        '_source/core/dom/text.js',
     88                                        '_source/core/dom/documentfragment.js',
     89                                        '_source/core/dom/walker.js',
     90                                        '_source/core/dom/range.js',
     91                                        '_source/core/_bootstrap.js',
     92                                        'plugins/about/plugin.js',
     93                                        'plugins/format/plugin.js',
     94                                        'plugins/font/plugin.js',
     95                                        'plugins/basicstyles/plugin.js',
     96                                        'plugins/specialchar/plugin.js',
     97                                        '_source/skins/kama/skin.js',
     98                                        '_source/themes/default/theme.js'
     99                                ]
     100                }
     101
     102        ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy