Files
votianng/html/lib/project/js/menu.js.php
2026-03-29 10:34:57 +02:00

562 lines
18 KiB
PHP

// **************
// * Navigation *
// **************
// *** Core menu code (BEGIN) **********************************************
// Shows a container
function myshow(elem_id) {
if (elem_id != undefined && elem_id != '') {
elem_id = '#' + elem_id;
$(elem_id).show();
};
}
// Hides a container
function myhide(elem_id) {
if (elem_id != undefined && elem_id != '') {
elem_id = '#' + elem_id;
$(elem_id).hide();
};
}
// Hides or shows the menu by clicking the page title container
function activateMenusByPageTitle() {
if (menuActiveByPageTitel) {
menuActiveByPageTitel = false;
$('#menu').hide();
$('#menu_reduced').hide();
} else {
menuActiveByPageTitel = true;
$('#menu').show();
}
}
// Switch activation status of the menu
function activateMenu(activateId, deactivateId) {
activateId = '#' + activateId;
deactivateId = '#' + deactivateId;
// if (deactivateId != '' && document.getElementById(deactivateId)) {
if (deactivateId != '' && $(deactivateId)) {
$(deactivateId).hide();
};
// if (activateId != '' && document.getElementById(activateId)) {
if (activateId != '' && $(activateId)) {
$(activateId).show();
};
}
// Call for loading one image
function changeContent(objectName,mode,navLevel) {
if (navLevel == "") {navLevel = 0};
navLevel = parseInt(navLevel);
objName = '#' + objectName;
useCascade = true;
if (navLevel < 0) {
useCascade = false;
navLevel = 0;
};
tmpIndex = 0; // "off"
if (mode == "over") {tmpIndex = 1;};
if (mode == "active") {tmpIndex = 2;};
if (mode == "deactive") {tmpIndex = 0;};
if (objectName != activeElement[navLevel] || mode == "active" || mode == "deactive") {
$(objName).css('background', 'url(' + navBgImg[navLevel][tmpIndex] + ')');
};
if (useCascade) {
if (objectName != activeElement[navLevel]) {
if (mode == "off") {
if (activeElement[navLevel] == "") {
// Hide elements of sub-navigation
for (i = navLevel; i <= menuNavigationDeep; i++) {
len = menuStruct[i].length;
for (j = 0; j < len; j++) {
if (subMenu[menuStruct[i][j]]) {
len2 = subMenu[menuStruct[i][j]].length;
for (k = 0; k < len2; k++) {
myhide(subMenu[menuStruct[i][j]][k]);
};
};
};
};
};
};
if (mode == "over") {
if (activeElement[navLevel] == "") {
// Show element of sub-navigation
if (subMenu[objectName]) {
len = subMenu[objectName].length;
for (i = 0; i < len; i++) {
myshow(subMenu[objectName][i]);
};
};
};
};
};
};
}
// Call for enable a sub menu as active and disable the old active element
function setMenu(objectName,navLevel) {
if (navLevel == "") {navLevel = "0"};
// Disable current displayed sub menus
for (i = navLevel; i <= menuNavigationDeep; i++) {
// Reset menu
len = menuStruct[i].length;
for (j = 0; j < len; j++) {
if (document.getElementById(menuStruct[i][j])) {
changeContent(menuStruct[i][j],'deactive',i);
};
// Hide sub menus if exist
if (subMenu[menuStruct[i][j]]) {
len2 = subMenu[menuStruct[i][j]].length;
for (k = 0; k < len2; k++) {
myhide(subMenu[menuStruct[i][j]][k]);
};
};
};
};
if (objectName != activeElement[navLevel] || activeElement[navLevel] == "") {
// Enable new submenu
if (subMenu[objectName]) {
len = subMenu[objectName].length;
for (i = 0; i < len; i++) {
myshow(subMenu[objectName][i]);
};
};
// Define active element and delete cascade
for (i = (navLevel + 1); i <= menuNavigationDeep; i++) {
activeElement[i] = "";
};
activeElement[navLevel] = objectName;
changeContent(activeElement[navLevel],'active',navLevel);
} else {
for (i = navLevel; i <= menuNavigationDeep; i++) {
activeElement[i] = "";
};
};
}
// Gets the id of the parent element
// if parentLevel==0 then take parent, if parentLevel==1 then take parent of the parent, etc.
function getParentId(objectId, parentLevel) {
if (parentLevel == '') {parentLevel = 0};
parentLevel = parseInt(parentLevel);
objId = '#' + objectId;
parentId = $(objId).parents()[parentLevel].id;
return parentId;
}
// Displays (hides and shows) sub menus (if does exist) according to an item
// E.g. it shows all elements (menu containers) like subMenu["preise"] => "menu_01_02_01
function displaySubmenu(itemId, mode) {
if (mode == '') {mode = 'show'};
if (itemId) {
len = subMenu[itemId].length;
for (i = 0; i < len; i++) {
if (mode == 'show') {
myshow(subMenu[itemId][i]);
} else {
myhide(subMenu[itemId][i]);
};
};
};
}
// Initiates the menu
function setMenuOnLoad(objectName,navLevel) {
if ($(objectName)) {
navLevel = parseInt(navLevel);
// alert('objectName=' + objectName + ' navLevel=' + navLevel + ' activeElement[' + navLevel + ']=' + activeElement[navLevel]);
// Activate current item
changeContent(objectName,'active',navLevel);
activeElement[navLevel] = objectName;
// Get id of the parent element
// E.g. objectName == "servicepreise" => parentId = "menu_01_02_01"
parentId = getParentId(objectName,0);
// Lookup for item of next parent navigation level having "parentId" in associated Array
// E.g. "menu_01_02_01" is element of subMenu["preise"] => Get all elements of subMenu["preise"]
for (tmpNavLevel = (navLevel - 1); tmpNavLevel >= 0; tmpNavLevel--) {
// Iterate all items of the navigation level in menuStruct[tmpNavLevel]
len = menuStruct[tmpNavLevel].length;
for (j = 0; j < len; j++) {
if (subMenu[menuStruct[tmpNavLevel][j]]) {
len2 = subMenu[menuStruct[tmpNavLevel][j]].length;
tmpActivateSubmenu = false;
for (k = 0; k < len2; k++) {
if (subMenu[menuStruct[tmpNavLevel][j]][k] == parentId) {
tmpActivateSubmenu = true;
};
};
if (tmpActivateSubmenu) {
// E.g. show all containers of subMenu["preise"]
displaySubmenu(menuStruct[tmpNavLevel][j], 'show');
// Activate parent item e.g. "preise" (= menuStruct[tmpNavLevel][j])
changeContent(menuStruct[tmpNavLevel][j],'active',tmpNavLevel);
activeElement[tmpNavLevel] = menuStruct[tmpNavLevel][j];
parentId = getParentId(menuStruct[tmpNavLevel][j],0);
};
};
};
};
};
}
// Sets all links of a special link class to "hidefocus"
function hideFocusOfLinkClass() {
// $$('#a_menu').each(function(i) {i.hideFocus = "true";});
}
// C9E9FE hellgrün
// 47B868 grün
// 2091C9 blau
var menuActive = true;
// var menuActiveByPageTitel = true;
<?php if ($menuActiveByPageTitel) : ?>
var menuActiveByPageTitel = true;
<?php else : ?>
var menuActiveByPageTitel = false;
<?php endif; ?>
var menuNavigationDeep = <?php if ($jsMenuNavigationDeep == "") : $jsMenuNavigationDeep = "0"; endif; echo $jsMenuNavigationDeep ?>;
// Init parameter for current displayed submenus
var activeElement = new Array();
<?php
for ($j = 0; $j <= $jsMenuNavigationDeep; $j++) :
echo "activeElement[" . $j . "] = '';";
endfor;
?>
var activeElementLen = activeElement.length;
var navBgColor = new Array();
navBgColor[0] = "#1b12b9"; // menu_01 blau (27, 18, 185)
navBgColor[1] = "#4e45ec"; // menu_02 blau (78, 69, 236)
navBgColor[2] = "#97bcFF"; // menu_03 blau (151, 188, 255)
navBgColor[3] = "#97bcFF";
var navBgImg = new Array();
navBgImg[0] = new Array("../images/navItemBgOffMenu01.jpg", "../images/navItemBgOverMenu01.jpg", "../images/navItemBgActiveMenu01.jpg");
navBgImg[1] = new Array("../images/navItemBgOffMenu02.jpg", "../images/navItemBgOverMenu02.jpg", "../images/navItemBgActiveMenu02.jpg");
navBgImg[2] = new Array("../images/navItemBgOffMenu03.jpg", "../images/navItemBgOverMenu03.jpg", "../images/navItemBgActiveMenu03.jpg");
navBgImg[3] = new Array("../images/navItemBgOffMenu03.jpg", "../images/navItemBgOverMenu03.jpg", "../images/navItemBgActiveMenu03.jpg");
// Array of the menu structure
var menuStruct = new Array();
// menuStruct[0] = new Array("verwaltung","auftraege", ...);
// menuStruct[1] = new Array("kunden","transporteure",... ,"uebersicht","pdf_ausgabe");
// ...
<?php
for ($j = 1; $j < $menuLevels; $j++) :
echo "menuStruct[" . ($j - 1) . "] = new Array(" . $jsMenuStruct[$j] . ");\n";
endfor;
?>
// Array of containers be visible by hovering and click
var subMenu = new Array();
// subMenu["verwaltung"] = new Array("menu_01_01","menu_01_02","menu_01_03");
// subMenu["rechnungen"] = new Array("menu_02_01");
// ...
<?php
$jsMenuOut = "";
$tmpLen = count($jsSubMenu);
for ($j = 0; $j < $tmpLen; $j++) :
$jsMenuOut .= "subMenu[\"" . $jsSubMenu[$j][0] . "\"] = new Array(";
$tmpLen2 = count($jsSubMenu[$j][1]);
for ($k = 0; $k < $tmpLen2; $k++) :
$jsMenuOut .= "\"" . $jsSubMenu[$j][1][$k] . "\"";
if ($k < ($tmpLen2 - 1)) :
$jsMenuOut .= ",";
endif;
endfor;
$jsMenuOut .= ");\n";
endfor;
echo $jsMenuOut;
?>
// *** Core menu code (END) **********************************************
// *** Framework Wrapper (BEGIN) ***************************************
function vShow(selector) {
myshow(selector);
};
function vHide(selector) {
myhide(selector);
};
function vSetCss(selector, cssStyles) {
selector = '#' + selector;
$(selector).css(cssStyles);
};
function vSetElementContent(selector, content) {
selector = '#' + selector;
$(selector).html(content);
};
function vGetElementContent(selector) {
selector = '#' + selector;
return $(selector).html();
};
function vConfirmFunc(msg, fn, height, selector) {
if (height == "" || height == undefined) { height = '160'; };
if (selector == "" || selector == undefined) { selector = 'dialog-confirm'; };
selector = '#' + selector;
genConfirm(msg);
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( selector ).dialog({
resizable: false, height:160, modal: true,
buttons: {
"Ja": function() { fn(); },
"Nein": function() { $( this ).dialog( "close" ); }
}
});
});
};
function vConfirmFuncPar(msg, fn, height, selector, par1, par2, par3, par4, par5, par6, par7, par8, par9) {
if (height == "" || height == undefined) { height = '160'; };
if (selector == "" || selector == undefined) { selector = 'dialog-confirm'; };
selector = '#' + selector;
genConfirm(msg);
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( selector ).dialog({
resizable: false, height:160, modal: true,
buttons: {
"Ja": function() {
if (par9 != '') {
fn(par1, par2, par3, par4, par5, par6, par7, par8, par9);
} else if (par8 != '') {
fn(par1, par2, par3, par4, par5, par6, par7, par8);
} else if (par7 != '') {
fn(par1, par2, par3, par4, par5, par6, par7);
} else if (par6 != '') {
fn(par1, par2, par3, par4, par5, par6);
} else if (par5 != '') {
fn(par1, par2, par3, par4, par5);
} else if (par4 != '') {
fn(par1, par2, par3, par4);
} else if (par3 != '') {
fn(par1, par2, par3);
} else if (par2 != '') {
fn(par1, par2);
} else if (par1 != '') {
fn(par1);
}
},
"Nein": function() { $( this ).dialog( "close" ); }
}
});
});
};
// *** Framework Wrapper (END) ******************************************
// *** DHTML (BEGIN) ****************************************************
var activeButton = '';
var disabledButtons = new Array(); // E.g. for export to disable all buttons after selecting one of them
function checkButtonIsDisabled(buttonName) {
notDisabled = true;
disabledButtonsLen = disabledButtons.length;
for (i = 0; i < disabledButtonsLen; i++) {
if (buttonName == disabledButtons[i]) {notDisabled = false;};
};
return notDisabled;
}
function changeButton(mode,buttonName,content,paddingLeft,paddingTop) {
elem = '#' + buttonName;
// elem = $(buttonName);
notDisabled = checkButtonIsDisabled(buttonName);
if (buttonName != activeButton && notDisabled) {
if (mode == "off") {
// elem.setStyle({color: '#FFFFFF'});
$(elem).css('color', '#FFFFFF');
// elem.innerHTML = '<div style="margin-left:' + paddingLeft + '; margin-top:' + paddingTop + ';">' + content + '</div>\n';
};
if (mode == "over") {
// buttonWidth = elem.getStyle('width');
buttonWidth = $(elem).css('width');
buttonWidth = parseInt(buttonWidth.substring(0, (buttonWidth.length - 2))) - 2;
// buttonHeight = elem.getStyle('height');
buttonHeight = $(elem).css('height');
buttonHeight = parseInt(buttonHeight.substring(0, (buttonHeight.length - 2))) - 2;
// elem.setStyle({color: '#97bcFF'});
$(elem).css('color', '#97bcFF');
// elem.innerHTML = '<div style="margin-left:' + paddingLeft + '; margin-top:' + paddingTop + '; color:#FFFFFF;">' + 'x' + content + '</div>\n';
/*
tmpInnerHTLM = eval('<div style="height:1px; background:#FFFFFF;"></div>\n' +
'<div style="height:' + buttonHeight + 'px;">\n' +
' <div style="width:1px; height:100%; background:#FFFFFF;"></div>\n' +
' <div style="width:' + buttonWidth + 'px; height:' + buttonHeight + 'px;">' + content + '</div>\n' +
' <div style="width:1px; height:100%; background:#000000;"></div>\n' +
'</div>\n' +
'<div style="height:1px; background:#000000;"></div>\n');
// elem.innerHTML = tmpInnerHTLM;
$(elem).text(tmpInnerHTLM);
*/
};
};
}
// *** DHTML (END) ****************************************************
// JQuery.Request (POST)
function ajax_request(url, data) {
$.ajax({
type: "POST",
url: url,
data: data,
success: function(msg){ajax_response(msg);}
});
}
// JQuery.Response (POST)
function ajax_response(msg) {
if(!bHasRedirect) {
$('maincontent').innerHTML = msg;
}
else {
bHasRedirect = false;
ajax_request(msg, "");
}
}
// JQuery.Request (GET)
function ajaxRequestGet(url, data) {
$.ajax({
type: "GET",
url: url,
data: data,
async: false,
cache: false,
success: function(msg){eval(msg);}
});
}
var statusMessage = "<?php echo $statusMessage ?>";
function displayStatusMessage() {
if (statusMessage != "") {
alert(statusMessage);
}
};
function hqCheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = true;
}
}
function hqUncheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = false;
}
}
function mkImpressumPopupWin() {
var widthPopupWin = 250;
var heightPopupWin = 310;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin=window.open("../admin/impressum.html", "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin);
};
function mkLanguagePopupWin() {
var widthPopupWin = 250;
var heightPopupWin = 310;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin=window.open("../admin/language.php", "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin);
};
function submitPage(navItem) {
if (document.forms[0].currentNavigationItem) {
document.forms[0].currentNavigationItem.value = navItem;
}
if (document.forms[0].menuActiveByPageTitel) {
if (menuActiveByPageTitel) {
document.forms[0].menuActiveByPageTitel.value = '0';
} else {
document.forms[0].menuActiveByPageTitel.value = '1';
}
}
document.forms[0].submit();
};
function genConfirm(text, headline, appendSelector) {
if (headline == '' || headline == undefined) {headline = '<?php echo getLngt("Bestätigung") ?>';};
if (text == '' || text == undefined) {text = '<?php echo getLngt("Wirklich?") ?>';};
if (appendSelector == '' || appendSelector == undefined) {appendSelector = '#maincontent';};
$(appendSelector).append('<div id="dialog-confirm" title="' + headline + '"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>' + text + '</p></div>');
}
function logout() {
if (confirm('<?php echo getLngt("Möchten Sie sich wirklich abmelden?") ?>')) {
document.location.href = "../admin/logout.php";
};
};
function openMfHistory() {
var widthPopupWin = 900;
var heightPopupWin = 700;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/mf_history.php","","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};
function openJobInvoiceAssoc() {
var widthPopupWin = 1200;
var heightPopupWin = 1024;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../jobs/jb_inv_assoc.php","","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};
function openVehicleDisposition() {
var widthPopupWin = 1800;
var heightPopupWin = 1024;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/vehicle_disposition.php","","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};