1 2/* 3Reference: http://jsfiddle.net/BB3JK/47/ 4*/ 5if ($(window).width() > 767) { 6 $(document).ready(function(){ 7 select_function(); 8 }); 9} 10 11function select_function() { 12 $('select.liselect').each(function(){ 13 var $this = $(this), numberOfOptions = $(this).children('option').length; 14 $this.addClass('select-hidden'); 15 $this.wrap('<div class="select"></div>'); 16 $this.after('<div class="select-styled"></div>'); 17 18 var $styledSelect = $this.next('div.select-styled'); 19 $styledSelect.text($this.children('option').eq(0).text()); 20 21 var $list = $('<ul />', { 22 'class': 'select-options' 23 }).insertAfter($styledSelect); 24 25 for (var i = 0; i < numberOfOptions; i++) { 26 $('<li />', { 27 text: $this.children('option').eq(i).text(), 28 rel: $this.children('option').eq(i).val() 29 }).appendTo($list); 30 } 31 32 var option = $(this).children(`option[value="${$this.val()}"]`); 33 let text = ''; 34 if(option.length){ 35 text = option.text() 36 if(text) 37 $styledSelect.text(text) 38 } 39 var $listItems = $list.children('li'); 40 41 $styledSelect.click(function(e) { 42 e.stopPropagation(); 43 $('div.select-styled.active').not(this).each(function(){ 44 $(this).removeClass('active').next('ul.select-options').hide(); 45 }); 46 $(this).toggleClass('active').next('ul.select-options').toggle(); 47 }); 48 49 $listItems.click(function(e) { 50 e.stopPropagation(); 51 $styledSelect.text($(this).text()).removeClass('active'); 52 $this.val($(this).attr('rel')); 53 $this.trigger("change"); 54 $list.hide(); 55 }); 56 57 $(document).click(function() { 58 $styledSelect.removeClass('active'); 59 $list.hide(); 60 }); 61 62 63 }); 64}
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.