PageSourceSearch

https://vis-hosting.com/wp-content/plugins/hostiko-toolkit/assets/js/nice-select.js?ver=7.1.2

js vis-hosting.com collected 2026-10-06 06:27:50 UTC 7,386 bytes, 198 lines download raw bytes

1
2/*  jQuery Nice Select - v1.1.0
3    https://github.com/hernansartorio/jquery-nice-select
4    Made by Hernán Sartorio  */
5 
6    (function(jQuery) {
7
8        jQuery.fn.niceSelect = function(method) {
9          
10          // Methods
11          if (typeof method == 'string') {      
12            if (method == 'update') {
13              this.each(function() {
14                var $select = jQuery(this);
15                var $dropdown = jQuery(this).next('.nice-select');
16                var open = $dropdown.hasClass('open');
17                
18                if ($dropdown.length) {
19                  $dropdown.remove();
20                  create_nice_select($select);
21                  
22                  if (open) {
23                    $select.next().trigger('click');
24                  }
25                }
26              });
27            } else if (method == 'destroy') {
28              this.each(function() {
29                var $select = jQuery(this);
30                var $dropdown = jQuery(this).next('.nice-select');
31                
32                if ($dropdown.length) {
33                  $dropdown.remove();
34                  $select.css('display', '');
35                }
36              });
37              if (jQuery('.nice-select').length == 0) {
38                jQuery(document).off('.nice_select');
39              }
40            } else {
41              console.log('Method "' + method + '" does not exist.')
42            }
43            return this;
44          }
45            
46          // Hide native select
47          this.hide();
48          
49          // Create custom markup
50          this.each(function() {
51            var $select = jQuery(this);
52            
53            if (!$select.next().hasClass('nice-select')) {
54              create_nice_select($select);
55            }
56          });
57          
58          function create_nice_select($select) {
59            $select.after(jQuery('<div></div>')
60              .addClass('nice-select')
61              .addClass($select.attr('class') || '')
62              .addClass($select.attr('disabled') ? 'disabled' : '')
63              .attr('tabindex', $select.attr('disabled') ? null : '0')
64              .html('<span class="current"></span><ul class="list"></ul>')
65            );
66              
67            var $dropdown = $select.next();
68            var $options = $select.find('option');
69            var $selected = $select.find('option:selected');
70            
71            $dropdown.find('.current').html($selected.data('display') || $selected.text());
72            
73            $options.each(function(i) {
74              var $option = jQuery(this);
75              var display = $option.data('display');
76      
77              $dropdown.find('ul').append(jQuery('<li></li>')
78                .attr('data-value', $option.val())
79                .attr('data-display', (display || null))
80                .addClass('option' +
81                  ($option.is(':selected') ? ' selected' : '') +
82                  ($option.is(':disabled') ? ' disabled' : ''))
83                .html($option.text())
84              );
85            });
86          }
87          
88          /* Event listeners */
89          
90          // Unbind existing events in case that the plugin has been initialized before
91          jQuery(document).off('.nice_select');
92          
93          // Open/close
94          jQuery(document).on('click.nice_select', '.nice-select', function(event) {
95            var $dropdown = jQuery(this);
96            
97            jQuery('.nice-select').not($dropdown).removeClass('open');
98            $dropdown.toggleClass('open');
99            
100            if ($dropdown.hasClass('open')) {
101              $dropdown.find('.option');  
102              $dropdown.find('.focus').removeClass('focus');
103              $dropdown.find('.selected').addClass('focus');
104            } else {
105              $dropdown.focus();
106            }
107          });
108          
109          // Close when clicking outside
110          jQuery(document).on('click.nice_select', function(event) {
111            if (jQuery(event.target).closest('.nice-select').length === 0) {
112                jQuery('.nice-select').removeClass('open').find('.option');  
113            }
114          });
115          
116          // Option click
117          jQuery(document).on('click.nice_select', '.nice-select .option:not(.disabled)', function(event) {
118            var $option = jQuery(this);
119            var $dropdown = $option.closest('.nice-select');
120            
121            $dropdown.find('.selected').removeClass('selected');
122            $option.addClass('selected');
123            
124            var text = $option.data('display') || $option.text();
125            $dropdown.find('.current').text(text);
126            
127            $dropdown.prev('select').val($option.data('value')).trigger('change');
128          });
129      
130          // Keyboard events
131          jQuery(document).on('keydown.nice_select', '.nice-select', function(event) {    
132            var $dropdown = jQuery(this);
133            var $focused_option = jQuery($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));
134            
135            // Space or Enter
136            if (event.keyCode == 32 || event.keyCode == 13) {
137              if ($dropdown.hasClass('open')) {
138                $focused_option.trigger('click');
139              } else {
140                $dropdown.trigger('click');
141              }
142              return false;
143            // Down
144            } else if (event.keyCode == 40) {
145              if (!$dropdown.hasClass('open')) {
146                $dropdown.trigger('click');
147              } else {
148                var $next = $focused_option.nextAll('.option:not(.disabled)').first();
149                if ($next.length > 0) {
150                  $dropdown.find('.focus').removeClass('focus');
151                  $next.addClass('focus');
152                }
153              }
154              return false;
155            // Up
156            } else if (event.keyCode == 38) {
157              if (!$dropdown.hasClass('open')) {
158                $dropdown.trigger('click');
159              } else {
160                var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
161                if ($prev.length > 0) {
162                  $dropdown.find('.focus').removeClass('focus');
163                  $prev.addClass('focus');
164                }
165              }
166              return false;
167            // Esc
168            } else if (event.keyCode == 27) {
169              if ($dropdown.hasClass('open')) {
170                $dropdown.trigger('click');
171              }
172            // Tab
173            } else if (event.keyCode == 9) {
174              if ($dropdown.hasClass('open')) {
175                return false;
176              }
177            }
178          });
179      
180          // Detect CSS pointer-events support, for IE <= 10. From Modernizr.
181          var style = document.createElement('a').style;
182          style.cssText = 'pointer-events:auto';
183          if (style.pointerEvents !== 'auto') {
184            jQuery('html').addClass('no-csspointerevents');
185          }
186          
187          return this;
188      
189        };
190      
191      }(jQuery));
192      
193      
194      jQuery(document).ready(function() {
195        jQuery('.hostiko-select-field').niceSelect();
196      });
197
198      

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.