MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / bindJQuery

Function bindJQuery

OpenReservation/wwwroot/Scripts/angular.js:1746–1800  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1744 var bindJQueryFired = false;
1745
1746 function bindJQuery() {
1747 var originalCleanData;
1748
1749 if (bindJQueryFired) {
1750 return;
1751 }
1752
1753 // bind to jQuery if present;
1754 var jqName = jq();
1755 jQuery = isUndefined(jqName)
1756 ? window.jQuery
1757 : // use jQuery (if present)
1758 !jqName
1759 ? undefined
1760 : // use jqLite
1761 window[jqName]; // use jQuery specified by `ngJq`
1762
1763 // Use jQuery if it exists with proper functionality, otherwise default to us.
1764 // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.
1765 // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older
1766 // versions. It will not work for sure with jQuery <1.7, though.
1767 if (jQuery && jQuery.fn.on) {
1768 jqLite = jQuery;
1769 extend(jQuery.fn,
1770 {
1771 scope: JQLitePrototype.scope,
1772 isolateScope: JQLitePrototype.isolateScope,
1773 controller: JQLitePrototype.controller,
1774 injector: JQLitePrototype.injector,
1775 inheritedData: JQLitePrototype.inheritedData
1776 });
1777
1778 // All nodes removed from the DOM via various jQuery APIs like .remove()
1779 // are passed through jQuery.cleanData. Monkey-patch this method to fire
1780 // the $destroy event on all removed nodes.
1781 originalCleanData = jQuery.cleanData;
1782 jQuery.cleanData = function (elems) {
1783 var events;
1784 for (var i = 0, elem; (elem = elems[i]) != null; i++) {
1785 events = jQuery._data(elem, "events");
1786 if (events && events.$destroy) {
1787 jQuery(elem).triggerHandler('$destroy');
1788 }
1789 }
1790 originalCleanData(elems);
1791 };
1792 } else {
1793 jqLite = JQLite;
1794 }
1795
1796 angular.element = jqLite;
1797
1798 // Prevent double-proxying.
1799 bindJQueryFired = true;
1800 }
1801
1802 /**
1803 * throw error if the argument is falsy.

Callers 1

angular.jsFile · 0.85

Calls 4

jqFunction · 0.85
isUndefinedFunction · 0.85
extendFunction · 0.85
jQueryFunction · 0.85

Tested by

no test coverage detected