|
58 | 58 | shallowCopy: true,
|
59 | 59 | equals: true,
|
60 | 60 | csp: true,
|
| 61 | + jq: true, |
61 | 62 | concat: true,
|
62 | 63 | sliceArgs: true,
|
63 | 64 | bind: true,
|
@@ -916,11 +917,48 @@ var csp = function() {
|
916 | 917 | * be added to the top-most HTML element.
|
917 | 918 | *
|
918 | 919 | */
|
| 920 | + |
| 921 | + |
| 922 | +/** |
| 923 | + * @ngdoc directive |
| 924 | + * @name ngJq |
| 925 | + * |
| 926 | + * @element html |
| 927 | + * @param {string=} the name of the library available under `window` |
| 928 | + * to be used for angular.element |
| 929 | + * @description |
| 930 | + * Use this directive to force the angular.element library. This should be |
| 931 | + * used to force either jqLite by leaving ng-jq blank or setting the name of |
| 932 | + * the jquery variable under window (eg. jQuery). |
| 933 | + * |
| 934 | + * Since this directive is global for the angular library, it is recommended |
| 935 | + * that it's added to the top-most HTML element, but it is not mandatory. |
| 936 | + * |
| 937 | + * @example |
| 938 | + * This example shows how to force jqLite using the `ngJq` directive to the `html` tag. |
| 939 | + ```html |
| 940 | + <!doctype html> |
| 941 | + <html ng-app ng-jq> |
| 942 | + ... |
| 943 | + ... |
| 944 | + </html> |
| 945 | + ``` |
| 946 | + * @example |
| 947 | + * This example shows how to use a jQuery based library of a different name. |
| 948 | + * The library name must be available at the top most 'window'. |
| 949 | + ```html |
| 950 | + <!doctype html> |
| 951 | + <html ng-app ng-jq="jQueryLib"> |
| 952 | + ... |
| 953 | + ... |
| 954 | + </html> |
| 955 | + ``` |
| 956 | + */ |
919 | 957 | var jq = function() {
|
920 | 958 | if (isDefined(jq.name_)) return jq.name_;
|
921 | 959 |
|
922 | 960 | var el = document.querySelector('[ng-jq]') || document.querySelector('[data-ng-jq]');
|
923 |
| - var name = undefined; |
| 961 | + var name; |
924 | 962 |
|
925 | 963 | if (el) {
|
926 | 964 | name = el.getAttribute('ng-jq') || el.getAttribute('data-ng-jq') || '';
|
@@ -1501,7 +1539,7 @@ function bindJQuery() {
|
1501 | 1539 |
|
1502 | 1540 | // bind to jQuery if present;
|
1503 | 1541 | var jqName = jq();
|
1504 |
| - jQuery = jqName !== undefined ? window[jqName] : window.jQuery; |
| 1542 | + jQuery = jqName != null ? window[jqName] : window.jQuery; |
1505 | 1543 |
|
1506 | 1544 | // Use jQuery if it exists with proper functionality, otherwise default to us.
|
1507 | 1545 | // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.
|
|
0 commit comments