3cx 更改气泡按钮样式 - 向上移动异步按钮并设置其样式等待创建异步 dom

问题描述 投票:0回答:1

两天以来,我一直在努力解决聊天气泡覆盖我的主题底部登录/退出网络应用栏的问题:

尝试:

  1. 在Wordpress中修改子style.css和functions.php

主题风格不适用 在 style.css 中修改了

button jquery-selectors chat shadow-dom 3cx
1个回答
0
投票

    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)`);

          const childResults = childShadows.map(child => querySelectorAllShadows(selector, child));
          
          // 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'});
                    }
                }
                
            }, 3000);  // 3 secondi di ritardo
        });
    </script>
    <?php
}
    add_action('wp_head', 'add_custom_js', 100);
© www.soinside.com 2019 - 2024. All rights reserved.