[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/tool/xmldb/actions/edit_key/ -> edit_key.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   * @package    tool_xmldb
  18   * @copyright  2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  19   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  20   */
  21  
  22  // Register the needed events
  23  onload=function() {
  24      // Adjust the form on load
  25      transformForm();
  26  
  27      // Get the required fields
  28      var typeField         = document.getElementById('menutype');
  29  
  30      // Register the rest of events
  31      if (typeField.addEventListener) {
  32          // Standard
  33          typeField.addEventListener('change', transformForm, false);
  34      } else {
  35          // IE 5.5
  36          typeField.attachEvent('onchange', transformForm);
  37      }
  38  }
  39  
  40  /**
  41   * This function controls all modifications to perform when any field changes
  42   */
  43  function transformForm(event) {
  44  
  45      // Initialize all the needed variables
  46      var typeField         = document.getElementById('menutype');
  47      var fieldsField       = document.getElementById('fields');
  48      var reftableField     = document.getElementById('reftable');
  49      var reffieldsField    = document.getElementById('reffields');
  50  
  51      // Initially, enable everything
  52      typeField.disabled = false;
  53      fieldsField.disabled = false;
  54      reftableField.disabled = false;
  55      reffieldsField.disabled = false;
  56  
  57      // Based on type, disable some items
  58      switch (typeField.value) {
  59          case '1':  // XMLDB_KEY_PRIMARY
  60          case '2':  // XMLDB_KEY_UNIQUE
  61              reftableField.disabled = true;
  62              reftableField.value = '';
  63              reffieldsField.disabled = true;
  64              reffieldsField.value = '';
  65              break;
  66          case '3':  // XMLDB_KEY_FOREIGN
  67          case '5':  // XMLDB_KEY_FOREIGN_UNIQUE
  68              break;
  69      }
  70  }


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