Files
Miroca_Server/www/static/file/home/js/home-undercut-1.0.min.js
Victor Alexandrovich Tsyrenschikov 75be663d7f css,js,ws
2026-01-02 18:20:49 +05:00

2 lines
5.2 KiB
JavaScript

function t_quillUndercut_init(){t_quillUndercut_addStyles(),t_quillUndercut_controlHandlers(),t_quillUndercut_parseNodes()}function t_quillUndercut__getId(){return"undercut-text-"+window.T_UNDERCUT_ID++}function t_quillUndercut_parseNodes(t){var e;void 0===t&&(t=document),t.querySelectorAll(".ql-undercut").forEach((function(t){if("string"!=typeof t.id||!t.id.startsWith("undercut-text")){var e=t_quillUndercut__getId(),n=t.getAttribute("data-show-text")||"",r=t.getAttribute("data-color")||"#000000",i=t.getAttribute("data-style")||"none",u=document.createElement("button");u.innerHTML=n||"[+]",u.className="ql-undercut__show ql-undercut_button",u.style.color=r,u.style.borderBottom="1px "+i+" "+r,u.setAttribute("aria-label",n||t_quillUndercut_translate("show")),u.setAttribute("aria-controls",e),t.innerHTML="",t.appendChild(u),t.setAttribute("id",e),t_quillUndercut_addEllipsis(t)}}))}function t_quillUndercut_controlHandlers(){document.addEventListener("click",(function(t){var e=t.target;if((e.closest(".ql-undercut__show")||e.closest(".ql-undercut__hide"))&&e.parentNode){var n=e.closest(".t-rec"),r=n&&n.getAttribute("id")||"";r=r.replace("rec","");var i=e.parentNode,u=i.getAttribute("data-color")||"#000000",l=i.getAttribute("data-style")||"none";if(e.closest(".ql-undercut__show")){var o=t_quillUndercut_unEscapeHtml(i.getAttribute("data-text")||""),a=i.getAttribute("data-hide-text")||"";if(i.innerHTML=o,/(\s|&nbsp;)$/.test(o)||(i.innerHTML+=" "),t_quillUndercut_removeEllipsis(i),t_quillUndercut__updateHeight(r),!a)return;var d=document.createElement("button");d.className="ql-undercut__hide ql-undercut_button",d.innerHTML=a||"",d.style.color=u,d.style.borderBottom="1px "+l+" "+u,d.setAttribute("aria-expanded",!0),d.setAttribute("aria-label",a||t_quillUndercut_translate("hide")),d.setAttribute("aria-controls",i.getAttribute("id")),i.appendChild(d)}else{var c=i.getAttribute("data-show-text"),s=document.createElement("button");s.innerHTML=c||"[+]",s.style.color=u,s.style.borderBottom="1px "+l+" "+u,s.className="ql-undercut__show ql-undercut_button",s.setAttribute("aria-expanded",!1),s.setAttribute("aria-label",c||t_quillUndercut_translate("show")),s.setAttribute("aria-controls",i.getAttribute("id")),i.innerHTML="",i.appendChild(s),t_quillUndercut_addEllipsis(i),t_quillUndercut__updateHeight(r)}}}))}function t_quillUndercut_addStyles(){var t="<style>.ql-undercut {display: inline;}.ql-undercut_button {display: inline;cursor: pointer;background: none;border-top: none;border-left: none;border-right: none;line-height: 1!important;padding: 0;margin: 0;font: inherit;line-height: inherit;text-transform: inherit;letter-spacing: inherit;}</style>",e;document.head&&document.head.insertAdjacentHTML("beforeend",t)}function t_quillUndercut_addEllipsis(t){if(t&&"SPAN"===t.tagName)for(var e=t.previousSibling;e;){for(var n=e.textContent,r=n.length-1;r>=0;r--)if(n[r].trim())return void(e.nodeType===Node.TEXT_NODE||"SPAN"===e.tagName?e.textContent=n.slice(0,r+1)+".."+n.slice(r+1):e.insertAdjacentHTML("beforeend",".."));e=e.previousSibling||e.parentNode.previousSibling}}function t_quillUndercut_removeEllipsis(t){var e;if(t.parentNode){var n=["SPAN","EM","STRONG","S","U","SUP","SUB","A","I","B","Q"],r=t.previousSibling;if(r)for(;(r.nodeType===Node.TEXT_NODE||n.includes(r.tagName))&&/^\s*$/.test(r.textContent)||r.nodeType!==Node.TEXT_NODE&&!n.includes(r.tagName);){if(!r.previousSibling)return;r=r.previousSibling}if(r&&(r.nodeType===Node.TEXT_NODE||n.includes(r.tagName))){var i=r.textContent,u=i.lastIndexOf("..");-1!==u&&(r.textContent=i.slice(0,u)+i.slice(u+2))}}}function t_quillUndercut_unEscapeHtml(t){var e=t.replace(/&lt;/g,"<").replace(/&gt;/g,">");return e=e.replace(/&amp;/g,"&")}function t_quillUndercut_getLang(){var t="",e=document.querySelector("#allrecords");return e&&(t=e.getAttribute("data-tilda-project-lang")),t||(t=(window.navigator.userLanguage||window.navigator.language).slice(0,2)),t?t.toUpperCase():"EN"}function t_quillUndercut_translate(t){var e=t_quillUndercut_getLang(),n={show:{EN:"Expand",RU:"Показать",FR:"Montrer",DE:"Zeigen",ES:"Mostrar",PT:"Mostrar",JA:"見せる",ZH:"展示",UK:"Показати",PL:"Pokazywać",KK:"Көрсету",IT:"Spettacolo",LV:"Rādīt"},hide:{EN:"Collapse",RU:"Скрыть",FR:"Cacher",DE:"Verstecken",ES:"Ocultar",PT:"Ocultar",JA:"隠れる",ZH:"隐藏",UK:"Сховати",PL:"Ukrywać",KK:"Жасыру",IT:"Nascondere",LV:"Slēpt"}};return n[t][e]||n[t].EN}function t_quillUndercut__updateHeight(t){var e=document.getElementById("rec"+t);if(e){e.querySelector(".t-slds")&&t_onFuncLoad("t_slds_UpdateSliderHeight",(function(){setTimeout((function(){return t_slds_UpdateSliderHeight(t)}),0)})),e.querySelector(".t-cover")&&t_onFuncLoad("t_cover__recalcContentHeight",(function(){t_cover__recalcContentHeight(t,!1,0)})),e.querySelector(".t-quiz")&&t_onFuncLoad("t_quiz__adjustStepToHeight",(function(){t_quiz__adjustStepToHeight({rec:e})}));var n=e.getAttribute("data-parenttplid")||e.getAttribute("data-record-type");["1068","1069","1070","1071","1072","822"].includes(n)&&t_onFuncLoad("t"+n+"_init",(function(){window["t"+n+"_init"](t)})),"517"===n&&t_onFuncLoad("t517_unifyHeights",(function(){t517_unifyHeights(t)}))}}window.T_UNDERCUT_ID=0,t_onReady(t_quillUndercut_init);