-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathlitewebchatinput.min.js
1 lines (1 loc) · 1.87 KB
/
litewebchatinput.min.js
1
function insertAtCursor(e,t){if(document.selection)e.focus(),sel=document.selection.createRange(),sel.text=t;else if(e.selectionStart||"0"==e.selectionStart){var n=e.selectionStart,l=e.selectionEnd;e.value=e.value.substring(0,n)+t+e.value.substring(l,e.value.length),e.selectionStart=n+t.length,e.selectionEnd=n+t.length}else e.value+=t}var upperChild=document.querySelector(".lite-chatbox"),oLine=document.querySelector(".lite-chatinput hr"),downChild=document.querySelector(".lite-chatinput"),emojiBtn=document.getElementById("emojiBtn"),editFullScreen=document.getElementById("editFullScreen"),exitFullScreen=document.getElementById("exitFullScreen"),emojiMart=document.getElementById("emojiMart"),toolMusk=document.getElementById("toolMusk"),pickerOptions={locale:"zh",onEmojiSelect:function(e){emojiMart.style.display="none",toolMusk.style.display="none",insertAtCursor(document.querySelector(".lite-chatinput textarea"),e.native)}},picker=new EmojiMart.Picker(pickerOptions);emojiMart.appendChild(picker),oLine.onmousedown=function(e){var t=e||event,n=t.clientY,l=upperChild.offsetHeight,o=downChild.offsetHeight;return document.onmousemove=function(e){var t=e||event,i=t.clientY-n;100<l+i&&100<o-i&&(upperChild.style.height=l+i+"px",downChild.style.height=o-i+"px")},document.onmouseup=function(){document.onmousedown=null,document.onmousemove=null},!1},emojiBtn.onclick=function(){emojiMart.style.display="block",toolMusk.style.display="block"},editFullScreen.onclick=function(){nowHeight=downChild.clientHeight,downChild.style.height="100%",editFullScreen.style.display="none",exitFullScreen.style.display="block",oLine.style.display="none"},exitFullScreen.onclick=function(){downChild.style.height=`${nowHeight}px`,exitFullScreen.style.display="none",editFullScreen.style.display="block",oLine.style.display="block"},toolMusk.onclick=function(){emojiMart.style.display="none",toolMusk.style.display="none"};