[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/tool/lp/amd/src/ -> event_base.js (source)

   1  // This file is part of Moodle - http://moodle.org/
   2  //
   3  // Moodle is free software: you can redistribute it and/or modify
   4  // it under the terms of the GNU General Public License as published by
   5  // the Free Software Foundation, either version 3 of the License, or
   6  // (at your option) any later version.
   7  //
   8  // Moodle is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  //
  13  // You should have received a copy of the GNU General Public License
  14  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  15  
  16  /**
  17   * Event base javascript module.
  18   *
  19   * @module     tool_lp/event_base
  20   * @package    tool_lp
  21   * @copyright  2015 Frédéric Massart - FMCorz.net
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  define(['jquery'], function($) {
  25  
  26      /**
  27       * Base class.
  28       */
  29      var Base = function() {
  30          this._eventNode = $('<div></div>');
  31      };
  32  
  33      /** @type {Node} The node we attach the events to. */
  34      Base.prototype._eventNode = null;
  35  
  36      /**
  37       * Register an event listener.
  38       *
  39       * @param {String} type The event type.
  40       * @param {Function} handler The event listener.
  41       * @method on
  42       */
  43      Base.prototype.on = function(type, handler) {
  44          this._eventNode.on(type, handler);
  45      };
  46  
  47      /**
  48       * Trigger an event.
  49       *
  50       * @param {String} type The type of event.
  51       * @param {Object} data The data to pass to the listeners.
  52       * @method _trigger
  53       */
  54      Base.prototype._trigger = function(type, data) {
  55          this._eventNode.trigger(type, [data]);
  56      };
  57  
  58      return /** @alias module:tool_lp/event_base */ Base;
  59  });


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1