-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathlitewebchatinput.min.js
1 lines (1 loc) · 2.1 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 l=e.selectionStart,n=e.selectionEnd;e.value=e.value.substring(0,l)+t+e.value.substring(n,e.value.length),e.selectionStart=l+t.length,e.selectionEnd=l+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,l=t.clientY,n=upperChild.offsetHeight,i=downChild.offsetHeight;return document.onmousemove=function(e){var t=e||event,o=t.clientY-l;100<n+o&&100<i-o&&(upperChild.style.height=`calc(100% - ${i-o}px)`,downChild.style.height=i-o+"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(){downHeight=downChild.clientHeight,upperHeight=upperChild.clientHeight,downChild.style.height="100%",upperChild.style.height="0px",editFullScreen.style.display="none",exitFullScreen.style.display="block",oLine.style.display="none"},exitFullScreen.onclick=function(){0!=upperHeight?(downChild.style.height=`${downHeight}px`,upperChild.style.height=`calc(100% - ${downHeight}px)`):(upperChild.style.height="calc(100% - 150px)",downChild.style.height="150px"),exitFullScreen.style.display="none",editFullScreen.style.display="block",oLine.style.display="block"},toolMusk.onclick=function(){emojiMart.style.display="none",toolMusk.style.display="none"};