1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ckeditor/samples/old/dialog/dialog.html Thu Dec 15 18:10:20 2016 +0300
1.3 @@ -0,0 +1,190 @@
1.4 +<!DOCTYPE html>
1.5 +<!--
1.6 +Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
1.7 +For licensing, see LICENSE.md or http://ckeditor.com/license
1.8 +-->
1.9 +<html>
1.10 +<head>
1.11 + <meta charset="utf-8">
1.12 + <title>Using API to Customize Dialog Windows — CKEditor Sample</title>
1.13 + <script src="../../../ckeditor.js"></script>
1.14 + <link rel="stylesheet" href="../../../samples/old/sample.css">
1.15 + <meta name="ckeditor-sample-name" content="Using the JavaScript API to customize dialog windows">
1.16 + <meta name="ckeditor-sample-group" content="Advanced Samples">
1.17 + <meta name="ckeditor-sample-description" content="Using the dialog windows API to customize dialog windows without changing the original editor code.">
1.18 + <style>
1.19 +
1.20 + .cke_button__mybutton_icon
1.21 + {
1.22 + display: none !important;
1.23 + }
1.24 +
1.25 + .cke_button__mybutton_label
1.26 + {
1.27 + display: inline !important;
1.28 + }
1.29 +
1.30 + </style>
1.31 + <script>
1.32 +
1.33 + CKEDITOR.on( 'instanceCreated', function( ev ){
1.34 + var editor = ev.editor;
1.35 +
1.36 + // Listen for the "pluginsLoaded" event, so we are sure that the
1.37 + // "dialog" plugin has been loaded and we are able to do our
1.38 + // customizations.
1.39 + editor.on( 'pluginsLoaded', function() {
1.40 +
1.41 + // If our custom dialog has not been registered, do that now.
1.42 + if ( !CKEDITOR.dialog.exists( 'myDialog' ) ) {
1.43 + // We need to do the following trick to find out the dialog
1.44 + // definition file URL path. In the real world, you would simply
1.45 + // point to an absolute path directly, like "/mydir/mydialog.js".
1.46 + var href = document.location.href.split( '/' );
1.47 + href.pop();
1.48 + href.push( 'assets/my_dialog.js' );
1.49 + href = href.join( '/' );
1.50 +
1.51 + // Finally, register the dialog.
1.52 + CKEDITOR.dialog.add( 'myDialog', href );
1.53 + }
1.54 +
1.55 + // Register the command used to open the dialog.
1.56 + editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) );
1.57 +
1.58 + // Add the a custom toolbar buttons, which fires the above
1.59 + // command..
1.60 + editor.ui.add( 'MyButton', CKEDITOR.UI_BUTTON, {
1.61 + label: 'My Dialog',
1.62 + command: 'myDialogCmd'
1.63 + });
1.64 + });
1.65 + });
1.66 +
1.67 + // When opening a dialog, its "definition" is created for it, for
1.68 + // each editor instance. The "dialogDefinition" event is then
1.69 + // fired. We should use this event to make customizations to the
1.70 + // definition of existing dialogs.
1.71 + CKEDITOR.on( 'dialogDefinition', function( ev ) {
1.72 + // Take the dialog name and its definition from the event data.
1.73 + var dialogName = ev.data.name;
1.74 + var dialogDefinition = ev.data.definition;
1.75 +
1.76 + // Check if the definition is from the dialog we're
1.77 + // interested on (the "Link" dialog).
1.78 + if ( dialogName == 'myDialog' && ev.editor.name == 'editor2' ) {
1.79 + // Get a reference to the "Link Info" tab.
1.80 + var infoTab = dialogDefinition.getContents( 'tab1' );
1.81 +
1.82 + // Add a new text field to the "tab1" tab page.
1.83 + infoTab.add( {
1.84 + type: 'text',
1.85 + label: 'My Custom Field',
1.86 + id: 'customField',
1.87 + 'default': 'Sample!',
1.88 + validate: function() {
1.89 + if ( ( /\d/ ).test( this.getValue() ) )
1.90 + return 'My Custom Field must not contain digits';
1.91 + }
1.92 + });
1.93 +
1.94 + // Remove the "select1" field from the "tab1" tab.
1.95 + infoTab.remove( 'select1' );
1.96 +
1.97 + // Set the default value for "input1" field.
1.98 + var input1 = infoTab.get( 'input1' );
1.99 + input1[ 'default' ] = 'www.example.com';
1.100 +
1.101 + // Remove the "tab2" tab page.
1.102 + dialogDefinition.removeContents( 'tab2' );
1.103 +
1.104 + // Add a new tab to the "Link" dialog.
1.105 + dialogDefinition.addContents( {
1.106 + id: 'customTab',
1.107 + label: 'My Tab',
1.108 + accessKey: 'M',
1.109 + elements: [
1.110 + {
1.111 + id: 'myField1',
1.112 + type: 'text',
1.113 + label: 'My Text Field'
1.114 + },
1.115 + {
1.116 + id: 'myField2',
1.117 + type: 'text',
1.118 + label: 'Another Text Field'
1.119 + }
1.120 + ]
1.121 + });
1.122 +
1.123 + // Provide the focus handler to start initial focus in "customField" field.
1.124 + dialogDefinition.onFocus = function() {
1.125 + var urlField = this.getContentElement( 'tab1', 'customField' );
1.126 + urlField.select();
1.127 + };
1.128 + }
1.129 + });
1.130 +
1.131 + var config = {
1.132 + extraPlugins: 'dialog',
1.133 + toolbar: [ [ 'MyButton' ] ]
1.134 + };
1.135 +
1.136 + </script>
1.137 +</head>
1.138 +<body>
1.139 + <h1 class="samples">
1.140 + <a href="../../../samples/old/index.html">CKEditor Samples</a> » Using CKEditor Dialog API
1.141 + </h1>
1.142 + <div class="warning deprecated">
1.143 + This sample is not maintained anymore. Check out the <a href="http://sdk.ckeditor.com/">brand new samples in CKEditor SDK</a>.
1.144 + </div>
1.145 + <div class="description">
1.146 + <p>
1.147 + This sample shows how to use the
1.148 + <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.dialog">CKEditor Dialog API</a>
1.149 + to customize CKEditor dialog windows without changing the original editor code.
1.150 + The following customizations are being done in the example below:
1.151 + </p>
1.152 + <p>
1.153 + For details on how to create this setup check the source code of this sample page.
1.154 + </p>
1.155 + </div>
1.156 + <p>A custom dialog is added to the editors using the <code>pluginsLoaded</code> event, from an external <a target="_blank" href="assets/my_dialog.js">dialog definition file</a>:</p>
1.157 + <ol>
1.158 + <li><strong>Creating a custom dialog window</strong> – "My Dialog" dialog window opened with the "My Dialog" toolbar button.</li>
1.159 + <li><strong>Creating a custom button</strong> – Add button to open the dialog with "My Dialog" toolbar button.</li>
1.160 + </ol>
1.161 + <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>
1.162 + <script>
1.163 + // Replace the <textarea id="editor1"> with an CKEditor instance.
1.164 + CKEDITOR.replace( 'editor1', config );
1.165 + </script>
1.166 + <p>The below editor modify the dialog definition of the above added dialog using the <code>dialogDefinition</code> event:</p>
1.167 + <ol>
1.168 + <li><strong>Adding dialog tab</strong> – Add new tab "My Tab" to dialog window.</li>
1.169 + <li><strong>Removing a dialog window tab</strong> – Remove "Second Tab" page from the dialog window.</li>
1.170 + <li><strong>Adding dialog window fields</strong> – Add "My Custom Field" to the dialog window.</li>
1.171 + <li><strong>Removing dialog window field</strong> – Remove "Select Field" selection field from the dialog window.</li>
1.172 + <li><strong>Setting default values for dialog window fields</strong> – Set default value of "Text Field" text field. </li>
1.173 + <li><strong>Setup initial focus for dialog window</strong> – Put initial focus on "My Custom Field" text field. </li>
1.174 + </ol>
1.175 + <textarea cols="80" id="editor2" name="editor2" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>
1.176 + <script>
1.177 +
1.178 + // Replace the <textarea id="editor1"> with an CKEditor instance.
1.179 + CKEDITOR.replace( 'editor2', config );
1.180 +
1.181 + </script>
1.182 + <div id="footer">
1.183 + <hr>
1.184 + <p>
1.185 + CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
1.186 + </p>
1.187 + <p id="copy">
1.188 + Copyright © 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
1.189 + Knabben. All rights reserved.
1.190 + </p>
1.191 + </div>
1.192 +</body>
1.193 +</html>