NOBUG: Fixed file access permissions
[moodle.git] / lib / yuilib / 3.13.0 / editor-tab / editor-tab.js
blob7f7e1d56efc2c687e296b0d37389214a599564ae
1 /*
2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
8 YUI.add('editor-tab', function (Y, NAME) {
11     /**
12      * Handles tab and shift-tab indent/outdent support.
13      * @class Plugin.EditorTab
14      * @constructor
15      * @extends Base
16      * @module editor
17      * @submodule editor-tab
18      */
20     var EditorTab = function() {
21         EditorTab.superclass.constructor.apply(this, arguments);
22     }, HOST = 'host';
24     Y.extend(EditorTab, Y.Base, {
25         /**
26         * Listener for host's nodeChange event and captures the tabkey interaction.
27         * @private
28         * @method _onNodeChange
29         * @param {Event} e The Event facade passed from the host.
30         */
31         _onNodeChange: function(e) {
32             var action = 'indent';
34             if (e.changedType === 'tab') {
35                 if (!e.changedNode.test('li, li *')) {
36                     e.changedEvent.halt();
37                     e.preventDefault();
38                     if (e.changedEvent.shiftKey) {
39                         action = 'outdent';
40                     }
42                     this.get(HOST).execCommand(action, '');
43                 }
44             }
45         },
46         initializer: function() {
47             this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
48         }
49     }, {
50         /**
51         * editorTab
52         * @property NAME
53         * @static
54         */
55         NAME: 'editorTab',
56         /**
57         * tab
58         * @property NS
59         * @static
60         */
61         NS: 'tab',
62         ATTRS: {
63             host: {
64                 value: false
65             }
66         }
67     });
70     Y.namespace('Plugin');
72     Y.Plugin.EditorTab = EditorTab;
75 }, '3.13.0', {"requires": ["editor-base"]});