MCPcopy Index your code
hub / github.com/angular-ui/ui-router / bindJQuery

Function bindJQuery

test/angular/1.4/angular.js:1772–1825  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1770var bindJQueryFired = false;
1771var skipDestroyOnNextJQueryCleanData;
1772function bindJQuery() {
1773 var originalCleanData;
1774
1775 if (bindJQueryFired) {
1776 return;
1777 }
1778
1779 // bind to jQuery if present;
1780 var jqName = jq();
1781 jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present)
1782 !jqName ? undefined : // use jqLite
1783 window[jqName]; // use jQuery specified by `ngJq`
1784
1785 // Use jQuery if it exists with proper functionality, otherwise default to us.
1786 // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.
1787 // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older
1788 // versions. It will not work for sure with jQuery <1.7, though.
1789 if (jQuery && jQuery.fn.on) {
1790 jqLite = jQuery;
1791 extend(jQuery.fn, {
1792 scope: JQLitePrototype.scope,
1793 isolateScope: JQLitePrototype.isolateScope,
1794 controller: JQLitePrototype.controller,
1795 injector: JQLitePrototype.injector,
1796 inheritedData: JQLitePrototype.inheritedData
1797 });
1798
1799 // All nodes removed from the DOM via various jQuery APIs like .remove()
1800 // are passed through jQuery.cleanData. Monkey-patch this method to fire
1801 // the $destroy event on all removed nodes.
1802 originalCleanData = jQuery.cleanData;
1803 jQuery.cleanData = function(elems) {
1804 var events;
1805 if (!skipDestroyOnNextJQueryCleanData) {
1806 for (var i = 0, elem; (elem = elems[i]) != null; i++) {
1807 events = jQuery._data(elem, "events");
1808 if (events && events.$destroy) {
1809 jQuery(elem).triggerHandler('$destroy');
1810 }
1811 }
1812 } else {
1813 skipDestroyOnNextJQueryCleanData = false;
1814 }
1815 originalCleanData(elems);
1816 };
1817 } else {
1818 jqLite = JQLite;
1819 }
1820
1821 angular.element = jqLite;
1822
1823 // Prevent double-proxying.
1824 bindJQueryFired = true;
1825}
1826
1827/**
1828 * 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