$(function () { matriz.common = { "Event": function () { this.data = {}; this.on = function (type, callback) { if (!this.data[type]) { this.data[type] = []; } this.data[type].push(callback); return this; }; this.trigger = function (type, parameters) { if (this.data[type]) { for (var i = 0, len = this.data[type].length; i < len; i++) { this.data[type][i].apply(this, parameters instanceof Array ? parameters:[parameters]); } } return this; }; } }; matriz.common.events = new matriz.common.Event(); });