[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/yui/src/qbankmanager/js/ -> qbankmanager.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   * Question Bank Management.
  18   *
  19   * @package    question
  20   * @copyright  2014 Andrew Nicols
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  /**
  25   * Questionbank Management.
  26   *
  27   * @module moodle-question-qbankmanager
  28   */
  29  
  30  /**
  31   * Question Bank Management.
  32   *
  33   * @class M.question.qbankmanager
  34   */
  35  
  36  var manager = {
  37      /**
  38       * A reference to the header checkbox.
  39       *
  40       * @property _header
  41       * @type Node
  42       * @private
  43       */
  44      _header: null,
  45  
  46      /**
  47       * The ID of the first checkbox on the page.
  48       *
  49       * @property _firstCheckbox
  50       * @type Node
  51       * @private
  52       */
  53      _firstCheckbox: null,
  54  
  55      /**
  56       * Set up the Question Bank Manager.
  57       *
  58       * @method init
  59       */
  60      init: function() {
  61          // Find the header checkbox, and set the initial values.
  62          this._header = Y.one('#qbheadercheckbox');
  63          if (!this._header) {
  64              return;
  65          }
  66          this._header.setAttrs({
  67              disabled: false,
  68              title: M.util.get_string('selectall', 'moodle')
  69          });
  70  
  71          this._header.on('click', this._headerClick, this);
  72  
  73          // Store the first checkbox details.
  74          var table = this._header.ancestor('table');
  75          this._firstCheckbox = table.one('tbody tr td.checkbox input');
  76      },
  77  
  78      /**
  79       * Handle toggling of the header checkbox.
  80       *
  81       * @method _headerClick
  82       * @private
  83       */
  84      _headerClick: function() {
  85          // Get the list of questions we affect.
  86          var categoryQuestions = Y.one('#categoryquestions')
  87                  .all('[type=checkbox],[type=radio]');
  88  
  89          // We base the state of all of the questions on the state of the first.
  90          if (this._firstCheckbox.get('checked')) {
  91              categoryQuestions.set('checked', false);
  92              this._header.setAttribute('title', M.util.get_string('selectall', 'moodle'));
  93          } else {
  94              categoryQuestions.set('checked', true);
  95              this._header.setAttribute('title', M.util.get_string('deselectall', 'moodle'));
  96          }
  97  
  98          this._header.set('checked', false);
  99      }
 100  };
 101  
 102  M.question = M.question || {};
 103  M.question.qbankmanager = M.question.qbankmanager || manager;


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