(function ($) {
$.each(['hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
jQuery.fn.center = function(parent, callback) {
if (parent) {
parent = this.parent();
} else {
parent = window;
}
this.css({
"position": "absolute",
"top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
"left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px")
});
if(typeof callback == 'function') callback(this);
}
window.showTableIfCanZoom = true;
/*function checkBrowserZoom(){
var browser = $.browser;
var zoom = detectZoom.zoom();
var device = detectZoom.device();
if(browser.webkit){
if(parseFloat(device.toFixed(1)) != 1){
$('#dvLoading').hide();
$(".fht-table-wrapper.fht-default").hide();
$(".height400").append('
');
$(".center").center(true, function(el){
setTimeout(function(){
el.notify("Please 100% zoom in this browser",{
position: 'top center',
className: 'error',
clickToHide: false,
autoHide: false
});
}, 300);
});
window.showTableIfCanZoom = false;
}else{
window.showTableIfCanZoom = true;
}
}
}
checkBrowserZoom();*/
var storage = sessionStorage.getItem("indeksi_Tabele");
var storageX = sessionStorage.getItem("indeksiX");
if (3887 == 4261) {
var storage = "";
var storageX = "";
}
var loadData = false;
if(storage != "" && storageX != "" && storage != null && storageX != null){
$(".checkY").prop("checked",false);
$.each(storage.split(","), function(i,item){
$(".checkY:eq("+item+")").prop('checked', true);
});
$(".checkX").prop("checked",false);
$.each(storageX.split(","), function(i,item){
$(".checkX:eq("+item+")").prop('checked',true);
});
LoadData();
loadData = true;
sessionStorage.removeItem("indeksi_Tabele");
sessionStorage.removeItem("indeksiX");
}
//Active sheetlist state
$('.sheetsList > a').each(function() {
if ($(this).attr('href') === location.pathname)
$(this).addClass('active');
});
$(".sheetsList > a").click(function(){
var $boxes = $('.checkY');
var $indeksi = [];
var $xBox = $('.checkX');
var $xIndeksi = [];
$boxes.each(function(i,item){
//do stuff here with this
if($(item).is(":checked"))
$indeksi.push(i);
// console.log(item);
});
$xBox.each(function(i,item){
if($(item).is(":checked")){
$xIndeksi.push(i);
}
});
sessionStorage.setItem("indeksi_Tabele", $indeksi);
sessionStorage.setItem("indeksiX", $xIndeksi);
$(this).closest('.sheetsList').find('a').removeClass('active');
$(this).addClass('active');
});
$(".vBoxSettings").on('hide', function(e){
if(!window.firstHide){
window.firstHide = true;
return false;
}else{
window.firstHide = false;
}
if($(this).css('display') == 'block') {
LoadData();
}
window.firstHide = false;
});
var isClicked = false;
var zoom = document.documentElement.clientWidth / window.innerWidth;
$(window).resize(function() {
var zoomNew = document.documentElement.clientWidth / window.innerWidth;
if (zoom != zoomNew) {
// zoom has changed
// adjust your fixed element
// checkBrowserZoom();
LoadData();
zoom = zoomNew;
}
});
var canScrollX = true;
$(document).ready(function () {
$(".hBoxSettings").hide();
$(".vBoxSettings").hide();
$(".buttonCross").click(function(){
$('#dvLoading').show();
});
$('.buttonTemplate').hover(function(){
var title = $(this).attr('title');
$(this).data('tipText', title).removeAttr('title');
$('')
.text(title)
.appendTo('body')
.fadeIn('slow');
}, function() {
// Hover out code
$(this).attr('title', $(this).data('tipText'));
$('.tooltip').remove();
}).mousemove(function(e) {
var mousex = e.pageX + 5; //Get X coordinates
var mousey = e.pageY + 5; //Get Y coordinates
$('.tooltip').css({ top: mousey, left: mousex })
});
$('#checkXall').on('change',function(){
if($('#checkXall').is(':checked')){
$('.checkX').prop('checked',true);
}
else{
$('.checkX').prop('checked',false);
}
});
$('#checkYall').on('change',function(){
if($('#checkYall').is(':checked')){
$('.checkY').prop('checked',true);
}
else{
$('.checkY').prop('checked',false);
$('.checkY.checkdisabled').prop('checked',true);
}
});
if(!loadData){
LoadData();
}
});
function hideButton(){
$(".buttonTemplate").hide();
}
var status = 1;
var id_btn= document.getElementById('btn3');
$(document).on("click",id_btn,function(){
status = 2;
});
/*
* funkcija pošlje parametre X koordinat in Y koordinat, ajax vrne html tabele
datum: 2.9.2015
sprememba: - dodan opis
*/
$(window).resize(function(){
LoadData();
});
function LoadData() {
console.trace('loadData');
var xArray = [];
var yArray = [];
$('.checkX:checked').each(function(a,b) {
xArray.push(this.value);
});
$('.checkY:checked').each(function(a,b) {
yArray.push(this.value);
});
//console.log(xArray, yArray);
if(xArray.length==0 || yArray.length==0){
$('.new_cont').html("Anzeigekriterien sind nicht definiert. Bitte klicken Sie auf + um ZEILEN und SPALTEN zu wählen.
");
$('.buttonHtmlGenerate').hide();
$('.buttonExcelGenerate').hide();
return false;
}
$('#dvLoading').show();
if(typeof window.showTableIfCanZoom !== 'undefined'){
if(!window.showTableIfCanZoom) {
$('#dvLoading').hide();
return false;
}else{
$('.height400').show();
}
}
$.ajax({
type: "POST",
url: '/_ajax/ajax.table.php',
data: '&action=getCategories&xcor=' + xArray.join() + '&ycor=' + yArray.join(),
success: function(data){
$('.new_cont').html('');
$('.buttonHtmlGenerate').show();
$('.buttonExcelGenerate').show();
$('#dvLoading').hide();
$('#myTable01').fixedHeaderTable('destroy');
//Appendamo img na prvo celico
// $('.row-4-1 .sub-table th:first-child').wrapInner('');
$('.row-4-1 .sub-table th:first-child').append('
');
$('#myTable01 .tableHead tr td').append('
');
$('#myTable01 .tableBody tr td').not('td:first-child').append('
');
//Preverimo število stolpec in ukrepamo
// var thead_td_last_length = $('.tableBody tr:first-child td').length;
// soulskiner spremenil 31.3.2020
// prestejem iteme v glavi in ne prvih vrednosti ker je lahko prazno, samo naslov
var thead_td_last_length = $('.vatcont td').length;
console.log(thead_td_last_length);
if(thead_td_last_length <= 21){
canScrollX = false;
var multiply_td = thead_td_last_length * 40;
var new_table_width;
if(thead_td_last_length != 2)
new_table_width = multiply_td + 150 + 5;
else
new_table_width = multiply_td + 180 + 5;
console.log(new_table_width);
//Marko 2015.08.12 Desna poravna vrstic z scrolerjem
if(thead_td_last_length == 21) new_table_width -= 30;
//Marko 2015.8.11 Changed the width of emtpy space
$('.tableHead tr:first-child').append(' | ');
$('.tableHead tr:last-child').append(' | ');
$('.tableBody tr').append(' | ');
//Marko 2015.08.12 Dodamo dodatni td oz th v header
var headers = $(".tableHead").last().find('tr');
$.each(headers, function(index, item){
for (var i = 22 ; i > thead_td_last_length; i--) {
if(index == 0)
$(item).append(' | ');
else
$(item).append(' | ');
}
});
//Marko 2015.08.12 Dodamo dodatni td v vsako vrstico
var tds = $(".rest");
$.each(tds, function(index, item){
for (var i = 22 ; i > thead_td_last_length; i--) {
$(item).append(' | ');
}
});
$('.height400').css({'width':new_table_width+'px'});
$('#myTable01').fixedHeaderTable({ footer: false, cloneHeadToFoot: false, fixedColumn: true, autoResize:true });
$('.tableHead tr:last-child td:last-child div.tes').css({'margin-left':'-8px'});
//$('#myTable01 .tableHead tr td').append('
');
//Marko 2015.08.12 Skrijemo scroll bar za levo desno :P
$(".fht-tbody:first").parent().hide();
$(".fht-tbody:last").css('overflow-x', 'hidden');
}else {
canScrollX = true;
$('.height400').css({'width':'100%'});
$('#myTable01').fixedHeaderTable({ footer: false, cloneHeadToFoot: false, fixedColumn: true, autoResize:true });
$('.tableHead th').css({'padding-right':'4px'});
//$(".fht-tbody:last").css('overflow-x', 'hidden');
}
//console.log($('.tableHead td:last-child').width() + " - " + $('.tableBody td:last-child').width());
//$('.fht-fixed-body .fht-thead').append('');
//Horizontal line th/td
$('th.borderLeft').each(function(){
$(this).append('');
});
if ($('.vBox2.tod h2.b-title').length < 1)
$('.vBox2.tod').prepend('ZEILEN
');
if ($('.hBox2.tod h2.b-title').length < 1)
$('.hBox2.tod').prepend('SPALTEN
');
// Alter table width: 3.6.2015
var thead_th = $('.fht-thead .tableHead tr:first-child th').length;
var thead_td = $('.fht-thead .tableHead tr:first-child td').length;
//UREDI 3.8.2015
$('.vat span').each(function(){
if($(this).height() > 12){
$(this).css('bottom','-4px');
}
});
},
complete: function(){
var height = 0;
$(".tableHead:first").find('tr').each(function(index, item){
height += $(item).height();
});
$(".fht-thead:first").css('height', height);
//Marko 2015.08.12 Zmajšamo višino tabele če je manj kot 14 vrstic
var parentHeight = $(".table-cont").height() - 200;
var tableTrs = $(".fht-tbody:last").find('.rest');
var trHeight = tableTrs.first().outerHeight();
var count = Math.ceil(parentHeight/trHeight);
if(count > tableTrs.length){
var newHeight = (tableTrs.length * trHeight);
if(tableTrs.length == 1) newHeight += trHeight;
$(".fht-tbody:last").css('height', newHeight);
}
if(canScrollX){
//Marko 2015.08.14 ce scrolamo v headerjih se tabela scrolla levo in desno
$('.rest, .tableHead:first').on('click', function(e){
if( e.which == 2 ) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
});
$('.tableHead:first').bind('mousewheel DOMMouseScroll', function (e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var content = $(".fht-tbody:last");
var delta = parseInt(e.originalEvent.wheelDelta || -e.originalEvent.detail);
if (delta > 0) {
$(content).scrollTo({left: '-=50', top: $(content).scrollTop() + "px"});
} else {
$(content).scrollTo({left: '+=50', top: $(content).scrollTop() + "px"});
}
});
}
//Marko 2015.08.14 ce scrolamo v prvi koloni se tabela scrolla gor in dol
$(".fht-tbody > .fht-table.fancyTable.sub-table:first").find('td').bind('mousewheel DOMMouseScroll', mouseUpDown);
$(".fht-tbody .fht-table.fancyTable.sub-table .rest").bind('mousewheel DOMMouseScroll', mouseUpDown);
function mouseUpDown(e){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var content = $(".fht-tbody:last");
var delta = parseInt(e.originalEvent.wheelDelta || -e.originalEvent.detail);
if (delta > 0) {
$(content).scrollTo({left: $(content).scrollLeft() + "px", top: '-=50'});
} else {
$(content).scrollTo({left: $(content).scrollLeft() + "px", top: '+=50'});
}
}
$(".buttonTemplate").text("+");
}
});
}
$(".buttonHtmlGenerate").click(function(){
var xyArray = [];
$('.checkX:checked').each(function(a,b) {
xyArray.push(this.value);
});
$('.checkY:checked').each(function(a,b) {
xyArray.push(this.value);
});
window.open("/admin/pages/htmlTemplateTable.php?xyCat=" + xyArray);
});
$(".buttonExcelGenerate").on("click",function(){
var xArray = [];
var yArray = [];
var xIndex = [];
var yIndex = [];
$('.checkX').each(function(a,b) {
if($(this).is(':checked')){
xIndex.push(a);
xArray.push(this.value);
}
});
$('.checkY').each(function(a,b) {
if($(this).is(':checked')){
yIndex.push(a);
yArray.push(this.value);
}
});
var tablesId = [];
$.each($(".sheetsList a"), function(index, el){
var e = $(el).attr('href').split("/");
tablesId.push(e[e.length -1]);
});
//tablesId = [2566];
//window.open("/admin/_forms/ExcelModul/_class/exportExcelCatBackup.php?xCat=" + xArray +"&yCat="+yArray + "&tables=" + tablesId);
window.open("/admin/_forms/ExcelModul/_class/exportExcelCat.php?xCat=" + xIndex +"&yCat="+yIndex + "&tables=" + tablesId);
});
$(".buttonPdfGenerate").click(function(){
var xyArray = [];
$('.checkX:checked').each(function(a,b) {
xyArray.push(this.value);
});
$('.checkY:checked').each(function(a,b) {
xyArray.push(this.value);
});
window.open("/admin/_forms/ExcelModul/_class/exportPDF.php?action=xyCat&xyCat=" + xyArray);
});
$(".buttonTemplate").click(function (e) {
if ($(this).text() == '-') {
//LoadData();
$(this).text('+');
window.firstHide = false;
$(".hBoxSettings").hide();
$(".vBoxSettings").hide();
} else {
//LoadData();
//console.log(e);
$(".hBoxSettings").show();
$(".vBoxSettings").show();
$(this).text('-');
}
return false;
});
$(".confBtn").click(function(){
LoadData();
$(".hBoxSettings").hide();
$(".vBoxSettings").hide();
$(".buttonTemplate").text('+');
});
$(function() {
$('.buttonTemplate[title]' ).tooltip();
var list_length= $('.vBox2 .checkY').length;
//console.log(string_lenght);
if(list_length > 20){
$('.vBox2').css({
"height":"400px",
"width":"400px",
"overflow-y": "scroll",
"word-break":"break-all"
});
}
});
$(".excelNoteButton").click(function (){
$('.sheetsList').hide();
$('.hBoxSettings').hide();
$('.vBoxSettings').hide();
$.ajax({
type: "POST",
url: '/_ajax/ajax.table.php',
data: '&action=getNote&id='+$(this).attr('value'),
success: function(data){
if(data!=""){
$('#tableContainer').html(data);
}
}
});
});
/*
* Funkcija pobriše duplicirane elemente, ki imajo isti id
* -ni v uporabi
*/
function cleanup(arr, prop) {
var new_arr = [];
var lookup = {};
for (var i in arr) {
lookup[arr[i][prop]] = arr[i];
}
for (i in lookup) {
new_arr.push(lookup[i]);
}
return new_arr;
}
var visible = $(".resultsDiv").is(":visible");
$(".dropDownBtn").on('click',function(event){
if ($(".resultsDiv").is(":visible")) {
$(".resultsDiv").slideUp();
return;
}
var uri = window.location.href;
$.ajax({
type:'POST',
url:'/_ajax/ajax.table.php',
data:{
action:'getExcelFiles',
id:uri
},
beforeSend:function(e){
$('#dvLoading').show(400);
},
success: function(e){
var obj = JSON.parse(e);
var data = obj.data;
if(jQuery.isEmptyObject(data)){
$(".resultsDiv").append("No results found");
}
else{
var div = '';
div +='';
div +='
';
div +='';
$.each(data, function(inx,item){
if(inx%4 == 0 && inx != 0){
div +='
';
div +='';
}
div += '';
div +='';
//div +='';
div +=item.table_name;
div +='';
div +=' | ';
});
div+='
';
div+='';
div+='';
$(".resultsDiv").html(div);
$(".resultsDiv").slideDown();
}
},
complete: function(e){
$('#dvLoading').hide();
}
});
});
$('.buttonCross').hide();
$('.buttonPdfGenerate').hide();
$("*").click(function(){
$('.resultsDiv').hide();
$("#markerDrop").html('▼');
});
function removeEmpty(){
//var item =$(".valuesTd .td-w b").innerHTML;
$.each($(".valuesTd .td-w b"), function(key,value){
if(value.innerHTML.length === 0){
// $("tr .valuesTd").remove();
//console.log(value.innerHTML);
}
});
}
function addClassTolastTd(){
/*count number of columns*/
var in_row = $("#myTable01 .tableBody tr:first .valuesTd").length-1;
var num_rows = $("#myTable01 .tableBody tr").length;
var data = $("#myTable01 .categoriesTop .categoriesThead");
var categories = [];
/*count number of sub categories at each category*/
for(var x = 0;x < data.length;x++){
for(var j = 0; j < in_row; j++){
if(data[x].colSpan == j){//OK
for(var n =0 ;n < num_rows ;n++){
$("#myTable01 .tableBody tr.valuesTd:eq("+n+") td:eq(" + data[x].colSpan + ")").addClass("Line");
}
//$("#myTable01 .tableBody tr .valuesTd").addClass("line");//sam na kirem indexu
}
}
}
}