Auftrags-Controller: Preisquellen in oberer Eingabezeile besser berücksichtigen
[kivitendo-erp.git] / js / dhtmlsuite / menu-for-applications.js
index 7896f91..bf23469 100644 (file)
@@ -242,6 +242,7 @@ DHTMLSuite.common.prototype = {
        getTopPos : function(inputObj)\r
        {               \r
          var returnValue = inputObj.offsetTop;\r
+      if (returnValue > 700) returnValue = 0;\r
          while((inputObj = inputObj.offsetParent) != null){\r
                if(inputObj.tagName!='HTML'){\r
                        returnValue += (inputObj.offsetTop - inputObj.scrollTop);\r
@@ -1137,7 +1138,7 @@ DHTMLSuite.menuItem = function()
        var cssPrefix;                                                  // Css prefix for the menu items.\r
        var modelItemRef;                                               // Reference to menuModelItem\r
 \r
-       this.layoutCSS = 'menu-item.css';\r
+//     this.layoutCSS = 'menu-item.css';\r
        this.cssPrefix = 'DHTMLSuite_';\r
        \r
        if(!standardObjectsCreated)DHTMLSuite.createStandardObjects();  \r
@@ -1159,7 +1160,7 @@ DHTMLSuite.menuItem.prototype =
        */\r
        createItem : function(menuModelItemObj)\r
        {\r
-               DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   // Load css\r
+//             DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   // Load css\r
                \r
                DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[this.objectIndex] = this;\r
                        \r
@@ -1187,7 +1188,7 @@ DHTMLSuite.menuItem.prototype =
                }else{          \r
                        /* Add events */\r
                        var tmpVar = this.objectIndex/1;\r
-                       this.divElement.onclick = function(e) { DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[tmpVar].__navigate(e); }\r
+                       //this.divElement.onclick = function(e) { DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[tmpVar].__navigate(e); }\r
                        this.divElement.onmousedown = this.__clickMenuItem;                     // on mouse down effect\r
                        this.divElement.onmouseup = this.__rolloverMenuItem;            // on mouse up effect\r
                        this.divElement.onmouseover = this.__rolloverMenuItem;          // mouse over effect\r
@@ -1264,7 +1265,17 @@ DHTMLSuite.menuItem.prototype =
                        parentEl.style.backgroundPosition = 'left center';      \r
                }\r
                if(this.modelItemRef.itemText){\r
-                       var div = document.createElement('DIV');\r
+                 var div;\r
+                 if( this.modelItemRef.url )\r
+                 {\r
+                         div = document.createElement('a');\r
+                         div.href = this.modelItemRef.url;\r
+                         div.target = this.modelItemRef.frameTarget;\r
+                         div.style.display = 'block';\r
+                       }\r
+                       else\r
+                         div = document.createElement('div');\r
+                         \r
                        div.className = 'DHTMLSuite_textContent';\r
                        div.innerHTML = this.modelItemRef.itemText;     \r
                        div.className = this.cssPrefix + 'menuItem_textContent';\r
@@ -1583,7 +1594,7 @@ DHTMLSuite.menuBar = function()
        var globalObjectIndex;                  // Global index of this object - used to refer to the object of this class outside\r
        this.cssPrefix = 'DHTMLSuite_';\r
        this.menuItemLayoutCss = false; // false = use default for the menuItem class.\r
-       this.layoutCSS = 'menu-bar.css';\r
+//     this.layoutCSS = 'menu-bar.css';\r
        this.menuBarBackgroundImage = 'menu_strip_bg.jpg';\r
        this.menuItem_objects = new Array();\r
        DHTMLSuite.variableStorage.menuBar_highlightedItems = new Array();\r
@@ -1597,7 +1608,7 @@ DHTMLSuite.menuBar = function()
        this.targetId = false;\r
        this.activeSubItemsOnMouseOver = false;\r
        this.menuItemCssPrefix = false;\r
-       this.createIframesForOldIeBrowsers = true;\r
+       this.createIframesForOldIeBrowsers = false;\r
        if(!standardObjectsCreated)DHTMLSuite.createStandardObjects();  \r
        \r
        \r
@@ -1619,7 +1630,7 @@ DHTMLSuite.menuBar.prototype = {
        init : function()\r
        {\r
                \r
-               DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   \r
+//             DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   \r
                this.__createDivs();    // Create general divs\r
                this.__createMenuItems();       // Create menu items\r
                this.__setBasicEvents();        // Set basic events.\r
@@ -2221,12 +2232,27 @@ DHTMLSuite.menuBar.prototype = {
                try{\r
                        var shortRef = this.submenuGroups[parentId];    \r
                        \r
+                       if( shortRef.style.visible == 'hidden' )\r
+                 {\r
+                         shortRef.style.display = 'none';\r
+                         return;\r
+                 }\r
+                       else\r
+                         shortRef.style.display = 'block';\r
+                       \r
                        var depth = this.menuItems[parentId].depth;\r
                        var dir = this.menuItemObj.submenuType[depth];\r
                        if(dir=='top'){                 \r
                                shortRef.style.left = DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) + 'px';\r
                                shortRef.style.top = (DHTMLSuite.commonObj.getTopPos(this.menuItem_objects[parentId].divElement) + this.menuItem_objects[parentId].divElement.offsetHeight) + 'px';\r
                        }else{\r
+              var too_large = DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement)\r
+                            + this.menuItem_objects[parentId].divElement.offsetWidth\r
+                            + shortRef.offsetWidth\r
+                            > $('#main_menu_div').width();\r
+              if (too_large)\r
+                shortRef.style.left = (DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) - shortRef.offsetWidth) + 'px';\r
+              else\r
                                shortRef.style.left = (DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) + this.menuItem_objects[parentId].divElement.offsetWidth) + 'px';\r
                                shortRef.style.top = (DHTMLSuite.commonObj.getTopPos(this.menuItem_objects[parentId].divElement)) + 'px';               \r
                        }       \r
@@ -2336,6 +2362,14 @@ DHTMLSuite.menuBar.prototype = {
        // }}}  \r
        ,\r
     unsetMenuBarState : function() { this.menuBarState = false },\r
+    changeMenuBarState: function (target) {\r
+          var parentId = target.id.replace(/[^0-9]/gi,'');\r
+          this.menuBarState = !this.menuBarState;\r
+       this.hideSubMenus();\r
+          if(this.menuBarState) {\r
+               this.__expandGroup(parentId);\r
+       }\r
+    },\r
        // {{{ __setBasicEvents()\r
     /**\r
      * Set basic events for the menu widget.\r
@@ -2345,15 +2379,16 @@ DHTMLSuite.menuBar.prototype = {
      */        \r
        __setBasicEvents : function()\r
        {\r
-               DHTMLSuite.commonObj.addEvent(document.documentElement,"click",this.hideSubMenus);              \r
         var menu = this;\r
-        $(document).mousedown(function(){ menu.unsetMenuBarState(); });\r
-        $('#win1').load(function(){\r
-            $('#win1').contents().mousedown(function(){\r
-                menu.hideSubMenus();\r
-                menu.menuBarState = false;\r
-            });\r
-        })\r
+        $('div.DHTMLSuite_menuBar_sub').click(function() { menu.hideSubMenus(); menu.unsetMenuBarState() });\r
+        $('div.DHTMLSuite_menuBar_top > div > div[objectref!="0"]').click(function() { menu.changeMenuBarState(this) });\r
+        $('div.DHTMLSuite_menuBar_top').click(function(e) {\r
+          if ($(e.target).attr('class') == 'DHTMLSuite_menuBar_top') { menu.hideSubMenus(); menu.unsetMenuBarState() }\r
+        });\r
+        $('#content').mousedown(function(){\r
+            menu.hideSubMenus();\r
+            menu.menuBarState = false;\r
+        });\r
        }\r
 }\r
 \r