diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui3.0.0/build/event/event-key-debug.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui3.0.0/build/event/event-key-debug.js Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,111 @@ +/* +Copyright (c) 2009, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 3.0.0 +build: 1549 +*/ +YUI.add('event-key', function(Y) { + +/** + * Functionality to listen for one or more specific key combinations. + * @module event + * @submodule event-key + */ + +/** + * Add a key listener. The listener will only be notified if the + * keystroke detected meets the supplied specification. The + * spec consists of the key event type, followed by a colon, + * followed by zero or more comma separated key codes, followed + * by zero or more modifiers delimited by a plus sign. Ex: + * press:12,65+shift+ctrl + * @event key + * @for YUI + * @param type {string} 'key' + * @param fn {function} the function to execute + * @param id {string|HTMLElement|collection} the element(s) to bind + * @param spec {string} the keyCode and modifier specification + * @param o optional context object + * @param args 0..n additional arguments to provide to the listener. + * @return {Event.Handle} the detach handle + */ +Y.Env.evt.plugins.key = { + + on: function(type, fn, id, spec, o) { + var a = Y.Array(arguments, 0, true), parsed, etype, criteria, ename; + + parsed = spec && spec.split(':'); + + if (!spec || spec.indexOf(':') == -1 || !parsed[1]) { +Y.log('Illegal key spec, creating a regular keypress listener instead.', 'info', 'event'); + a[0] = 'key' + ((parsed && parsed[0]) || 'press'); + return Y.on.apply(Y, a); + } + + // key event type: 'down', 'up', or 'press' + etype = parsed[0]; + + // list of key codes optionally followed by modifiers + criteria = (parsed[1]) ? parsed[1].split(/,|\+/) : null; + + // the name of the custom event that will be created for the spec + ename = (Y.Lang.isString(id) ? id : Y.stamp(id)) + spec; + + ename = ename.replace(/,/g, '_'); + + if (!Y.getEvent(ename)) { + + // subscribe spec validator to the DOM event + Y.on(type + etype, function(e) { + + // Y.log('keylistener: ' + e.keyCode); + + var passed = false, failed = false, i, crit, critInt; + + for (i=0; i