1YUI.add('aui-event-input', function (A, NAME) { 2 3/** 4 * An object that encapsulates text changed events for textareas and input 5 * element of type text and password. This event only occurs when the element 6 * is focused. 7 * 8 * @module aui-event 9 * @submodule aui-event-input 10 */ 11 12var DOM_EVENTS = A.Node.DOM_EVENTS; 13 14// Input event feature check should be done on textareas. WebKit before 15// version 531 (3.0.182.2) did not support input events for textareas. 16// See http://dev.chromium.org/developers/webkit-version-table 17if (A.Features.test('event', 'input')) { 18 // http://yuilibrary.com/projects/yui3/ticket/2533063 19 DOM_EVENTS.input = 1; 20 return; 21} 22 23DOM_EVENTS.cut = 1; 24DOM_EVENTS.dragend = 1; 25DOM_EVENTS.paste = 1; 26 27var ACTIVE_ELEMENT = 'activeElement', 28 OWNER_DOCUMENT = 'ownerDocument', 29 30 _HANDLER_DATA_KEY = '~~aui|input|event~~', 31 _INPUT_EVENT_TYPE = ['keydown', 'paste', 'drop', 'cut'], 32 _SKIP_FOCUS_CHECK_MAP = { 33 cut: 1, 34 drop: 1, 35 paste: 1 36 }; 37 38/** 39 * TODO. Wanna help? Please send a Pull Request. 40 * 41 * @event input 42 */ 43A.Event.define('input', { 44 45 /** 46 * TODO. Wanna help? Please send a Pull Request. 47 * 48 * @method on 49 * @param node 50 * @param subscription 51 * @param notifier 52 */ 53 on: function(node, subscription, notifier) { 54 var instance = this; 55 56 subscription._handler = node.on( 57 _INPUT_EVENT_TYPE, A.bind(instance._dispatchEvent, instance, notifier)); 58 }, 59 60 /** 61 * TODO. Wanna help? Please send a Pull Request. 62 * 63 * @method delegate 64 * @param node 65 * @param subscription 66 * @param notifier 67 * @param filter 68 */ 69 delegate: function(node, subscription, notifier, filter) { 70 var instance = this; 71 72 subscription._handles = []; 73 subscription._handler = node.delegate('focus', function(event) { 74 var element = event.target, 75 handler = element.getData(_HANDLER_DATA_KEY); 76 77 if (!handler) { 78 handler = element.on( 79 _INPUT_EVENT_TYPE, 80 A.bind(instance._dispatchEvent, instance, notifier)); 81 82 subscription._handles.push(handler); 83 element.setData(_HANDLER_DATA_KEY, handler); 84 } 85 }, filter); 86 }, 87 88 /** 89 * TODO. Wanna help? Please send a Pull Request. 90 * 91 * @method detach 92 * @param node 93 * @param subscription 94 * @param notifier 95 */ 96 detach: function(node, subscription, notifier) { 97 subscription._handler.detach(); 98 }, 99 100 /** 101 * TODO. Wanna help? Please send a Pull Request. 102 * 103 * @method detachDelegate 104 * @param node 105 * @param subscription 106 * @param notifier 107 */ 108 detachDelegate: function(node, subscription, notifier) { 109 A.Array.each(subscription._handles, function(handle) { 110 var element = A.one(handle.evt.el); 111 if (element) { 112 element.setData(_HANDLER_DATA_KEY, null); 113 } 114 handle.detach(); 115 }); 116 subscription._handler.detach(); 117 }, 118 119 /** 120 * TODO. Wanna help? Please send a Pull Request. 121 * 122 * @method _dispatchEvent 123 * @param notifier 124 * @param event 125 * @protected 126 */ 127 _dispatchEvent: function(notifier, event) { 128 var instance = this, 129 input = event.target; 130 131 if ( // Since cut, drop and paste events fires before the element is focused, skip focus checking. 132 _SKIP_FOCUS_CHECK_MAP[event.type] || 133 (input.get(OWNER_DOCUMENT).get(ACTIVE_ELEMENT) === input)) { 134 135 notifier.fire(event); 136 } 137 } 138}); 139 140 141}, '2.0.0', {"requires": ["aui-event-base", "event-delegate", "event-synthetic"]});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.