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

Function bindJQuery

lib/test/angular/1.6.7/angular.js:2033–2082  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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