1$(function () { 2 $('.select-box') 3 .setSelect({ 4 optionList: eval($('#sitelist').val()), 5 hiddenInput: '#siteid', 6 getOption: '#sOptionBtn', 7 callback: function (option) {} 8 }); 9}); 10(function ($) { 11 $.fn.setSelect = function (options) { 12 var opt = $.extend({ 13 optionList: [], 14 getOption: '', 15 hiddenInput: '', 16 callback: function () {} 17 }, 18 options || {}); 19 return this.each(function () { 20 opt._id = this; 21 var _time; 22 var arrow = $(this).find('i'); 23 24 var defaultvalue = parseInt($(opt.hiddenInput).val()); 25 var defaultoption; 26 $.each(opt.optionList, 27 function (index, item) { 28 if (defaultvalue === item.Value) { 29 defaultoption = item.Name; 30 return false; 31 } 32 }); 33 $(opt.getOption).text(defaultoption); 34 35 $(opt._id).append('<ul id="selectList"></ul>'); 36 37 $.each(opt.optionList, 38 function (index, item) { 39 $("#selectList").append('<li data-value="' + item.Value + '">' + item.Name + '</li>'); 40 }); 41 42 $(opt._id) 43 .bind({ 44 click: function () { 45 $(arrow).addClass('arrow-hover'); 46 $('#selectList').slideDown(); 47 // clearTimeout(_time); 48 return false; 49 } 50 //, 51 //mouseleave: function () { 52 // _time = setTimeout(function () { 53 // $(arrow).removeClass('arrow-hover'); 54 // $('#selectList').slideUp(); 55 // }, 300); 56 //} 57 }); 58 //è·åéæ©çå¼ 59 $('#selectList') 60 .delegate('li', 61 'click', 62 function () { 63 var option = $(this).text(); 64 var value = $(this).data('value'); 65 $(opt.getOption).text(option); 66 $(opt.hiddenInput).val(value); 67 $('#selectList').slideUp(); 68 $(arrow).removeClass('arrow-hover'); 69 opt.callback(option); 70 return false; 71 }); 72 73 $(document) 74 .on('click', 75 function () { 76 $('#selectList').slideUp(); 77 $(arrow).removeClass('arrow-hover'); 78 }); 79 }); 80 }; 81})(jQuery);
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.