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-2012, 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>Using API to Customize Dialog Windows — 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 | <style id="styles" type="text/css"> |
---|
18 | |
---|
19 | .cke_button_myDialogCmd .cke_icon |
---|
20 | { |
---|
21 | display: none !important; |
---|
22 | } |
---|
23 | |
---|
24 | .cke_button_myDialogCmd .cke_label |
---|
25 | { |
---|
26 | display: inline !important; |
---|
27 | } |
---|
28 | |
---|
29 | </style> |
---|
30 | </head> |
---|
31 | <body> |
---|
32 | |
---|
33 | <textarea cols="80" id="editor1" name="editor1" rows="10">Sample page for #9060. Use the "my dialog" button to launch the dialog</textarea> |
---|
34 | <script type="text/javascript"> |
---|
35 | //<![CDATA[ |
---|
36 | // Replace the <textarea id="editor1"> with an CKEditor instance. |
---|
37 | var editor = CKEDITOR.replace( 'editor1', |
---|
38 | { |
---|
39 | // Defines a simpler toolbar to be used in this sample. |
---|
40 | // Note that we have added out "MyButton" button here. |
---|
41 | toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike','-','Link', '-', 'MyButton' ] ] |
---|
42 | }); |
---|
43 | |
---|
44 | // Listen for the "pluginsLoaded" event, so we are sure that the |
---|
45 | // "dialog" plugin has been loaded and we are able to do our |
---|
46 | // customizations. |
---|
47 | editor.on( 'pluginsLoaded', function( ev ) |
---|
48 | { |
---|
49 | |
---|
50 | CKEDITOR.dialog.add( 'myDialog', function( editor ) |
---|
51 | { |
---|
52 | return { |
---|
53 | title : 'My Dialog', |
---|
54 | minWidth : 300, |
---|
55 | minHeight : 100, |
---|
56 | contents : [ |
---|
57 | { |
---|
58 | id : 'tab1', |
---|
59 | label : 'First Tab', |
---|
60 | title : 'First Tab', |
---|
61 | elements : |
---|
62 | [ |
---|
63 | { |
---|
64 | id : 'input1', |
---|
65 | type : 'button', |
---|
66 | label : 'click me!', |
---|
67 | onClick : function () { |
---|
68 | editor.execCommand('nestedDialog'); |
---|
69 | } |
---|
70 | } |
---|
71 | ] |
---|
72 | } |
---|
73 | ] |
---|
74 | }; |
---|
75 | } ); |
---|
76 | |
---|
77 | // Register the command used to open the dialog. |
---|
78 | editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) ); |
---|
79 | |
---|
80 | // Add the a custom toolbar buttons, which fires the above |
---|
81 | // command.. |
---|
82 | editor.ui.addButton( 'MyButton', |
---|
83 | { |
---|
84 | label : 'My Dialog', |
---|
85 | command : 'myDialogCmd' |
---|
86 | } ); |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | CKEDITOR.dialog.add( 'nestedDialog', function( editor ) |
---|
92 | { |
---|
93 | return { |
---|
94 | title : 'embedded editor', |
---|
95 | minWidth : 400, |
---|
96 | minHeight : 300, |
---|
97 | contents : [ |
---|
98 | { |
---|
99 | id : 'tab1', |
---|
100 | label : 'First Tab', |
---|
101 | title : 'First Tab', |
---|
102 | elements : |
---|
103 | [ |
---|
104 | { |
---|
105 | id : 'textarea1', |
---|
106 | type : 'html', |
---|
107 | onLoad : function() { |
---|
108 | // Copy all the configuration options |
---|
109 | var config = CKEDITOR.tools.clone( editor.config ); |
---|
110 | config.customConfig = ''; |
---|
111 | config.width = "300px"; |
---|
112 | config.height = 140; |
---|
113 | config.toolbar = [ ["Source"], ["Bold", "Italic", "Link", "Image"], ["Undo", "Redo"]]; |
---|
114 | config.toolbarCanCollapse = false; |
---|
115 | CKEDITOR.replace( "nested", config); |
---|
116 | }, |
---|
117 | html : '<textarea name="nested">This is some sample text<br>Select "some" and create a link. Then use Enter to create a new line for example after "sample"</textarea>' |
---|
118 | } |
---|
119 | ] |
---|
120 | } |
---|
121 | ] |
---|
122 | }; |
---|
123 | } ); |
---|
124 | |
---|
125 | // Register the command used to open the dialog. |
---|
126 | editor.addCommand( 'nestedDialog', new CKEDITOR.dialogCommand( 'nestedDialog' ) ); |
---|
127 | |
---|
128 | |
---|
129 | }); |
---|
130 | //]]> |
---|
131 | </script> |
---|
132 | </body> |
---|
133 | </html> |
---|