JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / image / plugin.js
1 /*\r
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 /**\r
7  * @file Image plugin\r
8  */\r
9 \r
10 CKEDITOR.plugins.add( 'image',\r
11 {\r
12         init : function( editor )\r
13         {\r
14                 var pluginName = 'image';\r
15 \r
16                 // Register the dialog.\r
17                 CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/image.js' );\r
18 \r
19                 // Register the command.\r
20                 editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );\r
21 \r
22                 // Register the toolbar button.\r
23                 editor.ui.addButton( 'Image',\r
24                         {\r
25                                 label : editor.lang.common.image,\r
26                                 command : pluginName\r
27                         });\r
28 \r
29                 editor.on( 'doubleclick', function( evt )\r
30                         {\r
31                                 var element = evt.data.element;\r
32 \r
33                                 if ( element.is( 'img' ) && !element.data( 'cke-realelement' ) && !element.isReadOnly() )\r
34                                         evt.data.dialog = 'image';\r
35                         });\r
36 \r
37                 // If the "menu" plugin is loaded, register the menu items.\r
38                 if ( editor.addMenuItems )\r
39                 {\r
40                         editor.addMenuItems(\r
41                                 {\r
42                                         image :\r
43                                         {\r
44                                                 label : editor.lang.image.menu,\r
45                                                 command : 'image',\r
46                                                 group : 'image'\r
47                                         }\r
48                                 });\r
49                 }\r
50 \r
51                 // If the "contextmenu" plugin is loaded, register the listeners.\r
52                 if ( editor.contextMenu )\r
53                 {\r
54                         editor.contextMenu.addListener( function( element, selection )\r
55                                 {\r
56                                         if ( !element || !element.is( 'img' ) || element.data( 'cke-realelement' ) || element.isReadOnly() )\r
57                                                 return null;\r
58 \r
59                                         return { image : CKEDITOR.TRISTATE_OFF };\r
60                                 });\r
61                 }\r
62         }\r
63 } );\r
64 \r
65 /**\r
66  * Whether to remove links when emptying the link URL field in the image dialog.\r
67  * @type Boolean\r
68  * @default true\r
69  * @example\r
70  * config.image_removeLinkByEmptyURL = false;\r
71  */\r
72 CKEDITOR.config.image_removeLinkByEmptyURL = true;\r
73 \r
74 /**\r
75  *  Padding text to set off the image in preview area.\r
76  * @name CKEDITOR.config.image_previewText\r
77  * @type String\r
78  * @default "Lorem ipsum dolor..." placehoder text.\r
79  * @example\r
80  * config.image_previewText = CKEDITOR.tools.repeat( '___ ', 100 );\r
81  */\r