doc++.
[ckeditor.git] / skins / ckeditor / _source / plugins / table / plugin.js
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
5
6 CKEDITOR.plugins.add( 'table',
7 {
8 init : function( editor )
9 {
10 var table = CKEDITOR.plugins.table,
11 lang = editor.lang.table;
12
13 editor.addCommand( 'table', new CKEDITOR.dialogCommand( 'table' ) );
14 editor.addCommand( 'tableProperties', new CKEDITOR.dialogCommand( 'tableProperties' ) );
15
16 editor.ui.addButton( 'Table',
17 {
18 label : lang.toolbar,
19 command : 'table'
20 });
21
22 CKEDITOR.dialog.add( 'table', this.path + 'dialogs/table.js' );
23 CKEDITOR.dialog.add( 'tableProperties', this.path + 'dialogs/table.js' );
24
25 // If the "menu" plugin is loaded, register the menu items.
26 if ( editor.addMenuItems )
27 {
28 editor.addMenuItems(
29 {
30 table :
31 {
32 label : lang.menu,
33 command : 'tableProperties',
34 group : 'table',
35 order : 5
36 },
37
38 tabledelete :
39 {
40 label : lang.deleteTable,
41 command : 'tableDelete',
42 group : 'table',
43 order : 1
44 }
45 } );
46 }
47
48 editor.on( 'doubleclick', function( evt )
49 {
50 var element = evt.data.element;
51
52 if ( element.is( 'table' ) )
53 evt.data.dialog = 'tableProperties';
54 });
55
56 // If the "contextmenu" plugin is loaded, register the listeners.
57 if ( editor.contextMenu )
58 {
59 editor.contextMenu.addListener( function( element, selection )
60 {
61 if ( !element || element.isReadOnly() )
62 return null;
63
64 var isTable = element.hasAscendant( 'table', 1 );
65
66 if ( isTable )
67 {
68 return {
69 tabledelete : CKEDITOR.TRISTATE_OFF,
70 table : CKEDITOR.TRISTATE_OFF
71 };
72 }
73
74 return null;
75 } );
76 }
77 }
78 } );