var changedContent = false; $(function() { initTooltip(); }); /**********************************************************************************************/ function initTooltip() { if ($.isFunction($.fn.tooltip)) { $('.trovarit_tooltip').Tooltip({ showURL: false, id: "trovarit_tooltip", showBody: "; ", fade: 250 }); } } /**********************************************************************************************/ function callOnEnter(e,functionToCall,argArray) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { if ((argArray == null) || (argArray == "")) { argArray = new Array(); } functionToCall.apply(this, argArray); return false; } else return true; } /**********************************************************************************************/ function submitEnter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { myfield.form.submit(); return false; } else return true; } /**********************************************************************************************/ function confirmDialog(title, onYesClick, question, height, width, onNoClick) { if (height == null) { height="auto"; } if (width == null) { width=300; } if (onNoClick == null) { onNoClick=""; } $("#dialog").html(""); var dialogContent = unescape("%3Cdiv%20class%3D%22trovarit_dialog_content%22%3E%0D%0A%3Cdiv%20class%3D%22trovarit_dialog_info%22%3Equestion%3C%2Fdiv%3E%0D%0A%3Ccenter%3E%0D%0A%3Ctable%20cellpadding%3D%2220%22%20width%3D%22270%22%3E%0A%20%20%3Ctr%3E%0A%20%20%20%20%3Ctd%20width%3D%22100%22%3E%3Ca%20class%3D%22trovarit_standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20height%3A20px%3B%20line-height%3A%2020px%3B%20font-weight%3Abold%3B%20color%3A%23ffffff%3B%20background-color%3A%233F89C3%3B%0D%0Aborder-left-color%3A%2379add6%3B%20%0D%0Aborder-top-color%3A%2379add6%3B%20%0D%0Aborder-right-color%3A%232c6089%3B%20%0D%0Aborder-bottom-color%3A%232c6089%3B%22%0D%0A%20onclick%3D%22onYesClick%3B%24%28%27%23dialog%27%29.dialog%28%27close%27%29%3B%22%20onmouseover%3D%22this.style.background%3D%27%23397bb0%27%3B%22%20onmouseout%3D%22this.style.background%3D%27%233F89C3%27%3B%22%3E%0D%0AJA%0D%0A%3C%2Fa%3E%0D%0A%3C%2Ftd%3E%0A%20%20%20%20%3Ctd%20width%3D%22100%22%3E%3Ca%20class%3D%22trovarit_standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20height%3A20px%3B%20line-height%3A%2020px%3B%20font-weight%3Abold%3B%20color%3A%23ffffff%3B%20background-color%3A%23E75200%3B%0D%0Aborder-left-color%3A%23ef864d%3B%20%0D%0Aborder-top-color%3A%23ef864d%3B%20%0D%0Aborder-right-color%3A%23a23900%3B%20%0D%0Aborder-bottom-color%3A%23a23900%3B%22%0D%0A%20onclick%3D%22onNoClick%3B%24%28%27%23dialog%27%29.dialog%28%27close%27%29%3B%22%20onmouseover%3D%22this.style.background%3D%27%23d04a00%27%3B%22%20onmouseout%3D%22this.style.background%3D%27%23E75200%27%3B%22%3E%0D%0ANEIN%0D%0A%3C%2Fa%3E%0D%0A%3C%2Ftd%3E%0A%20%20%3C%2Ftr%3E%0A%3C%2Ftable%3E%0A%3C%2Fcenter%3E%0D%0A%3C%2Fdiv%3E"); dialogContent = dialogContent.replace(/onYesClick/, onYesClick); dialogContent = dialogContent.replace(/onNoClick/, onNoClick); dialogContent = dialogContent.replace(/question/, question); $("#dialog").html(dialogContent); $("#dialog").dialog({ close: function(event, ui) { $(this).dialog('destroy'); }, resizable: false, draggable: false, height: height, width: width, bgiframe: true, modal: true, title: title }); } /**********************************************************************************************/ function infoDialog(title, content, height, width, onCloseClick) { if (height == null) { height="auto"; } if (width == null) { width=400; } if (onCloseClick == null) { onCloseClick=""; } $("#dialog").html(""); var dialogContent = unescape("%3Cdiv%20class%3D%22trovarit_dialog_content%22%3E%0D%0A%3Cdiv%20style%3D%22overflow%3A%20auto%3Bheight%3A%20150px%22%3E%3Cdiv%20class%3D%22trovarit_dialog_info%22%3Eboxcontent%3C%2Fdiv%3E%3C%2Fdiv%3E%0D%0A%3Ccenter%3E%0D%0A%3Ctable%20width%3D%22370%22%20style%3D%22margin-top%3A%2010px%3B%22%3E%0D%0A%20%20%3Ctr%3E%0D%0A%20%20%20%20%3Ctd%20width%3D%22100%25%22%20align%3D%22center%22%3E%3Ca%20class%3D%22trovarit_standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20width%3A100px%3B%20color%3A%23555555%3B%20background-color%3A%23E0E0E0%3B%0D%0Aborder-left-color%3A%23eaeaea%3B%20%0D%0Aborder-top-color%3A%23eaeaea%3B%20%0D%0Aborder-right-color%3A%239d9d9d%3B%20%0D%0Aborder-bottom-color%3A%239d9d9d%3B%22%0D%0A%20onclick%3D%22onCloseClick%3B%24%28%27%23dialog%27%29.dialog%28%27close%27%29%22%20onmouseover%3D%22this.style.background%3D%27%23cacaca%27%3B%22%20onmouseout%3D%22this.style.background%3D%27%23E0E0E0%27%3B%22%3E%0D%0ASCHLIESSEN%0D%0A%3C%2Fa%3E%0D%0A%3C%2Ftd%3E%0D%0A%20%20%3C%2Ftr%3E%0D%0A%3C%2Ftable%3E%0D%0A%3C%2Fcenter%3E%0D%0A%3C%2Fdiv%3E"); dialogContent = dialogContent.replace(/onCloseClick/, onCloseClick); if (height!="auto") { dialogContent = dialogContent.replace(/height: 150px/, 'height: '+(height-100)+'px;'); } else { dialogContent = dialogContent.replace(/height: 150px/, ''); } dialogContent = dialogContent.replace(/370/, width-30); dialogContent = dialogContent.replace(/boxcontent/, content); $("#dialog").html(dialogContent); $("#dialog").dialog({ close: function(event, ui) { $(this).dialog('destroy'); }, resizable: false, draggable: false, height: height, width: width, bgiframe: true, modal: true, title: title }); } /**********************************************************************************************/ function checkCookiesActive() { $.post( "http://www.trovarit.com/core/ajax/ajax.php", { type: "CHECK_COOKIES", page_charset: "ISO-8859-1" }, function(html) { if (html != 1) { if ("iso-8859-1" != "utf-8") { html = decode_utf8(html); } $(".trovarit_cookies_error").html(html); } }); } /**********************************************************************************************/ function encode_utf8( s ) { return unescape( encodeURIComponent( s ) ); } /**********************************************************************************************/ function decode_utf8( s ) { return decodeURIComponent( escape( s ) ); } /**********************************************************************************************/ function addslashes(str) { str=str.replace(/\\/g,'\\\\'); str=str.replace(/\"/g,'\\"'); str=str.replace(/\0/g,'\\0'); str=str.replace(/\n/g,''); str=str.replace(/\t/g,''); return str; } /**********************************************************************************************/ function exportTableToExcel(tableID, savename) { if (savename == null || savename == '') { savename = "Excel_Tabelle" } if ($('#'+tableID).length > 0) { blockScreen(); var headerData = '"header":['; $('#'+tableID+' th').each(function (i) { headerData += '"'+addslashes($(this).text().replace(/^\s+|\s+$/g, ''))+'",'; }); headerData = headerData.slice(0, -1) + '],'; var tableData = '"data": ['; $('#'+tableID+' tbody tr:visible').each(function (i) { var rowData = '['; $("td",this).each(function(j) { var tdContent = ""; tdContent = addslashes($(".exportThis",this).text().replace(/^\s+|\s+$/g, '')); if (tdContent == "") { tdContent = addslashes($(".sortThis",this).text().replace(/^\s+|\s+$/g, '')); } rowData += '"'+tdContent+'",'; }); rowData = rowData.slice(0, -1) + '],'; tableData = tableData + rowData; }); tableData = tableData.slice(0, -1) + ']'; alldata = "{"+headerData+tableData+"}"; $.post( "http://www.trovarit.com/core/ajax/ajax.php", { type: "CREATE_EXCEL_FROM_TABLE", page_charset: "ISO-8859-1", data: alldata, savename: savename }, function(data) { unblockScreen(); if (data.length != 32) { if ("iso-8859-1" != "utf-8") { data = decode_utf8(data); } infoDialog("FEHLER", data); } else { var tempChangedContent = changedContent; if (tempChangedContent) { contentChanged(false); } location.href = "http://www.trovarit.com/core/get_generated_file.php?file="+data; if (tempChangedContent) { contentChanged(true); } } }); } else { infoDialog("FEHLER", "Die Tabelle mit der ID existiert nicht!"); } } /**********************************************************************************************/ function tableToolbarFilter(tableID) { if (!excelFilterExists(tableID)) { blockScreen(); setTimeout(function(){callTableToolbarFilter(tableID);}, 150); } else { $("div.trovarit_excel_filter_dialog").dialog('close'); eval(tableID+"_filter").clearExcelFilterData(); eval(tableID+"_filter").setFilter(); } } /**********************************************************************************************/ function excelFilterExists(tableID) { var filterExists = false; eval("filterExists = ((typeof("+tableID+"_filter)!='undefined') && ("+tableID+"_filter != null))"); return filterExists; } /**********************************************************************************************/ function callTableToolbarFilter(tableID) { if (!excelFilterExists(tableID)) { var filterText = $('input#'+tableID+'_input_filter').val(); $('table#'+tableID+' tbody tr').removeHighlight(); if (filterText.length == 0) { $('table#'+tableID+' tbody tr').show(); } else { $('table#'+tableID+' tbody tr').each( function (column) { var searchText = $(this).text(); if (searchText.toLowerCase().indexOf(filterText.toLowerCase()) >= 0) { $(this).show(); } else { $(this).hide(); } }); $('table#'+tableID+' tbody tr').highlight(filterText); } setToolbarInfo(tableID, false); reinitTablesorter(tableID); unblockScreen(); } } /**********************************************************************************************/ function setToolbarInfo(tableID, initTotalCount) { if ($('table#'+tableID+' tbody tr:first td').length == 0) { $('#'+tableID+'_visible_count').text(0); } else { $('#'+tableID+'_visible_count').text($('table#'+tableID+' tbody tr td:visible').length / $('table#'+tableID+' tbody tr:first td').length); } if (initTotalCount) { $('#'+tableID+'_all_count').text($('table#'+tableID+' tbody tr').length); } } /**********************************************************************************************/ function tableToolbarFilterReset(tableID) { $('input#'+tableID+'_input_filter').val(""); tableToolbarFilter(tableID); } /**********************************************************************************************/ function addTableToolbar(tableID, filename, legendeContent, helpLink, disableExcelFilter) { if (disableExcelFilter == null) { disableExcelFilter = false; } if (($('#'+tableID).length == 1) && ($('#'+tableID).prev().attr("class") != "trovarit_table_toolbar_container")) { $.post( "http://www.trovarit.com/core/ajax/ajax.php", { type: "GET_TABLE_TOOLBAR", page_charset: "ISO-8859-1", app_language: "de", tableID: tableID, filename: filename, disableExcelFilter: disableExcelFilter, legendeTemplate: legendeContent, helpLink: helpLink }, function(html) { if ("iso-8859-1" != "utf-8") { html = decode_utf8(html); } $('#'+tableID).before(html); }); } else { infoDialog("FEHLER", "Die Tabelle mit der ID existiert nicht!"); } } /**********************************************************************************************/ function addTableExcelFilter(tableID, callbackAfterFilter) { if (($('#'+tableID).length == 1) && ($('#'+tableID+' .trovarit_table_excel_filter').length==0)) { $.post( "http://www.trovarit.com/core/ajax/ajax.php", { type: "ADD_EXCEL_TABLE_FILTER", page_charset: "ISO-8859-1", app_language: "de", tableID: tableID, callbackAfterFilter: callbackAfterFilter, colCount: $('#'+tableID+' thead th').length }, function(html) { if ("iso-8859-1" != "utf-8") { html = decode_utf8(html); } $('#'+tableID+' thead').prepend(html); }); } else { infoDialog("FEHLER", "Die Tabelle mit der ID existiert nicht!"); } } /**********************************************************************************************/ function reinitTablesorter(tableID) { $("table#"+tableID).trigger("update"); $("table#"+tableID).trigger("appendCache"); } /**********************************************************************************************/ function initTablesorter(tableID, sortRow, sortDescending) { if (sortRow == null) { sortRow = 0; } if (sortDescending == null) { sortDescending = 0; } $('table#'+tableID).tablesorter({ widgets: ['zebra'], sortList: [[sortRow,sortDescending]], textExtraction: function(node) { return $("span.sortThis", node).text(); } }); } /**********************************************************************************************/ function initFormValidator(formID) { $("#"+formID).validate({ meta: "validate", errorClass: "trovarit_validation_error", errorPlacement: function(error, element) { } }); } /**********************************************************************************************/ function isFormValid(formID) { if ($('#'+formID).length > 0) { if ($('#'+formID).valid()) { return true; } else { infoDialog("FEHLER","Bitte füllen Sie alle Felder korrekt aus!"); return false; } } else { infoDialog("FEHLER", "isFormValid(): Kein Formular mit der ID '"+formID+"' gefunden!"); } } /**********************************************************************************************/ function contentChanged(changed) { changedContent = changed; setUnload(changed); } /**********************************************************************************************/ function setUnload(enabled) { if (enabled) { $(window).bind('beforeunload', function() { return 'Daten haben sich geändert und wurden noch nicht gespeichert!'; }); } else { $(window).unbind('beforeunload'); } } /**********************************************************************************************/ function addValidatorCombobox() { jQuery.validator.addMethod("selectCombobox", function(value, element) { if (value == "") { return false; } return true; }, " "); } /**********************************************************************************************/ String.prototype.rtrim = function(chars) { chars = chars || "\\s"; return this.replace(new RegExp("[" + chars + "]+$", "g"), ""); } /**********************************************************************************************/ String.prototype.ltrim = function(chars) { chars = chars || "\\s"; return this.replace(new RegExp("^[" + chars + "]+", "g"), ""); } /**********************************************************************************************/ String.prototype.trim = function(chars) { return this.ltrim(chars).rtrim(chars); } /**********************************************************************************************/ function getJsonArray(myArray, arrayLabel) { if (myArray == null) { return ""; } var jsonString = '{"'+arrayLabel+'":['; $.each(myArray, function(key, value) { jsonString += '"'+addslashes(value)+'",'; }); jsonString = jsonString.rtrim(","); jsonString += ']}'; return jsonString; } /**********************************************************************************************/ /**********************************************************************************************/ function getTableCellText(tableCell) { var cellText = $(".exportThis",tableCell).text(); if (cellText == "") { cellText = $(".sortThis",tableCell).text(); } if (cellText == "") { cellText = $(tableCell).text(); } return cellText.trim(); } /**********************************************************************************************/ if(!Array.indexOf){ Array.prototype.indexOf = function(obj){ for(var i=0; i"); $("div.trovarit_excel_filter_dialog").hide().html(content); var pageOffsetTop = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop; var pageOffsetLeft = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft; var dialogWidth = 200; var dialogLeft = posElement.position().left-pageOffsetLeft-1; if (dialogLeft+dialogWidth > ($('#'+tableID).position().left+$('#'+tableID).innerWidth())) { dialogLeft = posElement.position().left+posElement.innerWidth()-dialogWidth-pageOffsetLeft-1; } $("div.trovarit_excel_filter_dialog").dialog({ close: function(event, ui) { $(this).dialog('destroy'); $("div.trovarit_excel_filter_dialog").remove(); }, resize: function(event, ui) { var tableHeight = $('.trovarit_excel_filter_dialog.ui-dialog-content').height()-$('.trovarit_excel_filter_dialog.ui-dialog-content .trovarit_table_toolbar_container').height()-8; $('div#trovarit_excel_filter_select').height(tableHeight); }, resizable: true, draggable: true, height: 200, width: 200, minWidth: 200, dialogClass: 'trovarit_filter_dialog', position: [Math.round(dialogLeft),Math.round(posElement.position().top+posElement.innerHeight()-pageOffsetTop)+3], bgiframe: true, modal: false, buttons: { "Löschen": function() { $("#trovarit_excel_filter_select input:checked").removeAttr("checked");eval(tableID+"_filter").setFilter(position);$(this).dialog('close');},"Abbr.": function() { $(this).dialog("close"); },"OK": function() { eval(tableID+"_filter").setFilter(position);$(this).dialog('close'); } } }); } /**********************************************************************************************/ function getExcelFilterData(position, filterData) { if (position == null) { return filterData; } else { return filterData[position]; } } /**********************************************************************************************/ this.getData = function() { return filterData; } /**********************************************************************************************/ this.setData = function(newFilterData) { filterData = newFilterData; } /**********************************************************************************************/ this.setExcelFilterData = function(position, filter) { filterData[position] = filter; } /**********************************************************************************************/ this.clearExcelFilterData = function() { filterData = new Array(); } /**********************************************************************************************/ this.hasExcelFilterData = function() { for ( i=0; i < filterData.length; i++ ) { if (filterData[i] != 'undefined' && filterData[i] != null) { return true; } } return false; } /**********************************************************************************************/ this.getExcelFilterCount = function() { var filterCount = 0; for ( i=0; i < filterData.length; i++ ) { if (filterData[i] != 'undefined' && filterData[i] != null) { filterCount++; } } return filterCount; } /**********************************************************************************************/ this.getAllFilterData = function(element,position) { var filterText = new Array(); var table = $(element).parents(".trovarit_sort_table"); $("tbody tr:visible td:nth-child("+position+")",table).each(function() { var rowText = getTableCellText(this); rowText=rowText.replace(/(\r\n|\n|\r)/gm,""); if (filterText.indexOf(rowText) == -1) { filterText.push(rowText); } }); filterText.sort(); return filterText; } /**********************************************************************************************/ this.setCheckedDialogFilter = function(position) { var values = getExcelFilterData(position,filterData); if ((values != null) && (values != 'undefined')) { $.each(values, function(key, value) { $("input[value='"+value+"']").attr("checked","checked"); }); } } /**********************************************************************************************/ this.setFilterHeader = function() { if (this.hasExcelFilterData()) { $.each(filterData, function(col, value) { if (value != 'undefined' && value != null) { $($('#'+tableID+' thead .trovarit_table_excel_filter')[col-1]).addClass("trovarit_table_excel_filter_active"); $($('#'+tableID+' thead .trovarit_table_excel_filter')[col-1]).find("td:first").text(value.length); } else { $($('#'+tableID+' thead .trovarit_table_excel_filter')[col-1]).removeClass("trovarit_table_excel_filter_active"); $($('#'+tableID+' thead .trovarit_table_excel_filter')[col-1]).find("td:first").text(""); } }); } else { $('#'+tableID+' thead .trovarit_table_excel_filter').removeClass("trovarit_table_excel_filter_active"); $('#'+tableID+' thead .trovarit_table_excel_filter').find("td:first").text(""); } } /**********************************************************************************************/ this.setFilter = function(position) { var filterArray = new Array(); $("input[name='filter']:checked").each(function(key, value) { filterArray.push($(this).val()); }); if (filterArray.length == 0) { filterArray = null; } this.setExcelFilterData(position,filterArray); this.filterTable(); } /**********************************************************************************************/ this.setHeaderLabel = function() { $.each(getExcelFilterData(position, filterData), function(key, value) { $("input[value='"+value+"']").attr("checked","checked"); }); } /**********************************************************************************************/ this.getFilterPositions = function() { var positions = new Array(); $.each(filterData, function(key, value) { if (value != 'undefined' && value != null) { positions.push(key); } }); return positions; } /**********************************************************************************************/ this.filterTableNow = function() { this.setFilterHeader(); var rowColShowCount=0; var filterCount = this.getExcelFilterCount(); if (this.hasExcelFilterData()) { var colPositions = this.getFilterPositions(); $("#"+tableID+" tbody tr").each(function(row, valueRow) { var allTD = $("td",valueRow); $.each(colPositions, function(keyCol,valueCol) { if (filterData[valueCol].indexOf(getTableCellText(allTD[valueCol-1]).replace(/(\r\n|\n|\r)/gm,"")) != -1) { rowColShowCount++; if (rowColShowCount == filterCount) { $(valueRow).show(); } } else { $(valueRow).hide(); return false; } }); rowColShowCount = 0; }); } else { $("#"+tableID+" tbody tr").show(); } setToolbarInfo(tableID,false); reinitTablesorter(tableID); if (callbackAfterFilter != null) { eval(callbackAfterFilter); } unblockScreen(true); } } /**********************************************************************************************/ function setTableZebra(tableID) { $("#"+tableID+" tbody tr:visible").each(function(row, element) { $(element).removeClass("even"); $(element).removeClass("odd"); if (row % 2 == 0) { $(element).addClass("odd"); } else { $(element).addClass("even"); } }); }