[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/tool/lp/amd/src/ -> competency_plan_navigation.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 click on selecting competency in the competency autocomplete.
  18   *
  19   * @package    tool_lp
  20   * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  define(['jquery'], function($) {
  25  
  26      /**
  27       * CompetencyPlanNavigation
  28       *
  29       * @param {String} competencySelector The selector of the competency element.
  30       * @param {String} baseUrl The base url for the page (no params).
  31       * @param {Number} userId The user id
  32       * @param {Number} competencyId The competency id
  33       * @param {Number} planId The plan id
  34       */
  35      var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {
  36          this._baseUrl = baseUrl;
  37          this._userId = userId + '';
  38          this._competencyId = competencyId + '';
  39          this._planId = planId;
  40          this._ignoreFirstCompetency = true;
  41  
  42          $(competencySelector).on('change', this._competencyChanged.bind(this));
  43      };
  44  
  45      /**
  46       * The competency was changed in the select list.
  47       *
  48       * @method _competencyChanged
  49       * @param {Event} e
  50       */
  51      CompetencyPlanNavigation.prototype._competencyChanged = function(e) {
  52          if (this._ignoreFirstCompetency) {
  53              this._ignoreFirstCompetency = false;
  54              return;
  55          }
  56          var newCompetencyId = $(e.target).val();
  57          var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;
  58          document.location = this._baseUrl + queryStr;
  59      };
  60  
  61      /** @type {Number} The id of the competency. */
  62      CompetencyPlanNavigation.prototype._competencyId = null;
  63      /** @type {Number} The id of the user. */
  64      CompetencyPlanNavigation.prototype._userId = null;
  65      /** @type {Number} The id of the plan. */
  66      CompetencyPlanNavigation.prototype._planId = null;
  67      /** @type {String} Plugin base url. */
  68      CompetencyPlanNavigation.prototype._baseUrl = null;
  69      /** @type {Boolean} Ignore the first change event for competencies. */
  70      CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;
  71  
  72      return /** @alias module:tool_lp/competency_plan_navigation */ CompetencyPlanNavigation;
  73  
  74  });


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