# --
# HTMLHeadBlockEvents.dtl - provides event blocking code
# Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
# --
# $Id: HTMLHeadBlockEvents.dtl,v 1.5 2012/11/20 15:26:40 mh Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

<script type="text/javascript">//<![CDATA[
"use strict";

var Core = Core || {};
Core.App = Core.App || {};

/**
 * @function
 *      Ignores an event. Implemented without jQuery because no external JavaScript is available yet.
 * @return nothing
 */
function IgnoreEvent (Event) {
    if (Event.preventDefault) {
        Event.preventDefault();
    }
    Event.returnValue = false;
    return false;
}

/**
 * @function
 *      This function blocks all click events on the page until it is
 *      unblocked after all JavaScript was loaded. Implemented without
 *      jQuery because no external JavaScript is available yet.
 * @return nothing
 */
Core.App.BlockEvents = function() {
    if (document.addEventListener) {
        document.addEventListener('click', IgnoreEvent, false);
    }
    else {
        document.attachEvent('onclick', IgnoreEvent);
    }
};

/**
 * @function
 *      This function unblocks all click events on the page
 *      after all JavaScript was loaded. Implemented without
 *      jQuery because no external JavaScript is available yet.
 * @return nothing
 */
Core.App.UnblockEvents = function() {
    if (document.removeEventListener) {
        document.removeEventListener('click', IgnoreEvent, false);
    }
    else {
        document.detachEvent('onclick', IgnoreEvent);
    }
};

// Now block all click events on the page to make sure that
// an agent does not click before all JavaScript was loaded,
// as event listeners are not yet available, for example.
Core.App.BlockEvents();
//]]></script>
