vgui/obj/60-bind.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Convenience methods to work with binds
*/
var bind = exports.bind = function () {
function bind() {
_classCallCheck(this, bind);
}
_createClass(bind, null, [{
key: "register",
/**
* Registers a new bind
* @param {!string} name - The name of the bind
* @param {!string} type - The type of the bind
* @param {!Function} callback - The callback function to use
*/
value: function register(name, type, callback) {
if (!name) throw new Error("Name argument not set");
if (!type) throw new Error("Type argument not set");
if (!callback) throw new Error("Callback argument not set");
document.addEventListener("BindEvent", function (e) {
if (e.key != name) return;
callback(e.value);
});
document.registerBind(name, type);
}
}]);
return bind;
}();