<commit_before>OpenLayers.Events = Class.create();

OpenLayers.Events.prototype = {
    // Array: supported events
    BROWSER_EVENTS: [
        "mouseover", "mouseout",
        "mousedown", "mouseup", "mousemove", 
        "click", "dblclick",
        "resize", "focus", "blur"
    ],

    // hash of Array(Function): events listener functions
    listeners: null,

    // Object: the code object issuing application events
    object: null,

    // DOMElement: the DOM element receiving browser events
    div: null,

    // Array: list of support application events
    eventTypes: null,

    /**
    * @param {OpenLayers.Map} map
    * @param {DOMElement} div
    */
    initialize: function (object, div, eventTypes) {
        this.listeners  = {};
        this.object     = object;
        this.div        = div;
        this.eventTypes = eventTypes;
        if (eventTypes) {
            for (var i = 0; i < this.eventTypes.length; i++) {
                // create a listener list for every custom application event
                this.listeners[ this.eventTypes[i] ] = [];
            }
        }
        for (var i = 0; i < this.BROWSER_EVENTS.length; i++) {
            var eventType = this.BROWSER_EVENTS[i];

            // every browser event has a corresponding application event 
            // (whether it's listened for or not).
            this.listeners[ eventType ] = [];

            Event.observe(div, eventType, 
                this.handleBrowserEvent.bindAsEventListener(this));
        }
        // disable dragstart in IE so that mousedown/move/up works normally
        Event.observe(div, "dragstart", Event.stop);
    },

    /**
    * @param {str} type
    * @param {Object} obj
    * @param {Function} func
    */
    register: function (type, obj, func) {
        var listeners = this.listeners[type];
        listeners.push( func.bindAsEventListener(obj) );
    },
    
    remove: function(type) {
        this.listeners[type].pop();
    },

    /**
    * @param {event} evt
    */
    handleBrowserEvent: function (evt) {
        evt.xy = this.getMousePosition(evt); 
        this.triggerEvent(evt.type, evt)
    },

    /**
    * @param {event} evt
    * 
    * @return {OpenLayers.Pixel}
    */
    getMousePosition: function (evt) {
        if (!this.div.offsets) {
            this.div.offsets = Position.page(this.div);
        }
        return new OpenLayers.Pixel(
                        evt.clientX - this.div.offsets[0], 
                        evt.clientY - this.div.offsets[1]); 
    },

    /**
    * @param {str} type
    * @param {event} evt
    */
    triggerEvent: function (type, evt) {
        if (evt == null) {
            evt = {};
        }
        evt.object = this.object;

        var listeners = this.listeners[type];
        for (var i = 0; i < listeners.length; i++) {
            var callback = listeners[i];
            callback(evt);
        }
    }
};<commit_msg> r1<EMAIL>:  crschmidt | 2006-06-05 09:56:11 -0400  Small change to events.js to set div on evt so that registered handlers can get ahold of it without using cross-browser stuff.<commit_after>OpenLayers.Events = Class.create();

OpenLayers.Events.prototype = {
    // Array: supported events
    BROWSER_EVENTS: [
        "mouseover", "mouseout",
        "mousedown", "mouseup", "mousemove", 
        "click", "dblclick",
        "resize", "focus", "blur"
    ],

    // hash of Array(Function): events listener functions
    listeners: null,

    // Object: the code object issuing application events
    object: null,

    // DOMElement: the DOM element receiving browser events
    div: null,

    // Array: list of support application events
    eventTypes: null,

    /**
    * @param {OpenLayers.Map} map
    * @param {DOMElement} div
    */
    initialize: function (object, div, eventTypes) {
        this.listeners  = {};
        this.object     = object;
        this.div        = div;
        this.eventTypes = eventTypes;
        if (eventTypes) {
            for (var i = 0; i < this.eventTypes.length; i++) {
                // create a listener list for every custom application event
                this.listeners[ this.eventTypes[i] ] = [];
            }
        }
        for (var i = 0; i < this.BROWSER_EVENTS.length; i++) {
            var eventType = this.BROWSER_EVENTS[i];

            // every browser event has a corresponding application event 
            // (whether it's listened for or not).
            this.listeners[ eventType ] = [];

            Event.observe(div, eventType, 
                this.handleBrowserEvent.bindAsEventListener(this));
        }
        // disable dragstart in IE so that mousedown/move/up works normally
        Event.observe(div, "dragstart", Event.stop);
    },

    /**
    * @param {str} type
    * @param {Object} obj
    * @param {Function} func
    */
    register: function (type, obj, func) {
        var listeners = this.listeners[type];
        listeners.push( func.bindAsEventListener(obj) );
    },
    
    remove: function(type) {
        this.listeners[type].pop();
    },

    /**
    * @param {event} evt
    */
    handleBrowserEvent: function (evt) {
        evt.xy = this.getMousePosition(evt); 
        this.triggerEvent(evt.type, evt)
    },

    /**
    * @param {event} evt
    * 
    * @return {OpenLayers.Pixel}
    */
    getMousePosition: function (evt) {
        if (!this.div.offsets) {
            this.div.offsets = Position.page(this.div);
        }
        return new OpenLayers.Pixel(
                        evt.clientX - this.div.offsets[0], 
                        evt.clientY - this.div.offsets[1]); 
    },

    /**
    * @param {str} type
    * @param {event} evt
    */
    triggerEvent: function (type, evt) {
        if (evt == null) {
            evt = {};
        }
        evt.object = this.object;
        evt.div = this.div;

        var listeners = this.listeners[type];
        for (var i = 0; i < listeners.length; i++) {
            var callback = listeners[i];
            callback(evt);
        }
    }
};
{'fraction_non_alphanumeric': 0.12708367717445124, 'fraction_numerical': 0.004786268361115695, 'mean_word_length': 1.8264925373134329, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3066750', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1790, 'n_words': 451}