Debian Codegraph @

closure-library/closure/goog/editor/plugins/abstracttabhandler.js

raw
1 // Copyright 2008 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Abstract Editor plugin class to handle tab keys. Has one
17 * abstract method which should be overriden to handle a tab key press.
18 *
19 * @author [email protected] (Robby Walker)
20 */
21
22 goog.provide('goog.editor.plugins.AbstractTabHandler');
23
24 goog.require('goog.editor.Plugin');
25 goog.require('goog.events.KeyCodes');
26 goog.require('goog.userAgent');
27
28
29
30 /**
31 * Plugin to handle tab keys. Specific tab behavior defined by subclasses.
32 *
33 * @constructor
34 * @extends {goog.editor.Plugin}
35 */
36 goog.editor.plugins.AbstractTabHandler = function() {
37 goog.editor.Plugin.call(this);
38 };
39 goog.inherits(goog.editor.plugins.AbstractTabHandler, goog.editor.Plugin);
40
41
42 /** @override */
43 goog.editor.plugins.AbstractTabHandler.prototype.getTrogClassId =
44 goog.abstractMethod;
45
46
47 /** @override */
48 goog.editor.plugins.AbstractTabHandler.prototype.handleKeyboardShortcut =
49 function(e, key, isModifierPressed) {
50 // If a dialog doesn't have selectable field, Moz grabs the event and
51 // performs actions in editor window. This solves that problem and allows
52 // the event to be passed on to proper handlers.
53 if (goog.userAgent.GECKO && this.getFieldObject().inModalMode()) {
54 return false;
55 }
56
57 // Don't handle Ctrl+Tab since the user is most likely trying to switch
58 // browser tabs. See bug 1305086.
59 // FF3 on Mac sends Ctrl-Tab to trogedit and we end up inserting a tab, but
60 // then it also switches the tabs. See bug 1511681. Note that we don't use
61 // isModifierPressed here since isModifierPressed is true only if metaKey
62 // is true on Mac.
63 if (e.keyCode == goog.events.KeyCodes.TAB && !e.metaKey && !e.ctrlKey) {
64 return this.handleTabKey(e);
65 }
66
67 return false;
68 };
69
70
71 /**
72 * Handle a tab key press.
73 * @param {goog.events.Event} e The key event.
74 * @return {boolean} Whether this event was handled by this plugin.
75 * @protected
76 */
77 goog.editor.plugins.AbstractTabHandler.prototype.handleTabKey =
78 goog.abstractMethod;