Ticket #3771: 3771.patch

File 3771.patch, 14.9 KB (added by Wiktor Walc, 14 years ago)
  • _source/includes/samplesprocessor.js

     
    5858                node.html = document.getElementById( 'html' );
    5959                node.code = document.getElementById( 'code' );
    6060
    61                 if ( !node.html || !node.code )
     61                if ( !node.html )
    6262                {
    6363                        //Not a xml template, probably index.html or documentation.
    6464                        if ( CKRELEASER.verbose )
    65                                 print( "    WARNING: File with .html extension does not contain all necessary elements (html, code): "
     65                                print( "    WARNING: File with .html extension does not contain all necessary elements (html): "
    6666                                                + sourceLocation.getName() );
    6767
    6868                        if ( sourceLocation.getAbsolutePath() != templateLocation.getAbsolutePath() )
     
    7171                }
    7272
    7373                node.html = newDocument.importNode( node.html, true );
    74                 node.code = newDocument.importNode( node.code, true );
     74                if ( node.code )
     75                        node.code = newDocument.importNode( node.code, true );
    7576
    7677                if ( newDocument.getElementById( 'html' ) )
    7778                        CKRELEASER.xml.replaceNodeWithNodes( newDocument, newDocument.getElementById( 'html' ), node.html.getChildNodes() );
    78                 if ( newDocument.getElementById( 'code' ) )
     79                if ( node.code && newDocument.getElementById( 'code' ) )
    7980                        CKRELEASER.xml.replaceNodeWithNodes( newDocument, newDocument.getElementById( 'code' ), node.code.getChildNodes() );
    8081
    8182                node.styles = document.getElementById( 'styles' );
     
    159160                                return;
    160161
    161162                        if ( sourceLocation.getAbsolutePath().toLowerCase().endsWith( ".html" ) )
     163                        {
    162164                                processXmlFile( sourceLocation, targetLocation );
     165                                if ( CKRELEASER.verbose )
     166                                        print( 'Processing sample: ' + sourceLocation );
     167                        }
    163168                        else
    164169                                CKRELEASER.io.copy( sourceLocation, targetLocation );
    165170
  • test/_assets/samples/api_dialog.correct.txt

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2<!--
     3Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     4For licensing, see LICENSE.html or http://ckeditor.com/license
     5-->
     6<html xmlns="http://www.w3.org/1999/xhtml">
     7<head>
     8        <title>Sample - CKEditor</title>
     9        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
     10<!-- CKReleaser %REMOVE_LINE%
     11        <script type="text/javascript" src="../ckeditor.js"></script>
     12CKReleaser %REMOVE_LINE% -->
     13        <script src="../ckeditor_source.js" type="text/javascript"></script> <!-- CKReleaser %REMOVE_LINE% -->
     14<!--
     15        ## Uncomment this if loading the "basic" version.
     16
     17        <script type="text/javascript" src="../_source/core/loader.js"></script>
     18        <script type="text/javascript">
     19        //<![CDATA[
     20
     21// Loaded dependencies of sample.js.
     22CKEDITOR.loader.load( 'core/ajax' );
     23CKEDITOR.loader.load( 'core/env' );
     24
     25        //]]>
     26        </script>
     27-->
     28        <script src="sample.js" type="text/javascript"></script>
     29        <link href="sample.css" rel="stylesheet" type="text/css"/>
     30        <style id="styles" type="text/css">
     31
     32.cke_button_myDialogCmd .cke_icon
     33{
     34        display : none !important;
     35}
     36
     37.cke_button_myDialogCmd .cke_label
     38{
     39        display : inline !important;
     40}
     41
     42        </style>
     43        <script id="headscript" type="text/javascript">
     44        //<![CDATA[
     45
     46// When opening a dialog, its "definition" is created for it, for
     47// each editor instance. The "dialogDefinition" event is then
     48// fired. We should use this event to make customizations to the
     49// definition of existing dialogs.
     50CKEDITOR.on( 'dialogDefinition', function( ev )
     51        {
     52                // Take the dialog name and its definition from the event
     53                // data.
     54                var dialogName = ev.data.name;
     55                var dialogDefinition = ev.data.definition;
     56
     57                // Check if the definition is from the dialog we're
     58                // interested on (the "Link" dialog).
     59                if ( dialogName == 'link' )
     60                {
     61                        // Get a reference to the "Link Info" tab.
     62                        var infoTab = dialogDefinition.getContents( 'info' );
     63
     64                        // Add a text field to the "info" tab.
     65                        infoTab.add( {
     66                                        type : 'text',
     67                                        label : 'My Custom Field',
     68                                        id : 'customField',
     69                                        'default' : 'Sample!',
     70                                        validate : function()
     71                                        {
     72                                                if ( /\d/.test( this.getValue() ) )
     73                                                        return 'My Custom Field must not contain digits';
     74                                        }
     75                                });
     76
     77                        // Remove the "Link Type" combo and the "Browser
     78                        // Server" button from the "info" tab.
     79                        infoTab.remove( 'linkType' );
     80                        infoTab.remove( 'browse' );
     81
     82                        // Set the default value for the URL field.
     83                        var urlField = infoTab.get( 'url' );
     84                        urlField['default'] = 'www.example.com';
     85
     86                        // Remove the "Target" tab from the "Link" dialog.
     87                        dialogDefinition.removeContents( 'target' );
     88
     89                        // Add a new tab to the "Link" dialog.
     90                        dialogDefinition.addContents({
     91                                id : 'customTab',
     92                                label : 'My Tab',
     93                                accessKey : 'M',
     94                                elements : [
     95                                        {
     96                                                id : 'myField1',
     97                                                type : 'text',
     98                                                label : 'My Text Field'
     99                                        },
     100                                        {
     101                                                id : 'myField2',
     102                                                type : 'text',
     103                                                label : 'Another Text Field'
     104                                        }
     105                                ]
     106                        });
     107                }
     108        });
     109
     110        //]]>
     111        </script>
     112</head>
     113<body>
     114        <h1>
     115                CKEditor Sample
     116        </h1>
     117        <!-- This <div> holds alert messages to be display in the sample page. -->
     118        <div id="alerts">
     119                <noscript>
     120                        <p>
     121                                <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
     122                                support, like yours, you should still see the contents (HTML data) and you should
     123                                be able to edit it normally, without a rich editor interface.
     124                        </p>
     125                </noscript>
     126        </div>
     127        <!-- This <fieldset> holds the HTML that you will usually find in your
     128             pages. -->
     129        <fieldset title="Output">
     130                <legend>Output</legend>
     131                <p>
     132                        This sample shows how to use the dialog API to customize dialogs whithout changing
     133                        the original editor code. The following customizations are being done::</p>
     134                <ol>
     135                        <li><strong>Add dialog pages</strong> ("My Tab" in the Link dialog).</li>
     136                        <li><strong>Remove a dialog tab</strong> ("Target" tab from the Link dialog).</li>
     137                        <li><strong>Add dialog fields</strong> ("My Custom Field" into the Link dialog).</li>
     138                        <li><strong>Remove dialog fields</strong> ("Link Type" and "Browser Server" the Link dialog).</li>
     139                        <li><strong>Set default values for dialog fields</strong> (for the "URL" field in the
     140                                Link dialog). </li>
     141                        <li><strong>Create a custom dialog</strong> ("My Dialog" button).</li>
     142                </ol>
     143                <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
     144                <script type="text/javascript">
     145                //<![CDATA[
     146                        // Replace the <textarea id="editor1"> with an CKEditor instance.
     147                        var editor = CKEDITOR.replace( 'editor1',
     148                                {
     149                                        // Defines a simpler toolbar to be used in this sample.
     150                                        // Note that we have added out "MyButton" button here.
     151                                        toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike','-','Link', '-', 'MyButton' ] ]
     152                                });
     153
     154                        // Listen for the "pluginsLoaded" event, so we are sure that the
     155                        // "dialog" plugin has been loaded and we are able to do our
     156                        // customizations.
     157                        editor.on( 'pluginsLoaded', function( ev )
     158                                {
     159                                        // If our custom dialog has not been registered, do that now.
     160                                        if ( !CKEDITOR.dialog.exists( 'myDialog' ) )
     161                                        {
     162                                                // We need to do the following trick to find out the dialog
     163                                                // definition file URL path. In the real world, you would simply
     164                                                // point to an absolute path directly, like "/mydir/mydialog.js".
     165                                                var href = document.location.href.split( '/' );
     166                                                href.pop();
     167                                                href.push( 'api_dialog', 'my_dialog.js' );
     168                                                href = href.join( '/' );
     169
     170                                                // Finally, register the dialog.
     171                                                CKEDITOR.dialog.add( 'myDialog', href );
     172                                        }
     173
     174                                        // Register the command used to open the dialog.
     175                                        editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) );
     176
     177                                        // Add the a custom toolbar buttons, which fires the above
     178                                        // command..
     179                                        editor.ui.addButton( 'MyButton',
     180                                                {
     181                                                        label : 'My Dialog',
     182                                                        command : 'myDialogCmd'
     183                                                } );
     184                                });
     185                //]]>
     186                </script>
     187        </fieldset>
     188        <!-- This <fieldset> contains the output readable code that illustrates
     189             how to use the editor, having the results shown in this sample. -->
     190        <fieldset title="Code">
     191                <legend>Code</legend>
     192                <script id="code" type="text/javascript">
     193                //<![CDATA[
     194                        document.write( CKEDITOR.samples.codeData );
     195                //]]>
     196                </script>
     197        </fieldset>
     198        <div id="footer">
     199                <hr/>
     200                <p>
     201                        CKEditor - The text editor for Internet - <a href="http://ckeditor.com/" shape="rect">http://ckeditor.com</a>
     202                </p>
     203                <p id="copy">
     204                        Copyright © 2003-2009, <a href="http://cksource.com/" shape="rect">CKSource</a> - Frederico Knabben. All rights reserved.
     205                </p>
     206        </div>
     207</body>
     208</html>
  • test/_assets/samples/api_dialog.html

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2<!--
     3Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     4For licensing, see LICENSE.html or http://ckeditor.com/license
     5-->
     6<html xmlns="http://www.w3.org/1999/xhtml">
     7<head>
     8        <title>Replace Textarea by Code - CKEditor Sample</title>
     9        <script type="text/javascript" src="sample.js"></script>
     10        <style id="styles" type="text/css">
     11
     12.cke_button_myDialogCmd .cke_icon
     13{
     14        display : none !important;
     15}
     16
     17.cke_button_myDialogCmd .cke_label
     18{
     19        display : inline !important;
     20}
     21
     22        </style>
     23        <script id="headscript" type="text/javascript">
     24        //<![CDATA[
     25
     26// When opening a dialog, its "definition" is created for it, for
     27// each editor instance. The "dialogDefinition" event is then
     28// fired. We should use this event to make customizations to the
     29// definition of existing dialogs.
     30CKEDITOR.on( 'dialogDefinition', function( ev )
     31        {
     32                // Take the dialog name and its definition from the event
     33                // data.
     34                var dialogName = ev.data.name;
     35                var dialogDefinition = ev.data.definition;
     36
     37                // Check if the definition is from the dialog we're
     38                // interested on (the "Link" dialog).
     39                if ( dialogName == 'link' )
     40                {
     41                        // Get a reference to the "Link Info" tab.
     42                        var infoTab = dialogDefinition.getContents( 'info' );
     43
     44                        // Add a text field to the "info" tab.
     45                        infoTab.add( {
     46                                        type : 'text',
     47                                        label : 'My Custom Field',
     48                                        id : 'customField',
     49                                        'default' : 'Sample!',
     50                                        validate : function()
     51                                        {
     52                                                if ( /\d/.test( this.getValue() ) )
     53                                                        return 'My Custom Field must not contain digits';
     54                                        }
     55                                });
     56
     57                        // Remove the "Link Type" combo and the "Browser
     58                        // Server" button from the "info" tab.
     59                        infoTab.remove( 'linkType' );
     60                        infoTab.remove( 'browse' );
     61
     62                        // Set the default value for the URL field.
     63                        var urlField = infoTab.get( 'url' );
     64                        urlField['default'] = 'www.example.com';
     65
     66                        // Remove the "Target" tab from the "Link" dialog.
     67                        dialogDefinition.removeContents( 'target' );
     68
     69                        // Add a new tab to the "Link" dialog.
     70                        dialogDefinition.addContents({
     71                                id : 'customTab',
     72                                label : 'My Tab',
     73                                accessKey : 'M',
     74                                elements : [
     75                                        {
     76                                                id : 'myField1',
     77                                                type : 'text',
     78                                                label : 'My Text Field'
     79                                        },
     80                                        {
     81                                                id : 'myField2',
     82                                                type : 'text',
     83                                                label : 'Another Text Field'
     84                                        }
     85                                ]
     86                        });
     87                }
     88        });
     89
     90        //]]>
     91        </script>
     92</head>
     93<body>
     94        <div id="html">
     95                <p>
     96                        This sample shows how to use the dialog API to customize dialogs whithout changing
     97                        the original editor code. The following customizations are being done::</p>
     98                <ol>
     99                        <li><strong>Add dialog pages</strong> ("My Tab" in the Link dialog).</li>
     100                        <li><strong>Remove a dialog tab</strong> ("Target" tab from the Link dialog).</li>
     101                        <li><strong>Add dialog fields</strong> ("My Custom Field" into the Link dialog).</li>
     102                        <li><strong>Remove dialog fields</strong> ("Link Type" and "Browser Server" the Link dialog).</li>
     103                        <li><strong>Set default values for dialog fields</strong> (for the "URL" field in the
     104                                Link dialog). </li>
     105                        <li><strong>Create a custom dialog</strong> ("My Dialog" button).</li>
     106                </ol>
     107                <textarea id="editor1" name="editor1" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
     108                <script type="text/javascript">
     109                //<![CDATA[
     110                        // Replace the <textarea id="editor1"> with an CKEditor instance.
     111                        var editor = CKEDITOR.replace( 'editor1',
     112                                {
     113                                        // Defines a simpler toolbar to be used in this sample.
     114                                        // Note that we have added out "MyButton" button here.
     115                                        toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike','-','Link', '-', 'MyButton' ] ]
     116                                });
     117
     118                        // Listen for the "pluginsLoaded" event, so we are sure that the
     119                        // "dialog" plugin has been loaded and we are able to do our
     120                        // customizations.
     121                        editor.on( 'pluginsLoaded', function( ev )
     122                                {
     123                                        // If our custom dialog has not been registered, do that now.
     124                                        if ( !CKEDITOR.dialog.exists( 'myDialog' ) )
     125                                        {
     126                                                // We need to do the following trick to find out the dialog
     127                                                // definition file URL path. In the real world, you would simply
     128                                                // point to an absolute path directly, like "/mydir/mydialog.js".
     129                                                var href = document.location.href.split( '/' );
     130                                                href.pop();
     131                                                href.push( 'api_dialog', 'my_dialog.js' );
     132                                                href = href.join( '/' );
     133
     134                                                // Finally, register the dialog.
     135                                                CKEDITOR.dialog.add( 'myDialog', href );
     136                                        }
     137
     138                                        // Register the command used to open the dialog.
     139                                        editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) );
     140
     141                                        // Add the a custom toolbar buttons, which fires the above
     142                                        // command..
     143                                        editor.ui.addButton( 'MyButton',
     144                                                {
     145                                                        label : 'My Dialog',
     146                                                        command : 'myDialogCmd'
     147                                                } );
     148                                });
     149                //]]>
     150                </script>
     151        </div>
     152</body>
     153</html>
  • test/test.js

     
    66( function()
    77{
    88        var releaser = new CKRELEASER.releaser();
     9        CKRELEASER.verbose = true;
    910
    1011        // Run tests.
    1112        var passCount = 0, failCount = 0;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy