3cx change bubble button style in Wordpress functions.php - move up an async button and styling it after waiting fetch for async dom created(3cx更改WordPress函数中的气泡按钮样式。php-上移一个异步按钮,并在等待获取创建的异步DOM后对其进行样式设置)
转载作者:bug小助手更新时间:2023-10-25 17:17:44244
I have been struggling with the moving up of the chat bubble overriding my theme bottom login/out web app bar for 2 days:
我一直在努力向上移动的聊天气泡覆盖我的主题底部登录/退出Web应用程序栏2天:
Tryed to:
尝试:
modify in Wordpress the child style.css and the functions.php
The style of the theme was not applying in style.css modified the <button id="wplc-chat-button"
样式中未应用主题样式。css修改了
`/* Theme Name: Alukas child Theme URI: Description: Tema child di Alukas Author: admin Author URI: https://monbi.it Template: alukas Version: 1.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html
/* == Add your own styles below this line == --------------------------------------------*/ #wplc-chat-button {bottom: 100px!important} `
using jquery to add css to the chat bubble after manually applying the bottom:70px!important to Chrome
using jquery to add css to the chat bubble parent div
using jquery to add css to the chat bubble grandparent div
更多回答
Welcome to StackOverflow, hope you will find new knowledge here. You can help us answering your question, by adding a minimal-reproducible-example StackOverflow Snippet. It will help readers execute your code with one click. And help create answers with one click. Thank you.
function add_custom_js() { ?> <script type="text/javascript">
function querySelectorAllShadows(selector, el = document.body) { // recurse on childShadows
/** * Finds all elements in the entire page matching `selector`, even if they are in shadowRoots. * Just like `querySelectorAll`, but automatically expand on all child `shadowRoot` elements. * @see https://stackoverflow.com/a/71692555/2228771 */ const childShadows = Array.from(el.querySelectorAll('*')). map(el => el.shadowRoot).filter(Boolean);
// console.log('[querySelectorAllShadows]', selector, el, `(${childShadows.length} shadowRoots)`);
// fuse all results into singular, flat array const result = Array.from(el.querySelectorAll(selector)); return result.concat(childResults).flat(); }
jQuery(document).ready(function(){ setTimeout(function() { // sposta la bubble chat
// Sposta il div #callus-container var allMatches = querySelectorAllShadows('#wp-live-chat-by-3CX'); if(allMatches && allMatches.length > 0){ var callusContainer = jQuery(allMatches[0]); // Prendi il primo match if(window.innerWidth <= 430) { callusContainer.css({'position':'fixed','bottom':'105px','right':'5px'}); } }
the main struggle have been to deal with async creation of the button solved with a js delay of 3 sec. and that the jQuery querySelectorAll function that it is not working inside the shadow-dom created
Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, can you edit your answer to include an explanation of what you're doing and why you believe it is the best approach?
我是一名优秀的程序员,十分优秀!