@@ -19,42 +19,11 @@ function MultiSelectDropdown(items, singularItemTitle, pluralItemTitle) {
1919 self . dropdownOpen ( ! self . dropdownOpen ( ) ) ;
2020 } ;
2121
22- this . isAncestor = function ( element , ancestorSelector ) {
23- var $target = $ ( element ) ;
24- // '.closest' returns the list of ancestors between this element and the selector.
25- // If the selector is not an ancestor of the element, it returns an empty list.
26- return ! ! $target . closest ( ancestorSelector ) . length ;
27- } ;
28-
29- this . isElementInsideDropdown = function ( element ) {
30- return self . isAncestor ( element , self . dropdownSelector ) ;
31- } ;
32-
33- // If the user clicks outside of the dropdown, close it.
34- $ ( document ) . click ( function ( event ) {
35- if ( ! self . isElementInsideDropdown ( event . target ) ) {
36- self . dropdownOpen ( false ) ;
37- }
38- } ) ;
39-
40- // If an element outside of the dropdown gains focus, close it.
41- $ ( document ) . focusin ( function ( event ) {
42- if ( ! self . isElementInsideDropdown ( event . target ) ) {
43- self . dropdownOpen ( false ) ;
44- }
45- } ) ;
46-
47- $ ( document ) . keydown ( function ( event ) {
48- var target = event . target ;
49- if ( self . isElementInsideDropdown ( target ) ) {
50- // If we press escape while focus is inside the dropdown, close it
51- if ( event . which === 27 ) { // Escape key
52- self . dropdownOpen ( false ) ;
53- event . preventDefault ( ) ;
54- $ ( self . dropdownBtnSelector ) . focus ( ) ;
55- }
56- }
57- } ) ;
22+ window . nuget . configureDropdown (
23+ self . dropdownSelector ,
24+ self . dropdownBtnSelector ,
25+ self . dropdownOpen ,
26+ false ) ;
5827
5928 // A filter to be applied to the items
6029 this . filter = ko . observable ( '' ) ;
0 commit comments