Cleanup #10601: Move static dyntabmenu code in external file
authorBenni Mack <benni.mack@typo3.org>
Sat, 7 Mar 2009 13:32:47 +0000 (13:32 +0000)
committerBenni Mack <benni.mack@typo3.org>
Sat, 7 Mar 2009 13:32:47 +0000 (13:32 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5139 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/js/tabmenu.js [new file with mode: 0644]
typo3/template.php

index a7e05ad..0440396 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2009-03-07  Benjamin Mack  <benni@typo3.org>
 
+       * Cleanup #10601: Move static dyntabmenu code in external file
+Description
        * #10565: Speedup / Cleanup t3lib_match_condition - make use of trimExplode
 
 2009-03-07  Ingo Renner  <ingo@typo3.org>
diff --git a/typo3/js/tabmenu.js b/typo3/js/tabmenu.js
new file mode 100644 (file)
index 0000000..787e048
--- /dev/null
@@ -0,0 +1,99 @@
+/***************************************************************
+ *
+ *  javascript functions regarding the "dyntabmenu"
+ *  used throughout the TYPO3 backend
+ *
+ *  Copyright notice
+ *
+ *  (c) 2003-2009      Kasper Skaarhoj
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 t3lib/ library provided by
+ *  Kasper Skaarhoj <kasper@typo3.com> together with TYPO3
+ *
+ *  Released under GNU/GPL (see license file in tslib/)
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *  This copyright notice MUST APPEAR in all copies of this script
+ *
+ ***************************************************************/
+
+var DTM_array = new Array();
+var DTM_origClass = new String();
+
+       // if tabs are used in a popup window the array might not exists
+if(!top.DTM_currentTabs) {
+       top.DTM_currentTabs = new Array();
+}
+
+function DTM_activate(idBase,index,doToogle) {
+               // Hiding all:
+       if (DTM_array[idBase]) {
+               for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
+                       if (DTM_array[idBase][cnt] != idBase+'-'+index) {
+                               document.getElementById(DTM_array[idBase][cnt]+'-DIV').style.display = 'none';
+                               // Only Overriding when Tab not disabled
+                               if (document.getElementById(DTM_array[idBase][cnt]+'-MENU').attributes.getNamedItem('class').nodeValue != 'disabled') {
+                                       document.getElementById(DTM_array[idBase][cnt]+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
+                               }
+                       }
+               }
+       }
+
+               // Showing one:
+       if (document.getElementById(idBase+'-'+index+'-DIV')) {
+               if (doToogle && document.getElementById(idBase+'-'+index+'-DIV').style.display == 'block') {
+                       document.getElementById(idBase+'-'+index+'-DIV').style.display = 'none';
+                       if(DTM_origClass=='') {
+                               document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
+                       } else {
+                               DTM_origClass = 'tab';
+                       }
+                       top.DTM_currentTabs[idBase] = -1;
+               } else {
+                       document.getElementById(idBase+'-'+index+'-DIV').style.display = 'block';
+                       if(DTM_origClass=='') {
+                               document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tabact';
+                       } else {
+                               DTM_origClass = 'tabact';
+                       }
+                       top.DTM_currentTabs[idBase] = index;
+               }
+       }
+}
+function DTM_toggle(idBase,index,isInit) {
+               // Showing one:
+       if (document.getElementById(idBase+'-'+index+'-DIV')) {
+               if (document.getElementById(idBase+'-'+index+'-DIV').style.display == 'block') {
+                       document.getElementById(idBase+'-'+index+'-DIV').style.display = 'none';
+                       if(isInit) {
+                               document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tab';
+                       } else {
+                               DTM_origClass = 'tab';
+                       }
+                       top.DTM_currentTabs[idBase+'-'+index] = 0;
+               } else {
+                       document.getElementById(idBase+'-'+index+'-DIV').style.display = 'block';
+                       if(isInit) {
+                               document.getElementById(idBase+'-'+index+'-MENU').attributes.getNamedItem('class').nodeValue = 'tabact';
+                       } else {
+                               DTM_origClass = 'tabact';
+                       }
+                       top.DTM_currentTabs[idBase+'-'+index] = 1;
+               }
+       }
+}
+
+function DTM_mouseOver(obj) {
+               DTM_origClass = obj.attributes.getNamedItem('class').nodeValue;
+               obj.attributes.getNamedItem('class').nodeValue += '_over';
+}
+
+function DTM_mouseOut(obj) {
+               obj.attributes.getNamedItem('class').nodeValue = DTM_origClass;
+               DTM_origClass = '';
+}
+
index 0775e1a..ad397be 100755 (executable)
@@ -1459,6 +1459,9 @@ $str.=$this->docBodyTagBegin().
         * @return      string          JavaScript section for the HTML header.
         */
        function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1,$dividers2tabs=2)     {
+               // load the static code, if not already done with the function below
+               $this->loadJavascriptLib('js/tabmenu.js');
+
                $content = '';
 
                if (is_array($menuItems))       {
@@ -1598,93 +1601,16 @@ $str.=$this->docBodyTagBegin().
 
        /**
         * Returns dynamic tab menu header JS code.
+        * This is now incorporated automatically when the function template::getDynTabMenu is called
+        * (as long as it is called before $this->startPage())
+        * The return value is not needed anymore
         *
-        * @return      string          JavaScript section for the HTML header.
+        * @return      string          JavaScript section for the HTML header. (return value is deprecated since TYPO3 4.3, will be removed in TYPO3 4.5)
         */
        function getDynTabMenuJScode()  {
-               return '
-                       <script type="text/javascript">
-                       /*<![CDATA[*/
-                               var DTM_array = new Array();
-                               var DTM_origClass = new String();
-
-                                       // if tabs are used in a popup window the array might not exists
-                               if(!top.DTM_currentTabs) {
-                                       top.DTM_currentTabs = new Array();
-                               }
-
-                               function DTM_activate(idBase,index,doToogle)    {       //
-                                               // Hiding all:
-                                       if (DTM_array[idBase])  {
-                                               for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++)    {
-                                                       if (DTM_array[idBase][cnt] != idBase+"-"+index) {
-                                                               document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
-                                                               // Only Overriding when Tab not disabled
-                                                               if (document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue != "disabled") {
-                                                                       document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
-                                                               }
-                                                       }
-                                               }
-                                       }
-
-                                               // Showing one:
-                                       if (document.getElementById(idBase+"-"+index+"-DIV"))   {
-                                               if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")      {
-                                                       document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
-                                                       if(DTM_origClass=="") {
-                                                               document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
-                                                       } else {
-                                                               DTM_origClass = "tab";
-                                                       }
-                                                       top.DTM_currentTabs[idBase] = -1;
-                                               } else {
-                                                       document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
-                                                       if(DTM_origClass=="") {
-                                                               document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
-                                                       } else {
-                                                               DTM_origClass = "tabact";
-                                                       }
-                                                       top.DTM_currentTabs[idBase] = index;
-                                               }
-                                       }
-                               }
-                               function DTM_toggle(idBase,index,isInit)        {       //
-                                               // Showing one:
-                                       if (document.getElementById(idBase+"-"+index+"-DIV"))   {
-                                               if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")  {
-                                                       document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
-                                                       if(isInit) {
-                                                               document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
-                                                       } else {
-                                                               DTM_origClass = "tab";
-                                                       }
-                                                       top.DTM_currentTabs[idBase+"-"+index] = 0;
-                                               } else {
-                                                       document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
-                                                       if(isInit) {
-                                                               document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
-                                                       } else {
-                                                               DTM_origClass = "tabact";
-                                                       }
-                                                       top.DTM_currentTabs[idBase+"-"+index] = 1;
-                                               }
-                                       }
-                               }
-
-                               function DTM_mouseOver(obj) {   //
-                                               DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
-                                               obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
-                               }
-
-                               function DTM_mouseOut(obj) {    //
-                                               obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
-                                               DTM_origClass = "";
-                               }
-
-
-                       /*]]>*/
-                       </script>
-               ';
+               $this->loadJavascriptLib('js/tabmenu.js');
+               // return value deprecated since TYPO3 4.3
+               return '';
        }
 
        /**