Ticket #5291: 5291_2.patch

File 5291_2.patch, 6.3 KB (added by Sa'ar Zac Elias, 14 years ago)
  • _samples/ui_usererror.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-2010, 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>User Defined UI In Alerts - CKEditor Sample</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>
     12        CKReleaser %REMOVE_START% -->
     13        <script type="text/javascript" src="../ckeditor_source.js"></script>
     14        <!-- CKReleaser %REMOVE_END% -->
     15        <script src="sample.js" type="text/javascript"></script>
     16        <link href="sample.css" rel="stylesheet" type="text/css" />
     17</head>
     18<body>
     19        <h1>
     20                CKEditor Sample
     21        </h1>
     22        <!-- This <div> holds alert messages to be display in the sample page. -->
     23        <div id="alerts">
     24                <noscript>
     25                        <p>
     26                                <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
     27                                support, like yours, you should still see the contents (HTML data) and you should
     28                                be able to edit it normally, without a rich editor interface.
     29                        </p>
     30                </noscript>
     31        </div>
     32        <form action="sample_posteddata.php" method="post">
     33                <p>
     34                        <label for="editor1">
     35                                Editor 1:</label><br />
     36                        <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://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
     37                        <script type="text/javascript">
     38                        //<![CDATA[
     39                                //Remove the event's internal listener
     40                                CKEDITOR.on( 'instanceCreated', function( evt )
     41                                {
     42                                        evt.editor.removeListeners( 'alert' );
     43                                        evt.editor.removeListeners( 'confirm' );
     44                                });
     45                                CKEDITOR.replace( 'editor1', {
     46                                        on : {
     47                                                'alert' : function( evt )
     48                                                {
     49                                                        alert( "An error occurred!\nError type: " + evt.data.errorType + "\nError string: " + evt.data.errorString );
     50                                                },
     51                                                'confirm' : function ( evt )
     52                                                {
     53                                                        evt.data.status = confirm( "Please confirm the following:\n" + evt.data.confirmString
     54                                                                + "\nCalled at: " + evt.data.confirmAt );
     55                                                }
     56                                        }
     57                                });
     58
     59                        //]]>
     60                        </script>
     61                </p>
     62                <p>
     63                        <input type="submit" value="Submit" />
     64                </p>
     65        </form>
     66        <div id="footer">
     67                <hr />
     68                <p>
     69                        CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
     70                </p>
     71                <p id="copy">
     72                        Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico
     73                        Knabben. All rights reserved.
     74                </p>
     75        </div>
     76</body>
     77</html>
  • _source/core/editor.js

     
    410410                         */
    411411                        this.focusManager = new CKEDITOR.focusManager( this );
    412412
     413                        // Set default handlers for alert and confirm
     414                        this.on( 'alert', function( evt )
     415                        {
     416                                window.alert( evt.data.errorString );
     417                        });
     418                        this.on( 'confirm', function( evt )
     419                        {
     420                                evt.data.status = window.confirm( evt.data.confirmString );
     421                        });
     422
    413423                        CKEDITOR.fire( 'instanceCreated', null, this );
    414424
    415425                        this.on( 'mode', updateCommandsMode, null, null, 1 );
     
    758768 * @name CKEDITOR#pluginsLoaded
    759769 * @event
    760770 */
     771
     772/**
     773 * Fired when there is a message to display to the user.
     774 * @name CKEDITOR#alert
     775 * @event
     776 */
     777
     778/**
     779 * Fired when the user need to confirm something. the data object 'status' determines the result.
     780 * @name CKEDITOR#confirm
     781 * @event
     782 */
     783 No newline at end of file
  • _source/core/event.js

     
    318318                        },
    319319
    320320                        /**
     321                         * Unregisters all listeners of the specified event.
     322                         * @param {String} eventName The event name.
     323                         * @example
     324                         * var myListener = function() { ... };
     325                         * var myListener1 = function() { ... };
     326                         * someObject.on( 'someEvent', myListener );
     327                         * someObject.on( 'someEvent', myListener1 );
     328                         * someObject.fire( 'someEvent' );  // Both listeners are called
     329                         * <b>someObject.removeListeners( 'someEvent' )</b>;
     330                         * someObject.fire( 'someEvent' );  // No listeners are called
     331                         */
     332                        removeListeners : function( eventName )
     333                        {
     334                                var event = getPrivate( this )[ eventName ] || {};
     335                                event.listeners && ( event.listeners = [] );
     336                        },
     337
     338                        /**
    321339                         * Checks if there is any listener registered to a given event.
    322340                         * @param {String} eventName The event name.
    323341                         * @example
  • _source/plugins/dialog/plugin.js

     
    237237                                        {
    238238                                                if ( item.isChanged() )
    239239                                                {
    240                                                         if ( !confirm( editor.lang.common.confirmCancel ) )
     240                                                        var confirmation = editor.fire( 'confirm', {
     241                                                                confirmString : editor.lang.common.confirmCancel,
     242                                                                confirmAt : 'dialog_cancel',
     243                                                                status : true
     244                                                        }).status;
     245                                                        if ( !confirmation )
    241246                                                                evt.data.hide = false;
    242247                                                        return true;
    243248                                                }
  • _source/plugins/find/dialogs/find.js

     
    604604                                                                                                        dialog.getValueOf( 'find', 'txtFindCaseChk' ),
    605605                                                                                                        dialog.getValueOf( 'find', 'txtFindWordChk' ),
    606606                                                                                                        dialog.getValueOf( 'find', 'txtFindCyclic' ) ) )
    607                                                                                         alert( editor.lang.findAndReplace
    608                                                                                                 .notFoundMsg );
     607                                                                                        editor.fire( 'alert', {
     608                                                                                                errorString : editor.lang.findAndReplace.notFoundMsg,
     609                                                                                                errorType : 'findandreplace_notfound'
     610                                                                                        });
    609611                                                                        }
    610612                                                                }
    611613                                                        ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy