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

Function bindJQuery

test/angular/1.5/angular.js:1887–1936  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1885
1886var bindJQueryFired = false;
1887function bindJQuery() {
1888 var originalCleanData;
1889
1890 if (bindJQueryFired) {
1891 return;
1892 }
1893
1894 // bind to jQuery if present;
1895 var jqName = jq();
1896 jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present)
1897 !jqName ? undefined : // use jqLite
1898 window[jqName]; // use jQuery specified by `ngJq`
1899
1900 // Use jQuery if it exists with proper functionality, otherwise default to us.
1901 // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.
1902 // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older
1903 // versions. It will not work for sure with jQuery <1.7, though.
1904 if (jQuery && jQuery.fn.on) {
1905 jqLite = jQuery;
1906 extend(jQuery.fn, {
1907 scope: JQLitePrototype.scope,
1908 isolateScope: JQLitePrototype.isolateScope,
1909 controller: JQLitePrototype.controller,
1910 injector: JQLitePrototype.injector,
1911 inheritedData: JQLitePrototype.inheritedData
1912 });
1913
1914 // All nodes removed from the DOM via various jQuery APIs like .remove()
1915 // are passed through jQuery.cleanData. Monkey-patch this method to fire
1916 // the $destroy event on all removed nodes.
1917 originalCleanData = jQuery.cleanData;
1918 jQuery.cleanData = function(elems) {
1919 var events;
1920 for (var i = 0, elem; (elem = elems[i]) != null; i++) {
1921 events = jQuery._data(elem, 'events');
1922 if (events && events.$destroy) {
1923 jQuery(elem).triggerHandler('$destroy');
1924 }
1925 }
1926 originalCleanData(elems);
1927 };
1928 } else {
1929 jqLite = JQLite;
1930 }
1931
1932 angular.element = jqLite;
1933
1934 // Prevent double-proxying.
1935 bindJQueryFired = true;
1936}
1937
1938/**
1939 * 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