4269699a42980d5dc77fb636c874fde4af0056db
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / tabmenu.js
1 /**
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * javascript functions regarding the "dyntabmenu" used throughout the TYPO3 backend
16 */
17
18 var DTM_array = DTM_array || [];
19
20 // if tabs are used in a popup window the array might not exists
21 if (!top.DTM_currentTabs) {
22 top.DTM_currentTabs = [];
23 }
24
25 function DTM_activate(idBase,index,doToogle) {
26 // Hiding all:
27 if (DTM_array[idBase]) {
28 for(var cnt = 0; cnt < DTM_array[idBase].length; cnt++) {
29 if (DTM_array[idBase][cnt] !== idBase + '-' + index) {
30 document.getElementById(DTM_array[idBase][cnt]+'-DIV').style.display = 'none';
31 // Only Overriding when Tab not disabled
32 if (document.getElementById(DTM_array[idBase][cnt]+'-MENU').attributes.getNamedItem('class').nodeValue !== 'disabled') {
33 document.getElementById(DTM_array[idBase][cnt]+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
34 }
35 }
36 }
37 }
38
39 // Showing one:
40 if (document.getElementById(idBase+'-'+index+'-DIV')) {
41 if (doToogle && document.getElementById(idBase+'-'+index+'-DIV').style.display === 'block') {
42 document.getElementById(idBase+'-'+index+'-DIV').style.display = 'none';
43 document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
44 top.DTM_currentTabs[idBase] = -1;
45 } else {
46 document.getElementById(idBase+'-'+index+'-DIV').style.display = 'block';
47 document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'active';
48 top.DTM_currentTabs[idBase] = index;
49 }
50 }
51 document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'active';
52 }
53 function DTM_toggle(idBase,index,isInit) {
54 // Showing one:
55 if (document.getElementById(idBase+'-'+index+'-DIV')) {
56 if (document.getElementById(idBase+'-'+index+'-DIV').style.display === 'block') {
57 document.getElementById(idBase+'-'+index+'-DIV').style.display = 'none';
58 if (isInit) {
59 document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
60 }
61 top.DTM_currentTabs[idBase+'-'+index] = 0;
62 } else {
63 document.getElementById(idBase+'-'+index+'-DIV').style.display = 'block';
64 if (isInit) {
65 document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'active';
66 }
67 top.DTM_currentTabs[idBase+'-'+index] = 1;
68 }
69 }
70 }