wp_back/wp-content/plugins/svg-support/js/min/jquery.dropdown-min.js

1 line
10 KiB
JavaScript
Raw Normal View History

2024-05-20 15:37:46 +03:00
(function(e){"use strict";function o(){}function n(e,o,n){var t,i,l,a=null,d=0;n||(n={});var s=function(){d=n.leading===!1?0:(new Date).getTime(),a=null,l=e.apply(t,i),a||(t=i=null)};return function(){var r=(new Date).getTime();d||n.leading!==!1||(d=r);var c=o-(r-d);return t=this,i=arguments,c<=0||c>o?(clearTimeout(a),a=null,d=r,l=e.apply(t,i),a||(t=i=null)):a||n.trailing===!1||(a=setTimeout(s,c)),l}}function t(){var e=this.isLabelMode,o=this.config.searchable,n=o?'<span class="dropdown-search">'+this.config.input+"</span>":"";return e?'<div class="dropdown-display-label"><div class="dropdown-chose-list">'+n+'</div></div><div class="dropdown-main">{{ul}}</div>':'<a href="javascript:;" class="dropdown-display" tabindex="0"><span class="dropdown-chose-list"></span><a href="javascript:;" class="dropdown-clear-all" tabindex="0">×</a></a><div class="dropdown-main">'+n+"{{ul}}</div>"}function i(){var o=this,n=o.config,t=o.$el,i=t.find(".dropdown-minItem-alert"),l=n.minCountErrorMessage;clearTimeout(o.itemCountAlertTimer),0===i.length&&(l||(l="最低选择"+n.minCount+"个"),i=e('<div class="dropdown-minItem-alert">'+l+"</div>")),t.append(i),o.itemCountAlertTimer=setTimeout(function(){t.find(".dropdown-minItem-alert").remove()},f)}function l(){var o=this,n=o.config,t=o.$el,i=t.find(".dropdown-maxItem-alert"),l=n.limitCountErrorMessage;clearTimeout(o.itemLimitAlertTimer),0===i.length&&(l||(l="最多可选择"+n.limitCount+"个"),i=e('<div class="dropdown-maxItem-alert">'+l+"</div>")),t.append(i),o.itemLimitAlertTimer=setTimeout(function(){t.find(".dropdown-maxItem-alert").remove()},f)}function a(o){var n=o||"";return n=n.replace(/<select[^>]*>/gi,"").replace("</select>",""),n=n.replace(/<\/optgroup>/gi,""),n=n.replace(/<optgroup[^>]*>/gi,function(e){var o=/label="(.[^"]*)"(\s|>)/.exec(e),n=/data\-group\-id="(.[^"]*)"(\s|>)/.exec(e);return'<li class="dropdown-group" data-group-id="'+(n?n[1]:"")+'">'+(o?o[1]:"")+"</li>"}),n=n.replace(/<option(.*?)<\/option>/gi,function(o){var n=e(o).val(),t=/>(.*)<\//.exec(o),i=o.indexOf("selected")>-1,l=o.indexOf("disabled")>-1,a="";o.replace(/data-(\w+)="?(.[^"]+)"?/g,function(e){a+=e+" "});return"<li "+(l?" disabled":' tabindex="0"')+' data-value="'+(n||"")+'" class="dropdown-option '+(i?"dropdown-chose":"")+'" '+a+">"+(t?t[1]:"")+"</li>"})}function d(o){var n=this,t={},i="",l=[],a=0,d=n.config.extendProps;return!(!o||!o.length)&&(e.each(o,function(o,n){var i=n.groupId,s=n.disabled?" disabled":"",r=n.selected&&!s?" selected":"",c="";e.each(d,function(e,o){n[o]&&(c+="data-"+o+'="'+n[o]+'" ')});var p="<option"+s+r+' value="'+n.id+'" '+c+">"+n.name+"</option>";r&&(l.push('<span class="dropdown-selected">'+n.name+'<i class="del" data-id="'+n.id+'"></i></span>'),a++),i?t[n.groupId]?t[n.groupId]+=p:t[n.groupId]=n.groupName+"&janking&"+p:t[o]=p}),e.each(t,function(e,o){var n=o.split("&janking&");if(2===n.length){var t=n[0],l=n[1];i+='<optgroup label="'+t+'" data-group-id="'+e+'">'+l+"</optgroup>"}else i+=o}),[i,l,a])}function s(o){function n(o,n){var t=e(n);this.id=t.prop("value"),this.name=t.text(),this.disabled=t.prop("disabled"),this.selected=t.prop("selected")}var t=o,i=[];return e.each(t.children(),function(o,t){var l={},a={},d=e(t);"OPTGROUP"===t.nodeName?(a.groupId=d.data("groupId"),a.groupName=d.attr("label"),e.each(d.children(),e.proxy(n,l)),e.extend(l,a)):e.each(d,e.proxy(n,l)),i.push(l)}),i}function r(o,n){this.$el=e(n),this.$select=this.$el.find("select"),this.placeholder=this.$select.attr("placeholder"),this.config=o,this.name=[],this.isSingleSelect=!this.$select.prop("multiple"),this.selectAmount=0,this.itemLimitAlertTimer=null,this.isLabelMode="label"===this.config.multipleMode,this.init()}var c=function(){var e=navigator.userAgent.toLowerCase();if(e.indexOf("safari")!==-1)return!(e.indexOf("chrome")>-1)}(),p={readonly:!1,minCount:0,minCountErrorMessage:"",limitCount:1/0,limitCountErrorMessage:"",input:'<input type="text" maxLength="20" placeholder="搜索关键词或ID">',data:[],searchable:!0,searchNoData:'<li style="color:#ddd">查无数据,换个词儿试试 /(ㄒoㄒ)/~~</li>'