/** * bootstrap-suggest-plugin - v0.1.29 * @description 这是一个基于 bootstrap 按钮式下拉菜单组件的搜索建议插件,必须使用于按钮式下拉菜单组件上。 * @author lzwme - https://lzw.me * @GitHub https://github.com/lzwme/bootstrap-suggest-plugin.git * @since 2019-11-18 09:30:06 */ !function(e){if("function"==typeof define&&define.amd)define(["jquery"],e);else if("object"==typeof exports&&"object"==typeof module)e(require("jquery"));else{if(!window.jQuery)throw new Error("Not found jQuery.");e(window.jQuery)}}(function(g){var c,s=g(window),l="ActiveXObject"in window,e=navigator.userAgent.match(/Chrome\/(\d+)/);e&&(e=+e[1]);var y=l||51o?i-=o:i=0,t.scrollTop(i))}function F(e,t){e.find("tr."+t.listHoverCSS).removeClass(t.listHoverCSS)}function f(e){var t,n=b;for(t in e)if("value"===t){n=m;break}return n?(window.console&&window.console.trace,m):e.value.length?e:m}function T(e,t){var n=t.effectiveFields;return!("__index"===e||n.length&&!~g.inArray(e,n))}function H(e,t,n,i){n.html('
'+e+"
").show(),j(t,n,i)}function q(e,t){var n=e.parent().find("ul:eq(0)");n.is(":visible")||(n.show(),e.trigger("onShowDropdown",[t?t.data.value:[]]))}function W(e,t){var n=e.parent().find("ul:eq(0)");n.is(":visible")&&(n.hide(),e.trigger("onHideDropdown",[t?t.data.value:[]]))}function B(e,t,n){var i,o,a,r,s,l,u=e.parent().find("ul:eq(0)"),d=0,f=[''],c=t.value;if(!t||!(i=c.length))return n.emptyTip?H(n.emptyTip,e,u,n):(u.empty(),W(e,n)),e;if(n._lastData&&JSON.stringify(n._lastData)===JSON.stringify(t)&&u.find("tr").length===i)return q(e,n),j(e,u,n);n._lastData=t;var p,h=n.effectiveFields.length?n.effectiveFields:g.map(c[0],function(e,t){return t});n.showHeader&&(f.push(""),g.each(h,function(e,t){T(t,n)&&(f.push(""),e++)}),f.push("")),f.push("");var v=Math.min(n.maxOptionCount,i);for(o=0;o',p[t],"")}),f.push('',r.join(""),"")}return f.push("
",n.effectiveFieldsAlias[t]||t,0===e?"("+i+")":"","
"),u.html(f.join("")),q(e,n),setTimeout(function(){if(!y){var e=u.find("table:eq(0)"),t=0,n=0;u.height().'+f.listHoverCSS+"{"+f.listHoverStyle+"}"),t.each(function(){var e,n,t,i,o,a,r,s=g(this),l=s.parent(),u=(i=f,o=(t=s).prev("i.clearable"),i.clearable&&!o.length&&(o=g('').prependTo(t.parent())),o.css({position:"absolute",top:"calc(50% - 6px)",transform:"rotate(45deg)",zIndex:4,cursor:"pointer",width:"14px",lineHeight:"14px",textAlign:"center",fontSize:12}).hide()),d=l.find("ul:eq(0)");(d.parent().css("position","relative"),a=s,r=f,!d.length||a.data(p)?m:(a.data(p,{options:r}),b))&&(f.showBtn||(s.css("borderRadius",4),l.css("width","100%").find(".btn:eq(0)").hide()),s.removeClass(v).prop(v,m).attr("autocomplete","off"),d.css(f.listStyle),f.inputBgColor||(f.inputBgColor=s.css("backgroundColor")),s.on("keydown.bs",function(e){var t,n;if(d.is(":visible")){if(t=d.find("."+f.listHoverCSS),n="",F(d,f),e.keyCode===f.keyDown){if(t.length?t.next().length?n=x(t.next().mouseover()):f.autoSelect&&S(s,"").val(k(s)):n=x(d.find("tbody tr:first").mouseover()),A(s,d,f),!f.autoSelect)return}else if(e.keyCode===f.keyUp){if(t.length?t.prev().length?n=x(t.prev().mouseover()):f.autoSelect&&S(s,"").val(k(s)):n=x(d.find("tbody tr:last").mouseover()),A(s,d,f),!f.autoSelect)return}else e.keyCode===f.keyEnter?(n=x(t),W(s,f)):S(s,"");C(s,n,f)}else S(s,"")}).on("compositionstart.bs",function(e){c=b}).on("compositionend.bs",function(e){c=m}).on("keyup.bs input.bs paste.bs",function(e){var t;e.keyCode&&D(s,f),~g.inArray(e.keyCode,[f.keyDown,f.keyUp,f.keyEnter])?s.val(s.val()):(clearTimeout(n),n=setTimeout(function(){c||(t=s.val(),g.trim(t)&&t===k(s)||(k(s,t),f.multiWord&&(t=t.split(f.separator).reverse()[0]),(t.length||f.allowNoKeyword)&&f.fnGetData(g.trim(t),s,B,f)))},f.delay||300))}).on("focus.bs",function(){j(s,d,f)}).on("blur.bs",function(){e||(W(s,f),c=!0,setTimeout(function(){c=m}))}).on("click.bs",function(){var e=s.val();if(g.trim(e)&&e===k(s)&&d.find("table tr").length)return q(s,f);d.is(":visible")||(f.multiWord&&(e=e.split(f.separator).reverse()[0]),(e.length||f.allowNoKeyword)&&f.fnGetData(g.trim(e),s,B,f))}),l.find(".btn:eq(0)").attr("data-toggle","").click(function(){if(d.is(":visible"))W(s,f);else{if(f.url){if(s.click().focus(),!d.find("tr").length)return m}else B(s,f.data,f);q(s,f)}return m}),d.mouseenter(function(){e=1,s.blur()}).mouseleave(function(){e=0,s.focus()}).on("mouseenter","tbody tr",function(){return F(d,f),g(this).addClass(f.listHoverCSS),m}).on("mousedown","tbody tr",function(){var e=x(g(this));C(s,e,f),k(s,e.key),D(s,f),f.hideOnSelect&&W(s,f)}),u.length&&(u.click(function(){S(s,"").val(""),D(s,f)}),l.mouseenter(function(){s.prop(v)||u.css("right",f.showBtn?Math.max(s.next().width(),33)+2:12).show()}).mouseleave(function(){u.hide()})))})},show:function(){return this.each(function(){g(this).click()})},hide:function(){return this.each(function(){W(g(this))})},disable:function(){return this.each(function(){g(this).attr(v,b).parent().find(".btn:eq(0)").prop(v,b)})},enable:function(){return this.each(function(){g(this).attr(v,m).parent().find(".btn:eq(0)").prop(v,m)})},destroy:function(){return this.each(function(){g(this).off("click.bs keydown.bs compositionstart.bs compositionend.bs keyup.bs input.bs paste.bs focus.bs click.bs").removeData(p).removeAttr("style").parent().find(".btn:eq(0)").off().show().attr("data-toggle","dropdown").prop(v,m).next().css("display","").off()})},version:function(){return"0.1.29"}};g.fn[p]=function(e){if("string"==typeof e&&i[e]){var t=b;return this.each(function(){if(!g(this).data(p))return t=m}),t||"init"===e||"version"===e?i[e].apply(this,[].slice.call(arguments,1)):this}return i.init.apply(this,arguments)}});