crystal.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. function handleDatatableReady()
  2. {
  3. $('th.datatable-head-cell').each(function() { $(this).attr('title', $(this).html()); });
  4. var rowspan = 1;
  5. var compareVal = '';
  6. var mergeIndex = 0;
  7. $('.datatable-rows .datatable-rows-span:first table tr').each(function()
  8. {
  9. var leftHeight = $(this).height();
  10. var dataIndex = $(this).data('index');
  11. var $right = $('.datatable-rows .datatable-rows-span:last table tr[data-index=' + dataIndex + ']');
  12. var rightHeight = $right.height();
  13. var trHeight = leftHeight;
  14. if(leftHeight <= rightHeight) trHeight = rightHeight;
  15. $right.height(trHeight);
  16. $(this).height(trHeight);
  17. if(dataIndex == 0)
  18. {
  19. compareVal = $(this).find('td:first').html();
  20. mergeIndex = dataIndex;
  21. }
  22. if(mergeIndex != dataIndex)
  23. {
  24. if(compareVal == $(this).find('td:first').html())
  25. {
  26. rowspan += 1;
  27. $(this).parent().find('tr').eq(mergeIndex).find('td:first').attr('rowspan', rowspan);
  28. $(this).find('td:first').remove();
  29. }
  30. else
  31. {
  32. rowspan = 1;
  33. compareVal = $(this).find('td:first').html();
  34. mergeIndex = dataIndex;
  35. }
  36. }
  37. });
  38. }
  39. $(function()
  40. {
  41. handleDatatableReady();
  42. fixScroll();
  43. });
  44. function fixScroll()
  45. {
  46. var $scrollwrapper = $('div.datatable').first().find('.scroll-wrapper:first');
  47. if($scrollwrapper.size() == 0)return;
  48. var $tfoot = $('div.datatable').first().find('table tfoot:last');
  49. var scrollOffset = $scrollwrapper.offset().top + $scrollwrapper.find('.scroll-slide').height();
  50. if($tfoot.size() > 0) scrollOffset += $tfoot.height();
  51. if($('div.datatable.head-fixed').size() == 0) scrollOffset -= '29';
  52. var windowH = $(window).height();
  53. var bottom = $tfoot.hasClass('fixedTfootAction') ? 14 + $tfoot.height() : 14;
  54. if(typeof(ssoRedirect) != "undefined") bottom = 14;
  55. if(scrollOffset > windowH + $(window).scrollTop()) $scrollwrapper.css({'position': 'fixed', 'bottom': '0px'});
  56. $('.datatable .scroll-slide.scroll-pos-out').css('bottom', '0px');
  57. $(window).scroll(function()
  58. {
  59. newBottom = $tfoot.hasClass('fixedTfootAction') ? 14 + $tfoot.height() : 14;
  60. if(typeof(ssoRedirect) != "undefined") newBottom = 14;
  61. if(scrollOffset <= windowH + $(window).scrollTop())
  62. {
  63. $scrollwrapper.css({'position':'relative', 'bottom': '0px'});
  64. $('.datatable .scroll-slide.scroll-pos-out').css('bottom', '-14px');
  65. }
  66. else if($scrollwrapper.css('position') != 'fixed' || bottom != newBottom)
  67. {
  68. $scrollwrapper.css({'position': 'fixed', 'bottom': newBottom + 'px'});
  69. bottom = newBottom;
  70. $('.datatable .scroll-slide.scroll-pos-out').css('bottom', '-' + newBottom + 'px');
  71. }
  72. });
  73. }