layui.define(["jquery"],function(C){var a=layui.$,u="layext-text-tool",t="layext-textool-pane",y,d=!0,x,p=[],o={hide:null,count:null,copy:null,reset:null,clear:null,hideIndex:-1,countIndex:-1,copyIndex:-1,resetIndex:-1,clearIndex:-1,hideName:"hide",countName:"count",copyName:"copy",resetName:"reset",clearName:"clear",hideClass:"layext-textool-minmax",countClass:"layext-textool-count",maxClass:"layext-textool-max",copyClass:"layext-textool-copy",resetClass:"layext-textool-reset",clearClass:"layext-textool-clear",copyTextId:u+"-copy-text",lengthClass:"layext-textool-length",lengthOverClass:u+"-length-over",laytips:"layext-textool-laytips"},g={eleId:null,maxlength:-1,initEnd:a.noop,showEnd:a.noop,hideEnd:a.noop,initShow:!0,inner:!1,align:"right",tools:["count","copy","reset","clear"],tipType:"title",tipColor:"#01AAED",color:"#666666",bgColor:"#FFFFFF",borderColor:"#E6E6E6",className:"",zIndex:19891014},r=function(e){var n=this;n.tipsAttr=null,n.selector=null,n.init(n,e||{})};r.prototype.init=function(e,n){e.options=a.extend({},g,n),e.selector=a.trim(e.options.eleId)===""?"."+u:"#"+e.options.eleId,e.initStyle(e),e.initPrototype(),a(e.selector).each(function(l,s){var c=a(this),i=e.options.maxlength;!isNaN(i)&&i>-1&&c.attr("maxlength",i),e.addTextool(e,c)}),e.initTips(e),typeof e.options.initEnd=="function"&&e.options.initEnd()},r.prototype.initStyle=function(e){e.options.zIndex=isNaN(e.options.zIndex)?0:e.options.zIndex||0,y=['"].join(""),a("head link:last")[0]&&a("head link:last").after(y)||a("head").append(y)},r.prototype.initPrototype=function(){!Array.prototype.indexOf&&(Array.prototype.indexOf=function(e,n){e=e||[];for(var l=e.length;l--;)if(e[l]==n)return l;return-1})},r.prototype.addTextool=function(e,n){var l=n.next("."+t);l&&l.length&&l.remove(),n.after(e.getToolsNode(e,n)),l=n.next("."+t),e.setEvent(e,n,l),l.fadeIn(200,function(){!e.options.initShow&&l.find("."+o.hideClass).trigger("click")})},r.prototype.copyText=function(e,n){if(!n)return!1;!a("#"+o.copyTextId).length&&a("body").append("');var l=a("#"+o.copyTextId),s=n.val();l.val(s===""?" ":s).select(),document.execCommand("copy"),e.showTip(e,n,"已复制!")},r.prototype.setValLength=function(e,n){var l=n.next("."+t).find("."+o.countClass);l.text(n.val().length),n.val().length>n.attr("maxlength")?l.addClass(o.lengthOverClass):l.hasClass(o.lengthOverClass)&&l.removeClass(o.lengthOverClass)},r.prototype.setEvent=function(e,n,l){e.setValLength(e,n);var s=n.val();l.on("click","a",function(c){var i=a(this),f=i.children("i.layui-icon");return i.hasClass(o.hideClass)&&(i.nextAll().toggle("fast"),i.prevAll().toggle("fast"),f.hasClass("layui-icon-more")?(f.removeClass("layui-icon-more").addClass("layui-icon-more-vertical"),i.attr(e.tipsAttr,"展开"),typeof e.options.hideEnd=="function"&&e.options.hideEnd(n,l)):(f.removeClass("layui-icon-more-vertical").addClass("layui-icon-more"),i.attr(e.tipsAttr,"收起"),typeof e.options.showEnd=="function"&&e.options.showEnd(n,l)),e.tipsAttr===o.laytips&&e.showTip(e,i,i.attr(e.tipsAttr))),i.hasClass(o.copyClass)&&e.copyText(e,n),i.hasClass(o.resetClass)&&(n.val(s),e.setValLength(e,n)),i.hasClass(o.clearClass)&&(n.val(""),e.setValLength(e,n)),layui.stope(c),!1}),n.on("keyup input",function(c){return e.setValLength(e,n),layui.stope(c),!1})},r.prototype.getToolsNode=function(e,n){if(!n)return!1;if(o.hide=[''].join(""),e.options.tools=e.options.tools||[o.countName],o.countIndex=e.options.tools.indexOf(o.countName),o.countIndex>-1){var l=n.attr("maxlength")||-1;o.count=['0",l<0?"":['/",l,""].join(""),""].join("")}o.copyIndex=e.options.tools.indexOf(o.copyName),o.copyIndex>-1&&(o.copy=[''].join("")),o.resetIndex=e.options.tools.indexOf(o.resetName),o.resetIndex>-1&&(o.reset=[''].join("")),o.clearIndex=e.options.tools.indexOf(o.clearName),o.clearIndex>-1&&(o.clear=[''].join("")),e.options.align==="left"?(d=!1,x=t+"-l"):(d=!0,x=t+"-r"),p=[''],!d&&p.push(o.hide);for(var s=0;s"),p.join("")},r.prototype.getTips=function(e,n){switch(e.options.tipType){case"title":e.tipsAttr="title";break;case"laytips":e.tipsAttr=o.laytips;break;default:return""}return[" ",e.tipsAttr,"=",n," "].join("")},r.prototype.initTips=function(e){a("["+o.laytips+"]").each(function(n,l){var s=a(l);a.trim(s.attr(e.tipsAttr))!==""&&s.hover(function(){e.showTip(e,s,s.attr(e.tipsAttr))},e.hideTip)})},r.prototype.showTip=function(e,n,l){e.hideTip(),layui.layer.tips(l,n,{tips:[1,e.options.tipColor||"#01AAED"],time:2e3,anim:5,zIndex:(e.options.zIndex||0)+2})},r.prototype.hideTip=function(){layui.layer.closeAll("tips")},C("textool",{init:function(e){return new r(e)}})});