﻿var JsBase = new function () {

    // properties
    var _this = this;
    this.Controls;

    // events
    _this.Init = function () {

        _this.Controls = new Object();
        delete this.Init;

    }

    this.BindKeyPress = function (target, keycode, callback) {
        $(target).keypress(function (event) {
            var eventKeycode = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
            if (eventKeycode == keycode) {
                callback();
            }
        });
    }

    this.BindClick = function (target, callback) {
        $(target).click(function (event) {
            callback();
        });
    }

    this.KeyCodes = {
        BACKSPACE: 8,
        CAPS_LOCK: 20,
        COMMA: 188,
        CONTROL: 17,
        DELETE: 46,
        DOWN: 40,
        END: 35,
        ENTER: 13,
        ESCAPE: 27,
        HOME: 36,
        INSERT: 45,
        LEFT: 37,
        NUMPAD_ADD: 107,
        NUMPAD_DECIMAL: 110,
        NUMPAD_DIVIDE: 111,
        NUMPAD_ENTER: 108,
        NUMPAD_MULTIPLY: 106,
        NUMPAD_SUBTRACT: 109,
        PAGE_DOWN: 34,
        PAGE_UP: 33,
        PERIOD: 190,
        RIGHT: 39,
        SHIFT: 16,
        SPACE: 32,
        TAB: 9,
        UP: 38
    }

    this.Init();

}
