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

Function bindJQuery

lib/test/angular/1.8.0/angular.js:2041–2090  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

angular.jsFile · 0.70

Calls 3

jqFunction · 0.70
isUndefinedFunction · 0.70
extendFunction · 0.70

Tested by

no test coverage detected