~ubuntu-branches/ubuntu/utopic/ldap-account-manager/utopic-proposed

« back to all changes in this revision

Viewing changes to templates/lib/extra/ckeditor/plugins/table/plugin.js

  • Committer: Package Import Robot
  • Author(s): Roland Gruber
  • Date: 2014-06-12 17:51:20 UTC
  • mfrom: (1.2.24)
  • Revision ID: package-import@ubuntu.com-20140612175120-grobhwyk369g9aod
Tags: 4.6-1
new upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
 
3
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 
4
 */
 
5
 
 
6
CKEDITOR.plugins.add( 'table', {
 
7
        requires: 'dialog',
 
8
        lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
 
9
        icons: 'table', // %REMOVE_LINE_CORE%
 
10
        hidpi: true, // %REMOVE_LINE_CORE%
 
11
        init: function( editor ) {
 
12
                if ( editor.blockless )
 
13
                        return;
 
14
 
 
15
                var table = CKEDITOR.plugins.table,
 
16
                        lang = editor.lang.table;
 
17
 
 
18
                editor.addCommand( 'table', new CKEDITOR.dialogCommand( 'table', {
 
19
                        context: 'table',
 
20
                        allowedContent: 'table{width,height}[align,border,cellpadding,cellspacing,summary];' +
 
21
                                'caption tbody thead tfoot;' +
 
22
                                'th td tr[scope];' +
 
23
                                ( editor.plugins.dialogadvtab ? 'table' + editor.plugins.dialogadvtab.allowedContent() : '' ),
 
24
                        requiredContent: 'table',
 
25
                        contentTransformations: [
 
26
                                [ 'table{width}: sizeToStyle', 'table[width]: sizeToAttribute' ]
 
27
                        ]
 
28
                } ) );
 
29
 
 
30
                function createDef( def ) {
 
31
                        return CKEDITOR.tools.extend( def || {}, {
 
32
                                contextSensitive: 1,
 
33
                                refresh: function( editor, path ) {
 
34
                                        this.setState( path.contains( 'table', 1 ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
 
35
                                }
 
36
                        } );
 
37
                }
 
38
 
 
39
                editor.addCommand( 'tableProperties', new CKEDITOR.dialogCommand( 'tableProperties', createDef() ) );
 
40
                editor.addCommand( 'tableDelete', createDef( {
 
41
                        exec: function( editor ) {
 
42
                                var path = editor.elementPath(),
 
43
                                        table = path.contains( 'table', 1 );
 
44
 
 
45
                                if ( !table )
 
46
                                        return;
 
47
 
 
48
                                // If the table's parent has only one child remove it as well (unless it's the body or a table cell) (#5416, #6289)
 
49
                                var parent = table.getParent();
 
50
                                if ( parent.getChildCount() == 1 && !parent.is( 'body', 'td', 'th' ) )
 
51
                                        table = parent;
 
52
 
 
53
                                var range = editor.createRange();
 
54
                                range.moveToPosition( table, CKEDITOR.POSITION_BEFORE_START );
 
55
                                table.remove();
 
56
                                range.select();
 
57
                        }
 
58
                } ) );
 
59
 
 
60
                editor.ui.addButton && editor.ui.addButton( 'Table', {
 
61
                        label: lang.toolbar,
 
62
                        command: 'table',
 
63
                        toolbar: 'insert,30'
 
64
                } );
 
65
 
 
66
                CKEDITOR.dialog.add( 'table', this.path + 'dialogs/table.js' );
 
67
                CKEDITOR.dialog.add( 'tableProperties', this.path + 'dialogs/table.js' );
 
68
 
 
69
                // If the "menu" plugin is loaded, register the menu items.
 
70
                if ( editor.addMenuItems ) {
 
71
                        editor.addMenuItems( {
 
72
                                table: {
 
73
                                        label: lang.menu,
 
74
                                        command: 'tableProperties',
 
75
                                        group: 'table',
 
76
                                        order: 5
 
77
                                },
 
78
 
 
79
                                tabledelete: {
 
80
                                        label: lang.deleteTable,
 
81
                                        command: 'tableDelete',
 
82
                                        group: 'table',
 
83
                                        order: 1
 
84
                                }
 
85
                        } );
 
86
                }
 
87
 
 
88
                editor.on( 'doubleclick', function( evt ) {
 
89
                        var element = evt.data.element;
 
90
 
 
91
                        if ( element.is( 'table' ) )
 
92
                                evt.data.dialog = 'tableProperties';
 
93
                } );
 
94
 
 
95
                // If the "contextmenu" plugin is loaded, register the listeners.
 
96
                if ( editor.contextMenu ) {
 
97
                        editor.contextMenu.addListener( function() {
 
98
                                // menu item state is resolved on commands.
 
99
                                return {
 
100
                                        tabledelete: CKEDITOR.TRISTATE_OFF,
 
101
                                        table: CKEDITOR.TRISTATE_OFF
 
102
                                };
 
103
                        } );
 
104
                }
 
105
        }
 
106
} );