1 | <!DOCTYPE html> |
---|
2 | <!-- |
---|
3 | Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. |
---|
4 | For licensing, see LICENSE.html or http://ckeditor.com/license |
---|
5 | --> |
---|
6 | <html> |
---|
7 | <head> |
---|
8 | <title>Using API to Customize Dialog Windows — CKEditor Sample</title> |
---|
9 | <meta charset="utf-8"> |
---|
10 | <script src="../../../ckeditor.js"></script> |
---|
11 | <style> |
---|
12 | |
---|
13 | .cke_button__mybutton_icon |
---|
14 | { |
---|
15 | display: none !important; |
---|
16 | } |
---|
17 | |
---|
18 | .cke_button__mybutton_label |
---|
19 | { |
---|
20 | display: inline !important; |
---|
21 | } |
---|
22 | |
---|
23 | </style> |
---|
24 | <script> |
---|
25 | |
---|
26 | CKEDITOR.on( 'instanceCreated', function( ev ){ |
---|
27 | var editor = ev.editor; |
---|
28 | |
---|
29 | // Listen for the "pluginsLoaded" event, so we are sure that the |
---|
30 | // "dialog" plugin has been loaded and we are able to do our |
---|
31 | // customizations. |
---|
32 | editor.on( 'pluginsLoaded', function() { |
---|
33 | |
---|
34 | CKEDITOR.dialog.add( 'myDialog', function( editor ) { |
---|
35 | return { |
---|
36 | title: 'My Dialog', |
---|
37 | minWidth: 400, |
---|
38 | minHeight: 200, |
---|
39 | contents: [ |
---|
40 | { |
---|
41 | id: 'tab1', |
---|
42 | label: 'First Tab', |
---|
43 | title: 'First Tab', |
---|
44 | elements: [ |
---|
45 | { |
---|
46 | id : 'myCheck', |
---|
47 | type : 'checkbox', |
---|
48 | label : 'Check me', |
---|
49 | onChange : function(o) { |
---|
50 | alert("changed"); |
---|
51 | } |
---|
52 | } |
---|
53 | ] |
---|
54 | } |
---|
55 | ] |
---|
56 | }; |
---|
57 | }); |
---|
58 | |
---|
59 | // Register the command used to open the dialog. |
---|
60 | editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) ); |
---|
61 | |
---|
62 | // Add the a custom toolbar buttons, which fires the above |
---|
63 | // command.. |
---|
64 | editor.ui.add( 'MyButton', CKEDITOR.UI_BUTTON, { |
---|
65 | label: 'My Dialog', |
---|
66 | command: 'myDialogCmd' |
---|
67 | }); |
---|
68 | }); |
---|
69 | }); |
---|
70 | |
---|
71 | var config = { |
---|
72 | extraPlugins: 'dialog', |
---|
73 | toolbar: [ [ 'MyButton' ] ] |
---|
74 | }; |
---|
75 | |
---|
76 | </script> |
---|
77 | </head> |
---|
78 | <body> |
---|
79 | <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> |
---|
80 | <script> |
---|
81 | // Replace the <textarea id="editor1"> with an CKEditor instance. |
---|
82 | CKEDITOR.replace( 'editor1', config ); |
---|
83 | </script> |
---|
84 | </body> |
---|
85 | </html> |
---|