]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/editor/editor-tab.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / editor / editor-tab.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('editor-tab', function(Y) {
9
10     /**
11      * Handles tab and shift-tab indent/outdent support.
12      * @module editor
13      * @submodule editor-tab
14      */     
15     /**
16      * Handles tab and shift-tab indent/outdent support.
17      * @class Plugin.EditorTab
18      * @constructor
19      * @extends Base
20      */
21     
22     var EditorTab = function() {
23         EditorTab.superclass.constructor.apply(this, arguments);
24     }, HOST = 'host';
25
26     Y.extend(EditorTab, Y.Base, {
27         /**
28         * Listener for host's nodeChange event and captures the tabkey interaction.
29         * @private
30         * @method _onNodeChange
31         * @param {Event} e The Event facade passed from the host.
32         */
33         _onNodeChange: function(e) {
34             var action = 'indent';
35
36             if (e.changedType === 'tab') {
37                 if (!e.changedNode.test('li, li *')) {
38                     e.changedEvent.halt();
39                     e.preventDefault();
40                     if (e.changedEvent.shiftKey) {
41                         action = 'outdent';
42                     }
43
44                     this.get(HOST).execCommand(action, '');
45                 }
46             }
47         },
48         initializer: function() {
49             this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
50         }
51     }, {
52         /**
53         * editorTab
54         * @property NAME
55         * @static
56         */
57         NAME: 'editorTab',
58         /**
59         * tab
60         * @property NS
61         * @static
62         */
63         NS: 'tab',
64         ATTRS: {
65             host: {
66                 value: false
67             }
68         }
69     });
70
71
72     Y.namespace('Plugin');
73
74     Y.Plugin.EditorTab = EditorTab;
75
76
77 }, '3.3.0' ,{requires:['editor-base'], skinnable:false});