message: reduce some duplicated code.
diff: @@ -43,38 +43,7 @@ Eventful.prototype = {
  * @param {Object} context
  */
  one: function (event, query, handler, context) {
  - var _h = this._$handlers;
  -
  - if (typeof query === 'function') {
  - context = handler;
  - handler = query;
  - query = null;
  - }
  -
  - if (!handler || !event) {
  - return this;
  - }
  -
  - query = normalizeQuery(this, query);
  -
  - if (!_h[event]) {
  - _h[event] = [];
  - }
  -
  - for (var i = 0; i < _h[event].length; i++) {
  - if (_h[event][i].h === handler) {
  - return this;
  - }
  - }
  -
  - _h[event].push({
  - h: handler,
  - one: true,
  - query: query,
  - ctx: context || this
  - });
  -
  - return this;
  + return on(this, event, query, handler, context, true);
  },
  /**
  @@ -86,38 +55,7 @@ Eventful.prototype = {
  * @param {Object} [context]
  */
  on: function (event, query, handler, context) {
  - var _h = this._$handlers;
  -
  - if (typeof query === 'function') {
  - context = handler;
  - handler = query;
  - query = null;
  - }
  -
  - if (!handler || !event) {
  - return this;
  - }
  -
  - query = normalizeQuery(this, query);
  -
  - if (!_h[event]) {
  - _h[event] = [];
  - }
  -
  - for (var i = 0; i < _h[event].length; i++) {
  - if (_h[event][i].h === handler) {
  - return this;
  - }
  - }
  -
  - _h[event].push({
  - h: handler,
  - one: false,
  - query: query,
  - ctx: context || this
  - });
  -
  - return this;
  + return on(this, event, query, handler, context, false);
  },
  /**
  @@ -301,6 +239,41 @@ function normalizeQuery(host, query) {
  return query;
  }
  +function on(eventful, event, query, handler, context, isOnce) {
  + var _h = eventful._$handlers;
  +
  + if (typeof query === 'function') {
  + context = handler;
  + handler = query;
  + query = null;
  + }
  +
  + if (!handler || !event) {
  + return eventful;
  + }
  +
  + query = normalizeQuery(eventful, query);
  +
  + if (!_h[event]) {
  + _h[event] = [];
  + }
  +
  + for (var i = 0; i < _h[event].length; i++) {
  + if (_h[event][i].h === handler) {
  + return eventful;
  + }
  + }
  +
  + _h[event].push({
  + h: handler,
  + one: isOnce,
  + query: query,
  + ctx: context || eventful
  + });
  +
  + return eventful;
  +}
  +
  // ----------------------
  // The events in zrender
  // ----------------------
  