odoo.define('web.list_common', function (require) { "use strict"; var core = require('web.core'); var _t = core._t; var Class = core.Class; /** * @mixin Events */ var Events = /** @lends Events# */{ /** * @param {String} event event to listen to on the current object, null for all events * @param {Function} handler event handler to bind to the relevant event * @returns this */ bind: function (event, handler) { var calls = this['_callbacks'] || (this._callbacks = {}); if (event in calls) { calls[event].push(handler); } else { calls[event] = [handler]; } return this; }, /** * @param {String} event event to unbind on the current object * @param {function} [handler] specific event handler to remove (otherwise unbind all handlers for the event) * @returns this */ unbind: function (event, handler) { var calls = this._callbacks || {}; if (!(event in calls)) { return this; } if (!handler) { delete calls[event]; } else { var handlers = calls[event]; handlers.splice( _(handlers).indexOf(handler), 1); } return this; }, /** * @param {String} event * @returns this */ trigger: function (event) { var calls; if (!(calls = this._callbacks)) { return this; } var callbacks = (calls[event] || []).concat(calls[null] || []); for(var i=0, length=callbacks.length; i