You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/public/static/plug/layui-dropdown/dropdown.js

7 lines
12 KiB

11 months ago
/**
* layui_dropdown
* v2.3.5
* by Microanswer
* http://layuidropdown.microanswer.cn/
**/
Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"")}),Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new Error("Function.prototype.bind - what is trying to be bound is not callable");function n(){}function i(){return e.apply(this instanceof n&&t?this:t,o.concat(Array.prototype.slice.call(arguments)))}var o=Array.prototype.slice.call(arguments,1),e=this;return n.prototype=this.prototype,i.prototype=new n,i}),layui.define(["jquery","laytpl"],function(t){function i(t,n){var i=e[t]||[];i.push(n),e[t]=i}function d(t,i){var n=e[t]||[];a.each(n,function(t,n){n(i)})}var a=layui.jquery||layui.$,l=layui.laytpl,o="a",p="b",e={},c="1",h="2",m="3";function f(t){if(!t)throw new Error("菜单条目内必须填写内容。");if("hr"===t)return"hr";if(0!==t.indexOf("{"))throw new Error("除了分割线hr,别的菜单条目都必须保证是合格的Javascript对象或json对象。");return new Function("return "+t)()}function u(t){for(var n=0;n<t.length;n++)void 0!==t[n]&&null!==t[n]||(t.splice(n,1),n--)}function w(t){if(t&&0<t.length){for(var n=0,i=[],o=0;o<t.length;o++)for(var e=t[o],s=0;s<e.length;s++)e[s].header&&e[s].fixed&&(n++,i.push(e[s]),e.splice(s,1),s--);if(0<n)return i}return null}var y=window.MICROANSWER_DROPDOWAN||"dropdown",v="<div tabindex='0' class='layui-anim layui-anim-upbit layu-dropdown-root' "+y+"-id='{{d.downid}}' style='display: none;z-index: {{d.zIndex}}'>{{# if (d.arrow){ }}<div class='layu-dropdown-pointer'></div>{{# } }}<div class='layu-dropdown-content' style='margin: {{d.gap}}px {{d.gap}}px;background-color: {{d.backgroundColor}};min-width: {{d.minWidth}}px;max-width: {{d.maxWidth}}px;min-height: {{d.minHeight}}px;max-height: {{d.maxHeight}}px;white-space: {{d.nowrap?\"nowrap\":\"normal\"}}'>",g="</div></div>",x=v+"<div class='layu-dropdown-content-table' cellpadding='0' cellspacing='0'>{{# if (d.fixHeaders && d.fixHeaders.length > 0){ }}<div class='layu-dropdown-content-thead'><div class='layu-dropdown-content-tr'>{{# layui.each(d.fixHeaders, function(i, fixHeader){ }}{{# if (fixHeader) { }}<div class='layu-dropdown-content-th'><div class='layu-dropdown-menu-fixed-head {{(d.menuSplitor && i < (d.menus.length-1))?\"layu-menu-splitor\":\"\"}}'><div class='layu-menu-fixed-head' style='text-align: {{fixHeader.align||\"center\"}}'>{{fixHeader.header}}</div></div></div>{{# } else { }}<th><div class='layu-dropdown-menu-fixed-head {{(d.menuSplitor && i < (d.menus.length-1))?\"layu-menu-splitor\":\"\"}}'><div class='layu-menu-fixed-head'>&nbsp;</div></div></th>{{# } }}{{# }); }}</div></div>{{# } }}<div class='layu-dropdown-content-tbody'><div class='layu-dropdown-content-tr'>{{# layui.each(d.menus, function(i, menu){ }}<div class='layu-dropdown-content-td' valign='top'><div class='layu-dropdown-menu-wrap {{(d.menuSplitor && i < (d.menus.length-1))?\"layu-menu-splitor\":\"\"}} layu-overflowauto' style='min-height: {{d.minHeight}}px;max-height: {{d.maxHeight - ((d.fixHeaders)?24:0)}}px;'><ul class='layu-dropdown-menu' dropdown-menu-index='{{i}}' style=''>{{# layui.each(menu, function(index, item){ }}<li class='layu-menu-item-wrap {{(d.fixHeaders && d.fixHeaders.length) > 0?\"layu-nomargin\":\"\"}}'>{{# if ('hr' === item) { }}<hr>{{# } else if (item.header) { }}{{# if (item.withLine) { }}<fieldset class=\"layui-elem-field layui-field-title layu-menu-header layu-withLine\"><legend>{{item.header}}</legend></fieldset>{{# } else { }}<div class='layu-menu-header' style='text-align: {{item.align||\"left\"}}'>{{item.header}}</div>{{# } }}{{# } else { }}<div class='layu-menu-item' dropdown-menu-item-index='{{index}}'><a href='javascript:;' lay-event='{{item.event}}'>{{# if (item.layIcon){ }}<i class='layui-icon {{item.layIcon}}'></i>&nbsp;{{# } }}<span class='{{item.txtClass||\"\"}}'>{{item.txt}}</span></a></div>{{# } }}</li>{{# }); }}</ul></div></div>{{#});}}</div></div></div>"+g,$={menus:void 0,templateMenu:"",templateMenuStr:""