MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / eventHandler

Function eventHandler

lib/test/angular/1.5.0/angular.js:3346–3389  ·  view source on GitHub ↗
(event, type)

Source from the content-addressed store, hash-verified

3344
3345function createEventHandler(element, events) {
3346 var eventHandler = function(event, type) {
3347 // jQuery specific api
3348 event.isDefaultPrevented = function() {
3349 return event.defaultPrevented;
3350 };
3351
3352 var eventFns = events[type || event.type];
3353 var eventFnsLength = eventFns ? eventFns.length : 0;
3354
3355 if (!eventFnsLength) return;
3356
3357 if (isUndefined(event.immediatePropagationStopped)) {
3358 var originalStopImmediatePropagation = event.stopImmediatePropagation;
3359 event.stopImmediatePropagation = function() {
3360 event.immediatePropagationStopped = true;
3361
3362 if (event.stopPropagation) {
3363 event.stopPropagation();
3364 }
3365
3366 if (originalStopImmediatePropagation) {
3367 originalStopImmediatePropagation.call(event);
3368 }
3369 };
3370 }
3371
3372 event.isImmediatePropagationStopped = function() {
3373 return event.immediatePropagationStopped === true;
3374 };
3375
3376 // Some events have special handlers that wrap the real handler
3377 var handlerWrapper = eventFns.specialHandlerWrapper || defaultHandlerWrapper;
3378
3379 // Copy event handlers in case event handlers array is modified during execution.
3380 if ((eventFnsLength > 1)) {
3381 eventFns = shallowCopy(eventFns);
3382 }
3383
3384 for (var i = 0; i < eventFnsLength; i++) {
3385 if (!event.isImmediatePropagationStopped()) {
3386 handlerWrapper(element, event, eventFns[i]);
3387 }
3388 }
3389 };
3390
3391 // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all
3392 // events on `element`

Callers

nothing calls this directly

Calls 2

isUndefinedFunction · 0.70
shallowCopyFunction · 0.70

Tested by

no test coverage detected