HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/admin/assets/js/modal.js
/**
 * AutomateWoo Modal
 */
jQuery(function($) {

    AutomateWoo.Modal = {

        init: function(){

            $(document.body).on( 'click', '.js-close-automatewoo-modal', this.close );
            $(document.body).on( 'click', '.automatewoo-modal-overlay', this.close );
            $(document.body).on( 'click', '.js-open-automatewoo-modal', this.handle_link );

            $(document).on( 'keydown', function(e) {
                if ( e.keyCode === 27 ) {
                    AutomateWoo.Modal.close();
                }
            });

        },


        handle_link: function(e){
            e.preventDefault();

            var $a = $(this);
            var type = $a.data( 'automatewoo-modal-type' );
            var size = $a.data( 'automatewoo-modal-size' );

            if ( type === 'ajax' ) {
                AutomateWoo.Modal.open( type, size );
                AutomateWoo.Modal.loading();

                $.post( $a.attr('href'), {}, function( response ){
                    AutomateWoo.Modal.contents( response );
                });
            }
            else if ( type === 'inline' ) {
                var contents = $( $a.data( 'automatewoo-modal-contents' ) ).html();
                AutomateWoo.Modal.open( type, size );
                AutomateWoo.Modal.contents( contents );
            }
        },


        open: function( type, size ) {

            var classes = [ 'automatewoo-modal--type-' + type ];

            if ( size ) {
                classes.push( 'automatewoo-modal--size-' + size );
            }

            $(document.body).addClass('automatewoo-modal-open').append('<div class="automatewoo-modal-overlay"></div>');
            $(document.body).append('<div class="automatewoo-modal ' + classes + '"><div class="automatewoo-modal__contents"><div class="automatewoo-modal__header"></div></div><div class="automatewoo-icon-close js-close-automatewoo-modal"></div></div>');
            this.position();
        },


        loading: function() {
            $(document.body).addClass('automatewoo-modal-loading');
        },


        contents: function ( contents ) {
            $(document.body).removeClass('automatewoo-modal-loading');
            $('.automatewoo-modal__contents').html(contents);

            AW.initTooltips();

            this.position();
        },

        /**
         * Closes modal, by changin classes on `document.body` and removing modal content and overlay elements.
         * @fires awmodal-close on the `document.body`.
         */
        close: function() {
            $(document.body).removeClass('automatewoo-modal-open automatewoo-modal-loading');
            $('.automatewoo-modal, .automatewoo-modal-overlay').remove();

            // Fallback to Event in the browser does not support CustomEvent, like IE.
            const eventCtor = typeof CustomEvent === 'undefined' ? Event : CustomEvent;
            document.body.dispatchEvent( new eventCtor( 'awmodal-close' ) );
        },


        position: function() {

            var $modal = $('.automatewoo-modal');
            var $modal_body = $('.automatewoo-modal__body');
            var $modal_header = $('.automatewoo-modal__header');

            $modal_body.removeProp('style');

            var modal_header_height = $modal_header.outerHeight();
            var modal_height = $modal.height();
            var modal_width = $modal.width();
            var modal_body_height = $modal_body.outerHeight();
            var modal_contents_height = modal_body_height + modal_header_height;

            $modal.css({
                'margin-left': -modal_width / 2,
                'margin-top': -modal_height / 2
            });

            if ( modal_height < modal_contents_height - 5 ) {
                $modal_body.height( modal_height - modal_header_height );
            }
        }

    };


    AutomateWoo.Modal.init();

});

var throttle = null;

jQuery(window).on( 'resize', function(){
    clearTimeout(throttle);
    throttle = setTimeout(function(){
        AutomateWoo.Modal.position();
    }, 50);
});