JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / placeholder / dialogs / placeholder.js
1 /*\r
2  * Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
3  * For licensing, see LICENSE.html or http://ckeditor.com/license\r
4  */\r
5 \r
6 (function()\r
7 {\r
8         function placeholderDialog( editor, isEdit )\r
9         {\r
10 \r
11                 var lang = editor.lang.placeholder,\r
12                         generalLabel = editor.lang.common.generalTab;\r
13                 return {\r
14                         title : lang.title,\r
15                         minWidth : 300,\r
16                         minHeight : 80,\r
17                         contents :\r
18                         [\r
19                                 {\r
20                                         id : 'info',\r
21                                         label : generalLabel,\r
22                                         title : generalLabel,\r
23                                         elements :\r
24                                         [\r
25                                                 {\r
26                                                         id : 'text',\r
27                                                         type : 'text',\r
28                                                         style : 'width: 100%;',\r
29                                                         label : lang.text,\r
30                                                         'default' : '',\r
31                                                         required : true,\r
32                                                         validate : CKEDITOR.dialog.validate.notEmpty( lang.textMissing ),\r
33                                                         setup : function( element )\r
34                                                         {\r
35                                                                 if ( isEdit )\r
36                                                                         this.setValue( element.getText().slice( 2, -2 ) );\r
37                                                         },\r
38                                                         commit : function( element )\r
39                                                         {\r
40                                                                 var text = '[[' + this.getValue() + ']]';\r
41                                                                 // The placeholder must be recreated.\r
42                                                                 CKEDITOR.plugins.placeholder.createPlaceholder( editor, element, text );\r
43                                                         }\r
44                                                 }\r
45                                         ]\r
46                                 }\r
47                         ],\r
48                         onShow : function()\r
49                         {\r
50                                 if ( isEdit )\r
51                                         this._element = CKEDITOR.plugins.placeholder.getSelectedPlaceHoder( editor );\r
52 \r
53                                 this.setupContent( this._element );\r
54                         },\r
55                         onOk : function()\r
56                         {\r
57                                 this.commitContent( this._element );\r
58                                 delete this._element;\r
59                         }\r
60                 };\r
61         }\r
62 \r
63         CKEDITOR.dialog.add( 'createplaceholder', function( editor )\r
64                 {\r
65                         return placeholderDialog( editor );\r
66                 });\r
67         CKEDITOR.dialog.add( 'editplaceholder', function( editor )\r
68                 {\r
69                         return placeholderDialog( editor, 1 );\r
70                 });\r
71 } )();\r