Path: blob/trunk/third_party/closure/goog/editor/plugins/abstracttabhandler.js
2868 views
// Copyright 2008 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Abstract Editor plugin class to handle tab keys. Has one16* abstract method which should be overriden to handle a tab key press.17*18* @author [email protected] (Robby Walker)19*/2021goog.provide('goog.editor.plugins.AbstractTabHandler');2223goog.require('goog.editor.Plugin');24goog.require('goog.events.KeyCodes');25goog.require('goog.userAgent');26272829/**30* Plugin to handle tab keys. Specific tab behavior defined by subclasses.31*32* @constructor33* @extends {goog.editor.Plugin}34*/35goog.editor.plugins.AbstractTabHandler = function() {36goog.editor.Plugin.call(this);37};38goog.inherits(goog.editor.plugins.AbstractTabHandler, goog.editor.Plugin);394041/** @override */42goog.editor.plugins.AbstractTabHandler.prototype.getTrogClassId =43goog.abstractMethod;444546/** @override */47goog.editor.plugins.AbstractTabHandler.prototype.handleKeyboardShortcut =48function(e, key, isModifierPressed) {49// If a dialog doesn't have selectable field, Moz grabs the event and50// performs actions in editor window. This solves that problem and allows51// the event to be passed on to proper handlers.52if (goog.userAgent.GECKO && this.getFieldObject().inModalMode()) {53return false;54}5556// Don't handle Ctrl+Tab since the user is most likely trying to switch57// browser tabs. See bug 1305086.58// FF3 on Mac sends Ctrl-Tab to trogedit and we end up inserting a tab, but59// then it also switches the tabs. See bug 1511681. Note that we don't use60// isModifierPressed here since isModifierPressed is true only if metaKey61// is true on Mac.62if (e.keyCode == goog.events.KeyCodes.TAB && !e.metaKey && !e.ctrlKey) {63return this.handleTabKey(e);64}6566return false;67};686970/**71* Handle a tab key press.72* @param {goog.events.Event} e The key event.73* @return {boolean} Whether this event was handled by this plugin.74* @protected75*/76goog.editor.plugins.AbstractTabHandler.prototype.handleTabKey =77goog.abstractMethod;787980