<commit_before>/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */

/**
 * Copyright (c) 2011 National Land Survey of Finland.
 */

OpenLayers.Control.PorttiKeyboard = OpenLayers.Class(OpenLayers.Control, {
    autoActivate : true,
    slideFactor : 50, // 75
    core : null,
    setup : function(mapmodule) {
        //this.core = config.core;
        this.mapmodule = mapmodule;
        this.sandbox = mapmodule.getSandbox();
    },
    initialize : function() {
        OpenLayers.Control.prototype.initialize.apply(this, arguments);    
    },    
    draw : function() {
        this.handler = new OpenLayers.Handler.Keyboard(this, {
            "keydown" : this.defaultKeyDown,
            "keyup" : this.defaultKeyUp
        });
    },
    defaultKeyDown : function(evt) {
        switch(evt.keyCode) {
            case OpenLayers.Event.KEY_LEFT:
            	this.mapmodule.panMapByPixels(-this.slideFactor,0, false, true);
                break;
            case OpenLayers.Event.KEY_RIGHT:
            	this.mapmodule.panMapByPixels(this.slideFactor,0, false, true);
                break;
            case OpenLayers.Event.KEY_UP:
            	this.mapmodule.panMapByPixels(0, -this.slideFactor, false, true);
                break;
            case OpenLayers.Event.KEY_DOWN:
            	this.mapmodule.panMapByPixels(0, this.slideFactor, false, true);
                break;
            case 17:
                // CTRL
                this.sandbox.postRequestByName('CtrlKeyDownRequest');
                //this.core.processRequest(this.core.getRequestBuilder()());
                break;
            case 27:
                // ESC
                this.sandbox.postRequestByName('EscPressedEvent');
                //this.core.dispatch(this.core.getEventBuilder('EscPressedEvent')());
                break;
            case 33:
                // Page Up. Same in all browsers.
            	this.mapmodule.notifyStartMove();
                this.mapmodule.panMapNorth();<commit_msg>[AH-140] Allaround fix for overeager keyhandlinh<commit_after>/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */

/**
 * Copyright (c) 2011 National Land Survey of Finland.
 */

OpenLayers.Control.PorttiKeyboard = OpenLayers.Class(OpenLayers.Control, {
    autoActivate : true,
    slideFactor : 50, // 75
    core : null,
    setup : function(mapmodule) {
        //this.core = config.core;
        this.mapmodule = mapmodule;
        this.sandbox = mapmodule.getSandbox();
    },
    initialize : function() {
        OpenLayers.Control.prototype.initialize.apply(this, arguments);    
    },    
    draw : function() {
        this.handler = new OpenLayers.Handler.Keyboard(this, {
            "keydown" : this.defaultKeyDown,
            "keyup" : this.defaultKeyUp
        });
    },
    defaultKeyDown : function(evt) {
        if(jQuery('input:focus').length > 0) {
            // cancel all handling if there are inputs with focus
            // (user might be writing something)
            return;
        }
        switch(evt.keyCode) {
            case OpenLayers.Event.KEY_LEFT:
            	this.mapmodule.panMapByPixels(-this.slideFactor,0, false, true);
                break;
            case OpenLayers.Event.KEY_RIGHT:
            	this.mapmodule.panMapByPixels(this.slideFactor,0, false, true);
                break;
            case OpenLayers.Event.KEY_UP:
            	this.mapmodule.panMapByPixels(0, -this.slideFactor, false, true);
                break;
            case OpenLayers.Event.KEY_DOWN:
            	this.mapmodule.panMapByPixels(0, this.slideFactor, false, true);
                break;
            case 17:
                // CTRL
                this.sandbox.postRequestByName('CtrlKeyDownRequest');
                //this.core.processRequest(this.core.getRequestBuilder()());
                break;
            case 27:
                // ESC
                this.sandbox.postRequestByName('EscPressedEvent');
                //this.core.dispatch(this.core.getEventBuilder('EscPressedEvent')());
                break;
            case 33:
                // Page Up. Same in all browsers.
            	this.mapmodule.notifyStartMove();
                this.mapmodule.panMapNorth();
{'fraction_non_alphanumeric': 0.10865322055953155, 'fraction_numerical': 0.012144870960746042, 'mean_word_length': 1.9116161616161615, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3753190', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1280, 'n_words': 257}