Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / xmldb / actions / edit_key / edit_key.js
blobeb3dd67377c509df0b8cf7ec496e8205e732e413
1 /// $Id $
3 ///////////////////////////////////////////////////////////////////////////
4 //                                                                       //
5 // NOTICE OF COPYRIGHT                                                   //
6 //                                                                       //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
8 //          http://moodle.com                                            //
9 //                                                                       //
10 // Copyright (C) 2001-3001 Martin Dougiamas        http://dougiamas.com  //
11 //           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
12 //                                                                       //
13 // This program is free software; you can redistribute it and/or modify  //
14 // it under the terms of the GNU General Public License as published by  //
15 // the Free Software Foundation; either version 2 of the License, or     //
16 // (at your option) any later version.                                   //
17 //                                                                       //
18 // This program is distributed in the hope that it will be useful,       //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
21 // GNU General Public License for more details:                          //
22 //                                                                       //
23 //          http://www.gnu.org/copyleft/gpl.html                         //
24 //                                                                       //
25 ///////////////////////////////////////////////////////////////////////////
28 /// Register the needed events
30     onload=function() {
31     /// Adjust the form on load
32         transformForm();
34     /// Get the required fields
35         var typeField         = document.getElementById('menutype');
37     /// Register the rest of events
38         if (typeField.addEventListener) {
39         /// Standard
40             typeField.addEventListener('change', transformForm, false);
41         } else {
42         /// IE 5.5
43             typeField.attachEvent('onchange', transformForm);
44         }
45     }
47 /**
48  * This function controls all modifications to perform when any field changes
49  */
50 function transformForm(event) {
52 /// Initialize all the needed variables
53     var typeField         = document.getElementById('menutype');
54     var fieldsField       = document.getElementById('fields');
55     var reftableField     = document.getElementById('reftable');
56     var reffieldsField    = document.getElementById('reffields');
58 /// Initially, enable everything
59     typeField.disabled = false;
60     fieldsField.disabled = false;
61     reftableField.disabled = false;
62     reffieldsField.disabled = false;
64 /// Based on type, disable some items
65     switch (typeField.value) {
66         case '1':  // XMLDB_KEY_PRIMARY
67         case '2':  // XMLDB_KEY_UNIQUE
68             reftableField.disabled = true;
69             reftableField.value = '';
70             reffieldsField.disabled = true;
71             reffieldsField.value = '';
72             break;
73         case '3':  // XMLDB_KEY_FOREIGN
74         case '5':  // XMLDB_KEY_FOREIGN_UNIQUE
75             break;
76     }