MCPcopy
hub / github.com/angular-ui/ui-router / bindJQuery

Function bindJQuery

test/angular/1.6/angular.js:2043–2092  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2041
2042var bindJQueryFired = false;
2043function bindJQuery() {
2044 var originalCleanData;
2045
2046 if (bindJQueryFired) {
2047 return;
2048 }
2049
2050 // bind to jQuery if present;
2051 var jqName = jq();
2052 jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present)
2053 !jqName ? undefined : // use jqLite
2054 window[jqName]; // use jQuery specified by `ngJq`
2055
2056 // Use jQuery if it exists with proper functionality, otherwise default to us.
2057 // AngularJS 1.2+ requires jQuery 1.7+ for on()/off() support.
2058 // AngularJS 1.3+ technically requires at least jQuery 2.1+ but it may work with older
2059 // versions. It will not work for sure with jQuery <1.7, though.
2060 if (jQuery && jQuery.fn.on) {
2061 jqLite = jQuery;
2062 extend(jQuery.fn, {
2063 scope: JQLitePrototype.scope,
2064 isolateScope: JQLitePrototype.isolateScope,
2065 controller: /** @type {?} */ (JQLitePrototype).controller,
2066 injector: JQLitePrototype.injector,
2067 inheritedData: JQLitePrototype.inheritedData
2068 });
2069
2070 // All nodes removed from the DOM via various jQuery APIs like .remove()
2071 // are passed through jQuery.cleanData. Monkey-patch this method to fire
2072 // the $destroy event on all removed nodes.
2073 originalCleanData = jQuery.cleanData;
2074 jQuery.cleanData = function(elems) {
2075 var events;
2076 for (var i = 0, elem; (elem = elems[i]) != null; i++) {
2077 events = jQuery._data(elem, 'events');
2078 if (events && events.$destroy) {
2079 jQuery(elem).triggerHandler('$destroy');
2080 }
2081 }
2082 originalCleanData(elems);
2083 };
2084 } else {
2085 jqLite = JQLite;
2086 }
2087
2088 angular.element = jqLite;
2089
2090 // Prevent double-proxying.
2091 bindJQueryFired = true;
2092}
2093
2094/**
2095 * throw error if the argument is falsy.

Callers 1

angular.jsFile · 0.70

Calls 3

jqFunction · 0.70
isUndefinedFunction · 0.70
extendFunction · 0.70

Tested by

no test coverage detected