| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <!-- |
| 3 | Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. |
| 4 | For 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"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></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.message; // The message |
| 51 | spans[1].innerHTML = evt.data.type; // 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.message; // The message |
| 70 | spans[1].innerHTML = evt.data.where; // 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.result = 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.result = 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 © 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> </span><br /> |
| 110 | Called at: <span> </span><br /> |
| 111 | <button id="confirmDialogOk">OK</button> <button id="confirmDialogCancel">Cancel</button> |
| 112 | </div> |
| 113 | <div id="alertDialog"> |
| 114 | An error occurred: <span> </span><br /> |
| 115 | Type: <span> </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 |