You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/BookingWeb/Content/hplus/js/plugins/suggest/bootstrap-suggest.min.js

10 lines
10 KiB
JavaScript

2 years ago
/**
* 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||51<e,v="bsSuggest",g="onDataRequestSuccess",y="disabled",m=!0,w=!1;function b(e){return void 0===e}function x(e){return e.data()}function k(e,t){return b(t)?e.attr("alt"):e.attr("alt",t)}function S(e,t){return void 0!==t?e.attr("data-id",t):e.attr("data-id")}function j(e,t,n){if(t&&t.key){var i,r,o=n.separator||",",a=S(e);n&&n.multiWord?((i=e.val().split(o))[i.length-1]=t.key,a?(r=a.split(o)).push(t.id):r=[t.id],S(e,r.join(o)).val(i.join(o)).focus()):S(e,t.id||"").val(t.key).focus(),e.data("pre-val",e.val()).trigger("onSetSelectValue",[t,(n.data.value||n._lastData.value)[t.index]])}}function C(i,r,e){if(r.is(":visible")){var o=i.parent(),t=o.height(),n=o.width();e.autoDropup&&setTimeout(function(){var e=i.offset().top,t=l.scrollTop(),n=r.height();l.height()+t-e<n&&n+t<e?o.addClass("dropup"):o.removeClass("dropup")},10);var a={};return"left"===e.listAlign?a={left:i.siblings("div").width()-n,right:"auto"}:"right"===e.listAlign&&(a={left:"auto",right:0}),s&&!e.showBtn&&(o.hasClass("dropup")?(a.top="auto",a.bottom=t):(a.top=t,a.bottom="auto")),e.autoMinWidth||(a.minWidth=n),r.css(a),i}}function D(e,t){var n,i,r;if(-1===t.indexId&&!t.idField||t.multiWord)return e;i=t.inputBgColor,r=t.inputWarnColor;var o=e.val(),a=e.data("pre-val");return S(e)||!o?(e.css("background",i||""),!o&&a&&e.trigger("onUnsetSelectValue").data("pre-val","")):(n=e.css("backgroundColor").replace(/ /g,"").split(",",3).join(","),~r.indexOf(n)||e.trigger("onUnsetSelectValue").data("pre-val","").css("background",r)),e}function A(e,t,n){var i,r,o=e.parent().find("tbody tr."+n.listHoverCSS);o.length&&(i=(o.index()+3)*o.height(),(r=+t.css("maxHeight").replace("px",""))<i||t.scrollTop()>r?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('<div style="padding:10px 5px 5px">'+e+"</div>").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=['<table class="table table-condensed table-sm" style="margin:0">'],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("<thead><tr>"),p[0])T(o,n)&&(c.push("<th>",n.effectiveFieldsAlias[o]||o,0===f?"("+i+")":"","</th>"),f++);c.push("</tr></thead>")}for(c.push("<tbody>"),r=0;r<i;r++){for(o in f=0,a=[],l=(u=p[r])[n.idField],s=u[n.keyField],u)b(s)&&n.indexKey===f&&(s=u[o]),b(l)&&n.indexId===f&&(l=u[o]),f++,T(o,n)&&a.push('<td data-name="',o,'">',u[o],"</td>");c.push('<tr data-index="',u.__index||r,'" data-id="',l,'" data-key="',s,'">',a.join(""),"</tr>")}return c.push("</tbody></table>"),d.html(c.join("")),q(e,n),setTimeout(function(){if(!h){var e=d.find("table:eq(0)"),t=0,n=0;d.height()<e.height()&&+d.css("minWidth").replace("px","")<d.width()&&(t=18,n=20),d.css("paddingRight",t),e.css("marginBottom",n)}},301),C(e,d,n),e}function _(t,n){n=n||"";var e=t._preAjax;e&&e.abort&&4!==e.readyState&&e.abort();var i={type:"GET",dataType:t.jsonp?"jsonp":"json",timeout:5e3};t.jsonp&&(i.jsonp=t.jsonp);var r,o=t.fnAdjustAjaxParam;if(c.isFunction(o)){if(r=o(n,t),w===r)return;c.extend(i,r)}return i.url=function(){if(!n||i.data)r
//# sourceMappingURL=bootstrap-suggest.min.js.map