template::register_double_click_handler (private)

 template::register_double_click_handler

Defined in packages/acs-templating/tcl/head-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 template::get_body_event_handlers template::get_body_event_handlers (public) template::register_double_click_handler template::register_double_click_handler template::get_body_event_handlers->template::register_double_click_handler parameter::get_from_package_key parameter::get_from_package_key (public) template::register_double_click_handler->parameter::get_from_package_key template::add_body_script template::add_body_script (public) template::register_double_click_handler->template::add_body_script

Testcases:
No testcase defined.
Source code:
    set default_timeout [parameter::get_from_package_key  -package_key acs-templating  -parameter DefaultPreventDoubleClickTimeoutMs  -default 2000]
    if {$default_timeout == 0} {
        return
    }
    template::add_body_script -script [subst -nobackslashes -nocommands [ns_trim {
        function oacs_reenable_double_click_handler(target) {
            if ( target.dataset.oacsClicked == 'true') {
                target.dataset.oacsClicked = false;
                target.disabled = false;
                target.classList.remove("disabled");
                console.log("re-enable click handler");
            }
        };
        for (e of document.getElementsByClassName('prevent-double-click')) {
            if (!e.dataset.oacsDoubleClickHandlerRegistered) {
                e.addEventListener('click', function(event) {
                    let target = event.target || event.srcElement;
                    if ( target.dataset.oacsClicked == 'true') {
                        event.stopPropagation();
                        event.preventDefault();
                        console.log("blocked double-click");
                        return false;
                    } else {
                        setTimeout(function () {
                            target.disabled = true;
                            target.dataset.oacsClicked = true;
                            target.classList.add("disabled");
                        });
                        const timeout = target.dataset.oacsTimeout || $default_timeout;
                        setTimeout(oacs_reenable_double_click_handler, timeout, target);
                        return true;
                    }
                }, true);
                // In case the page has changed before the button was re-enabled
                // and the user uses the brower's back button, we have to establish
                // a clickable state.
                e.addEventListener('focus', function(event) {
                    oacs_reenable_double_click_handler(event.target || event.srcElement);
                });
                e.dataset.oacsDoubleClickHandlerRegistered = true;
            }
        };
    }]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: