()
| 2039 | |
| 2040 | var bindJQueryFired = false; |
| 2041 | function 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 |
no test coverage detected