HEX
Server: Apache
System: Linux webd006.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: zwafgyp (177615)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/zwafgyp/lacalita/wp-content/plugins/chaty-pro/src/components/rule-button.js
const $ = window.jQuery;
export default function ruleButtonPosition() {
 
    // handle button postion when new rule is added
    function addRuleHandler({ $scope, $current }) {
        const $button   = $scope.find('.rule-btns');
        const $children = $scope.find('.chaty-data-and-time-rules').children();
        $button.css({
            marginTop: $children && $children.length === 1 ? '20px' : '0px'
        });
        $current.append( $button );
    }

    // handle button position when rule is removed
    function removeRuleHandler( $scope, type = 'single' ) {
        const $button = $scope.find('.rule-btns');

        if( type === 'single' ) {
            if( $scope.parent().children().length === 2 ) {
                $scope.parent().find('.rule-btns').css({marginTop: '20px'})
            }
    
            if( $button && $scope.prev().length === 1 ) {
                $scope.prev().append($button)
            }
        }

        if( $button && $scope.prev().length === 0 || type === 'all' ) {
            $button.css({marginTop: '0'})
            $scope.parents('.chaty-option-box').append($button);
            $scope.parents('.chaty-option-box').removeClass('show-remove-rules-btn');
        }

    }

    wp.hooks.addAction( 'chaty.days_and_hours_remove_rule', 'removeRuleHandler', removeRuleHandler );
    wp.hooks.addAction( 'chaty.days_and_hours_add_rule', 'addRuleHandler', addRuleHandler )

}