Ticket #5291: 5291_3.patch

File 5291_3.patch, 11.5 KB (added by Sa'ar Zac Elias, 14 years ago)
  • _samples/sample.css

     
    7979        white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
    8080        word-wrap: break-word; /* IE */
    8181}
     82#overlay {
     83        display: none;
     84        width: 100%;
     85        height: 100%;
     86        background-color: #000000;;
     87        position: absolute;
     88        top: 0px;
     89        left: 0px;
     90        filter: alpha(opacity=60);
     91        -moz-opacity: 0.6;
     92        opacity: 0.6;
     93        text-align: center;
     94        padding: 0px;
     95}
     96#alertDialog, #confirmDialog {
     97        display: none;
     98        background-color: #ffffff;
     99        width: 50%;
     100        height: 100px;
     101        position: absolute;
     102        top: 150px;
     103        text-align: left;
     104        margin-left: auto;
     105        margin-right: auto;
     106}
     107#alertDialog button, #confirmDialog button {
     108        float: right;
     109        width: 150px;
     110        border: 1px solid white;
     111        color: #ffffff;
     112        margin: 1px;
     113        height: 20px;
     114        position: relative;
     115        top: 40px;
     116        cursor: pointer;
     117}
     118#alertDialogButton, #confirmDialogOk {
     119        background-color: #339933;
     120}
     121#confirmDialogCancel {
     122        background-color: #ff0000;
     123}
     124 No newline at end of file
  • _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                                CKEDITOR.replace( 'editor1', {
     40                                        on : {
     41                                                'alert' : function( evt )
     42                                                {
     43                                                        // Use an user-defined UI for alerts.
     44                                                        overlay.style.display = 'block';
     45                                                        overlay.style.zIndex = evt.editor.config.baseFloatZIndex + 100;
     46                                                        alertDialog.style.display = 'block';
     47                                                        alertDialog.style.zIndex = evt.editor.config.baseFloatZIndex + 200;
     48                                                        alertDialog.style.left = ( ( pageWidth - parseInt( alertDialog.offsetWidth, 10 ) ) / 2 ) + 'px';
     49                                                        var spans = alertDialog.getElementsByTagName( 'span' );
     50                                                        spans[0].innerHTML = evt.data.errorString; // The message
     51                                                        spans[1].innerHTML = evt.data.errorType; // The alert type, e.g. 'find_notfound'
     52                                                        document.getElementById( 'alertDialogButton' ).onclick = function()
     53                                                        {
     54                                                                alertDialog.style.display = 'none';
     55                                                                overlay.style.display = 'none';
     56                                                                evt.data.callback && ( evt.data.callback.call( evt ) ); // Execute the callback if exists
     57                                                        };
     58                                                        evt.stop(); // Cancel the default event handler
     59                                                },
     60                                                'confirm' : function ( evt )
     61                                                {
     62                                                        // Use an user-defined UI for alerts.
     63                                                        overlay.style.display = 'block';
     64                                                        overlay.style.zIndex = evt.editor.config.baseFloatZIndex + 100;
     65                                                        confirmDialog.style.display = 'block';
     66                                                        confirmDialog.style.zIndex = evt.editor.config.baseFloatZIndex + 200;
     67                                                        confirmDialog.style.left = ( ( pageWidth - parseInt( confirmDialog.offsetWidth, 10 ) ) / 2 ) + 'px';
     68                                                        var spans = confirmDialog.getElementsByTagName( 'span' );
     69                                                        spans[0].innerHTML = evt.data.confirmString; // The message
     70                                                        spans[1].innerHTML = evt.data.confirmAt; // The place where the confirmation is needed, e.g. dialog_cancel
     71                                                        document.getElementById( 'confirmDialogCancel' ).onclick = function()
     72                                                        {
     73                                                                confirmDialog.style.display = 'none';
     74                                                                overlay.style.display = 'none';
     75                                                                evt.data.hide = false; // Hide the dialog
     76                                                                evt.data.callback && ( evt.data.callback.call( evt ) ); // Execute the callback if exists
     77                                                        };
     78                                                        document.getElementById( 'confirmDialogOk' ).onclick = function()
     79                                                        {
     80                                                                confirmDialog.style.display = 'none';
     81                                                                overlay.style.display = 'none';
     82                                                                evt.data.hide = true; // Do not hide the dialog
     83                                                                evt.data.callback && ( evt.data.callback.call( evt ) ); // Execute the callback if exists
     84                                                        };
     85                                                        evt.stop(); // Cancel the default event handler
     86                                                }
     87                                        }
     88                                });
     89
     90                        //]]>
     91                        </script>
     92                </p>
     93                <p>
     94                        <input type="submit" value="Submit" />
     95                </p>
     96        </form>
     97        <div id="footer">
     98                <hr />
     99                <p>
     100                        CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
     101                </p>
     102                <p id="copy">
     103                        Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico
     104                        Knabben. All rights reserved.
     105                </p>
     106        </div>
     107        <div id="overlay"></div>
     108        <div id="confirmDialog">
     109                Confirmation required: <span>&nbsp;</span><br />
     110                Called at: <span>&nbsp;</span><br />
     111                <button id="confirmDialogOk">OK</button> <button id="confirmDialogCancel">Cancel</button>
     112        </div>
     113        <div id="alertDialog">
     114                An error occurred: <span>&nbsp;</span><br />
     115                Type: <span>&nbsp;</span><br />
     116                <button id="alertDialogButton">OK</button>
     117        </div>
     118        <script type="text/javascript">
     119        //<![CDATA[
     120                var     overlay = document.getElementById( 'overlay' ),
     121                        alertDialog = document.getElementById( 'alertDialog' ),
     122                        confirmDialog = document.getElementById( 'confirmDialog' );
     123                if ( window.innerWidth )
     124                        pageWidth = window.innerWidth;
     125                else if ( document.documentElement && document.documentElement.clientWidth )
     126                        pageWidth = document.documentElement.clientWidth;
     127                else
     128                        pageWidth = document.body.clientWidth;
     129        //]]>
     130        </script>
     131</body>
     132</html>
     133 No newline at end of file
  • _source/plugins/dialog/plugin.js

     
    233233
    234234                this.on( 'cancel', function( evt )
    235235                        {
     236                                var isChanged = false;
    236237                                iterContents( function( item )
    237238                                        {
    238239                                                if ( item.isChanged() )
    239240                                                {
    240                                                         if ( !confirm( editor.lang.common.confirmCancel ) )
    241                                                                 evt.data.hide = false;
     241                                                        editor.fire( 'confirm', {
     242                                                                confirmString : editor.lang.common.confirmCancel,
     243                                                                confirmAt : 'dialog_cancel',
     244                                                                hide : true,
     245                                                                callback : function()
     246                                                                {
     247                                                                        if ( this.data.hide )
     248                                                                                me.hide();
     249                                                                }
     250                                                        });
     251                                                        isChanged = true;
    242252                                                        return true;
    243253                                                }
    244254                                        });
     255                                !isChanged && me.hide();
    245256                        }, this, null, 0 );
    246257
    247258                this.parts.close.on( 'click', function( evt )
    248259                                {
    249                                         if ( this.fire( 'cancel', { hide : true } ).hide !== false )
    250                                                 this.hide();
     260                                        this.fire( 'cancel' );
    251261                                }, this );
    252262
    253263                // Sort focus list according to tab order definitions.
     
    12351245                                                'class' : 'cke_dialog_ui_button_cancel',
    12361246                                                onClick : function( evt )
    12371247                                                {
    1238                                                         var dialog = evt.data.dialog;
    1239                                                         if ( dialog.fire( 'cancel', { hide : true } ).hide !== false )
    1240                                                                 dialog.hide();
     1248                                                        evt.data.dialog.fire( 'cancel' );
    12411249                                                }
    12421250                                        }, override, true );
    12431251                                };
  • _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 : 'find_notfound'
     610                                                                                        });
    609611                                                                        }
    610612                                                                }
    611613                                                        ]
     
    671673                                                                                                        dialog.getValueOf( 'replace', 'txtReplaceCaseChk' ),
    672674                                                                                                        dialog.getValueOf( 'replace', 'txtReplaceWordChk' ),
    673675                                                                                                        dialog.getValueOf( 'replace', 'txtReplaceCyclic' ) ) )
    674                                                                                         alert( editor.lang.findAndReplace
    675                                                                                                 .notFoundMsg );
     676                                                                                        editor.fire( 'alert', {
     677                                                                                                errorString : editor.lang.findAndReplace.notFoundMsg,
     678                                                                                                errorType : 'replace_notfound'
     679                                                                                        });
    676680                                                                        }
    677681                                                                }
    678682                                                        ]
     
    721725
    722726                                                                                if ( finder.replaceCounter )
    723727                                                                                {
    724                                                                                         alert( editor.lang.findAndReplace.replaceSuccessMsg.replace( /%1/, finder.replaceCounter ) );
    725                                                                                         editor.fire( 'saveSnapshot' );
     728                                                                                        editor.fire( 'alert', {
     729                                                                                                errorString : editor.lang.findAndReplace.replaceSuccessMsg.replace( /%1/, finder.replaceCounter ),
     730                                                                                                errorType : 'replace_success',
     731                                                                                                callback : function()
     732                                                                                                {
     733                                                                                                        editor.fire( 'saveSnapshot' );
     734                                                                                                }
     735                                                                                        });
    726736                                                                                }
    727737                                                                                else
    728                                                                                         alert( editor.lang.findAndReplace.notFoundMsg );
     738                                                                                        editor.fire( 'alert', {
     739                                                                                                errorString : editor.lang.findAndReplace.notFoundMsg,
     740                                                                                                errorType : 'replace_notfound'
     741                                                                                        });
    729742                                                                        }
    730743                                                                }
    731744                                                        ]
  • _source/themes/default/theme.js

     
    157157                        // Disable browser context menu for editor's chrome.
    158158                        container.disableContextMenu();
    159159
     160                        // Set default handlers for alert and confirm
     161                        editor.on( 'alert', function( evt )
     162                        {
     163                                window.alert( evt.data.errorString );
     164                                evt.data.callback && ( evt.data.callback.call( evt ) );
     165                        }, null, null, 20);
     166                        editor.on( 'confirm', function( evt )
     167                        {
     168                                evt.data.status = window.confirm( evt.data.confirmString );
     169                                evt.data.callback && ( evt.data.callback.call( evt ) );
     170                        }, null, null, 20);
     171
    160172                        editor.fireOnce( 'themeLoaded' );
    161173                        editor.fireOnce( 'uiReady' );
    162174                },
     
    333345 *     top : 'someElementId'
    334346 * };
    335347 */
     348
     349/**
     350 * Fired when there is a message to display to the user.
     351 * @name CKEDITOR#alert
     352 * @event
     353 */
     354
     355/**
     356 * Fired when the user need to confirm something. the data object 'status' determines the result.
     357 * @name CKEDITOR#confirm
     358 * @event
     359 */
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy