|
40 | 40 | return; |
41 | 41 | } |
42 | 42 |
|
43 | | - var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer, lastMousePosition; |
| 43 | + var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer, |
| 44 | + lastMousePosition, $document; |
44 | 45 |
|
45 | 46 | KEY = { |
46 | 47 | TAB: 9, |
|
90 | 91 | } |
91 | 92 | }; |
92 | 93 |
|
| 94 | + $document = $(document); |
| 95 | + |
93 | 96 | nextUid=(function() { var counter=1; return function() { return counter++; }; }()); |
94 | 97 |
|
95 | 98 | function indexOf(value, array) { |
|
162 | 165 | }); |
163 | 166 | } |
164 | 167 |
|
165 | | - $(document).delegate("body", "mousemove", function (e) { |
| 168 | + $document.delegate("body", "mousemove", function (e) { |
166 | 169 | lastMousePosition = {x: e.pageX, y: e.pageY}; |
167 | 170 | }); |
168 | 171 |
|
|
493 | 496 | * |
494 | 497 | * also takes care of clicks on label tags that point to the source element |
495 | 498 | */ |
496 | | - $(document).ready(function () { |
497 | | - $(document).delegate("body", "mousedown touchend", function (e) { |
| 499 | + $document.ready(function () { |
| 500 | + $document.delegate("body", "mousedown touchend", function (e) { |
498 | 501 | var target = $(e.target).closest("div.select2-container").get(0), attr; |
499 | 502 | if (target) { |
500 | | - $(document).find("div.select2-container-active").each(function () { |
| 503 | + $document.find("div.select2-container-active").each(function () { |
501 | 504 | if (this !== target) $(this).data("select2").blur(); |
502 | 505 | }); |
503 | 506 | } else { |
504 | 507 | target = $(e.target).closest("div.select2-drop").get(0); |
505 | | - $(document).find("div.select2-drop-active").each(function () { |
| 508 | + $document.find("div.select2-drop-active").each(function () { |
506 | 509 | if (this !== target) $(this).data("select2").blur(); |
507 | 510 | }); |
508 | 511 | } |
|
0 commit comments