Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('editor-tab', function (Y, NAME) {
2
 
3
 
4
    /**
5
     * Handles tab and shift-tab indent/outdent support.
6
     * @class Plugin.EditorTab
7
     * @constructor
8
     * @extends Base
9
     * @module editor
10
     * @submodule editor-tab
11
     */
12
 
13
    var EditorTab = function() {
14
        EditorTab.superclass.constructor.apply(this, arguments);
15
    }, HOST = 'host';
16
 
17
    Y.extend(EditorTab, Y.Base, {
18
        /**
19
        * Listener for host's nodeChange event and captures the tabkey interaction.
20
        * @private
21
        * @method _onNodeChange
22
        * @param {Event} e The Event facade passed from the host.
23
        */
24
        _onNodeChange: function(e) {
25
            var action = 'indent';
26
 
27
            if (e.changedType === 'tab') {
28
                if (!e.changedNode.test('li, li *')) {
29
                    e.changedEvent.halt();
30
                    e.preventDefault();
31
                    if (e.changedEvent.shiftKey) {
32
                        action = 'outdent';
33
                    }
34
 
35
                    this.get(HOST).execCommand(action, '');
36
                }
37
            }
38
        },
39
        initializer: function() {
40
            this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
41
        }
42
    }, {
43
        /**
44
        * editorTab
45
        * @property NAME
46
        * @static
47
        */
48
        NAME: 'editorTab',
49
        /**
50
        * tab
51
        * @property NS
52
        * @static
53
        */
54
        NS: 'tab',
55
        ATTRS: {
56
            host: {
57
                value: false
58
            }
59
        }
60
    });
61
 
62
 
63
    Y.namespace('Plugin');
64
 
65
    Y.Plugin.EditorTab = EditorTab;
66
 
67
 
68
}, '3.18.1', {"requires": ["editor-base"]});