?
Current Path : /home1/savoy/www/savoyglobal.net/horeitia/assets/js/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyglobal.net/horeitia/assets/js/jquery.freezecolumn_old.js |
(function($) { // Hide scope, no $ conflict $.fn.freezeTableColumn=function(options){ options=$.extend({ freezColumnCount:1, isFixedHeader:false, fixedWidth : 20, tableBodyHeight : 450, filterOption : false, showDeleteButton : false, deleteImgsrc : '', showAddButton : false, addImgSrc : '' },options); var trCount =1; var g = { scroll: function () { $(g.body1Div).scrollTop($(g.body2Div).scrollTop()); $(g.h2Div).scrollLeft($(g.body2Div).scrollLeft()); }, Filter : function(){ $(tblFreezCol1).find("tr").hide(); $(tblNormalCol1).find("tr").hide(); $.expr[':'].containsIgnoreCase = function(n,i,m){ return jQuery(n).text().toUpperCase().indexOf(m[3].toUpperCase())>=0; }; var tblRows = $(tblFreezCol1).find("tr"); var tblRows1 = $(tblNormalCol1).find("tr"); var str = $(inputElement).val(); tblRows.filter("*:containsIgnoreCase('"+str+"')").show(); tblRows1.filter("*:containsIgnoreCase('"+str+"')").show(); g.synCRowVisible(); }, synCRowVisible : function(){ $(tblFreezCol1).find("tr").each(function(i,o){ if($(this).css('display') != 'none' ||$(tblNormalCol1).find("tr").eq(i).css('display') != 'none') { $(this).css('display','table-row'); $(tblNormalCol1).find("tr").eq(i).css('display','table-row') } }); } }; var employee_array= new Array(); g.globalDiv = document.createElement('div'); g.headerDiv = document.createElement('div'); g.h1Div = document.createElement('div'); g.h2Div = document.createElement('div'); g.bodyDiv = document.createElement('div'); g.body1Div = document.createElement('div'); g.body2Div = document.createElement('div'); var td = document.createElement('td'); var tblFreezCol = document.createElement('table'); var tblNormalCol = document.createElement('table'); var tblFreezCol1 = document.createElement('table'); var tblNormalCol1 = document.createElement('table'); $(g.globalDiv).addClass('glblDiv'); $(g.headerDiv).addClass('headerDiv'); $(g.headerDiv).css('margin','0px'); $(g.h2Div).addClass('hdr2Div'); $(g.h1Div).css('width', options.fixedWidth +'%'); $(g.h1Div).css('margin','0px'); $(g.h1Div).css('float','left'); $(g.h1Div).css('overflow','hidden'); $(g.h2Div).css('overflow','hidden'); $(g.h2Div).css('position','relative'); $(g.h2Div).css('margin','0px'); $(g.h2Div).css('width', (100 - options.fixedWidth - 1.3 )+ '%'); $(g.body1Div).css('width',options.fixedWidth +'%'); $(g.body1Div).css('float','left'); $(g.body1Div).css('height',options.tableBodyHeight + 'px'); $(g.body1Div).css('overflow','hidden'); $(g.body2Div).css('width',(100 - options.fixedWidth )+ '%'); $(g.body2Div).css('height',(options.tableBodyHeight + 30) + 'px' ); $(g.body2Div).css('overflow','scroll'); $(g.body2Div).css('position','relative'); $(g.body2Div).css('margin','0px'); $(tblFreezCol).addClass('sorttimesheet'); $(tblFreezCol1).addClass('sorttimesheet'); $(tblNormalCol).addClass('sorttimesheet'); $(tblNormalCol1).addClass('sorttimesheet'); // table header part $('tr:first', this).each(function () { var tr = document.createElement('tr'); var tr1 = document.createElement('tr'); var trHeight = $(this).height(); if(trHeight == 0) trHeight = 45; $('th', $(this)).each(function (i,o) { var obj = $(o).clone(true); var colspan = 0; colspan = $(obj).attr('colspan'); (i < options.freezColumnCount - (colspan - 1)) ? obj.appendTo($(tr)) : obj.appendTo($(tr1)); }); if(options.showDeleteButton || options.showAddButton) { var delTd = document.createElement('th'); var tmpDelBtn = document.createElement('img'); $(tmpDelBtn).attr({src : options.deleteImgsrc,title:"Add Employee Details",width:"20" ,height:"20"}); $(delTd).append( $(tmpDelBtn)); $(delTd).appendTo($(tr1)) } $(tr).height(trHeight); $(tr1).height(trHeight); $(tblFreezCol).append($(tr)); $(g.h1Div).append($(tblFreezCol)).appendTo($(g.headerDiv).appendTo($(g.globalDiv))); $(tblNormalCol).append($(tr1)); $(g.h2Div).append($(tblNormalCol)).appendTo($(g.headerDiv).appendTo($(g.globalDiv))); }); $('tr', this).not(':first').each(function(i,o){ var tr = document.createElement('tr'); var tr1 = document.createElement('tr'); var colCount = 0; $('td', $(this)).each(function (i,o) { var obj = $(o).clone(true); if(colCount < options.freezColumnCount){ if($(this).attr('colspan')){ if($(this).attr('colspan') < i + options.freezColumnCount){ obj.appendTo($(tr)); colCount += $(this).attr('colspan'); } else{ $(obj).attr('colspan', (options.freezColumnCount - (i +1))); colCount += (options.freezColumnCount - (i +1)); obj.appendTo($(tr)); var td = document.createElement('td'); $(td).attr('colspan',parseInt($(this).attr('colspan')) - (options.freezColumnCount - (i +1))) $(td).appendTo($(tr1)); } } else{ obj.appendTo($(tr)); colCount ++; } } else{ obj.appendTo($(tr1)); } }); if(options.showDeleteButton || options.showAddButton) { var delTd1 = document.createElement('td'); var delButton = document.createElement('img'); if( options.showAddButton && i==0){ $(delButton).attr({src : options.addImgSrc,title:"Add Employee Details",width:"20" ,height:"20"}); $(delButton).click(function(){ if(jQuery.inArray($("input#employee_id").val(), employee_array)!='-1') { alert("Employee already selected"); return; } employee_array.push($("input#employee_id").val()); var newTrfreez =$(tr).clone().find("input").each(function() { $(this).attr({ 'id': function(_, id) {return id + trCount}, 'name': function(_, name) {return name + '[]'}, readonly : true }); }).end(); var newTrNormal = $(tr1).clone().find("input").each(function() { $(this).attr({ 'id': function(_, id) {return id + trCount}, 'name': function(_, id) {return id + '[]'}, 'readonly' : true }); }).end(); $(tr).find("input,span").each(function() { if($(this).is("input")) $(this).val(''); else if($(this).is("span")) $(this).empty(); }); $(tr1).find("input,span").each(function() { if($(this).is("input")) $(this).val(''); else if($(this).is("span")) $(this).empty(); }); $(newTrNormal).find('td:last').empty(); var newDelBttn = document.createElement('img'); $(newDelBttn).attr({src : options.deleteImgsrc,title:"Remove Employee Details",width:"20" ,height:"20"}); $(newDelBttn).click(function(){ $(newTrNormal).remove(); $(newTrfreez).remove(); }); $(newTrNormal).find('td:last').append( $(newDelBttn)); $(newTrfreez).appendTo($(tblFreezCol1)) $(newTrNormal).appendTo($(tblNormalCol1)); trCount++; }); } else{ $(delButton).attr({src : options.deleteImgsrc,title:"Add Employee Details",width:"20" ,height:"20"}); $(delButton).click(function(){ $(tr).remove(); $(tr1).remove(); }); } $(delButton).appendTo($(delTd1)); $(delTd1).width(35); $(delTd1).appendTo($(tr1)) } var trHeight = $(this).height() < 45 ? 45 : $(this).height(); $(tr).height(trHeight); $(tr1).height(trHeight); $(tr).show(function(){ $(tr1).show(); }); $(tblFreezCol1).append($(tr)); $(g.body1Div).append($(tblFreezCol1)).appendTo($(g.bodyDiv).appendTo($(g.globalDiv))); $(tblNormalCol1).append($(tr1)); $(g.body2Div).append($(tblNormalCol1)).appendTo($(g.bodyDiv).appendTo($(g.globalDiv))); }); $('#freezTable').empty(); if(options.filterOption) { var filterDiv = document.createElement('div'); $(filterDiv).css( { width : "97.3%" , margin:'0px', background:'#DFE5E5 no-repeat', 'padding':'8px', 'height' : "30px", 'border-top':'1px solid #C1DAD7', 'border-right':'1px solid #C1DAD7', 'border-left':'1px solid #C1DAD7' }); var inputElement = document.createElement('input'); $(inputElement).attr({type : "text"}); $(inputElement).css({'float' : "none",'margin-left':'10px'}); $(filterDiv).append("Search For :"); $(filterDiv).append(inputElement); $(inputElement).keyup(function(){ g.Filter(); }); $(filterDiv).appendTo($('#freezTable')); } $(g.globalDiv).appendTo($('#freezTable')); $(g.body2Div).scroll(function(){g.scroll();}); }; })(jQuery);