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