diff options
author | talasila <talasila@research.att.com> | 2017-02-08 10:13:29 -0500 |
---|---|---|
committer | talasila <talasila@research.att.com> | 2017-02-08 10:15:00 -0500 |
commit | f8a8d5192b1e5013d9e2f699be54b072ef39d5f0 (patch) | |
tree | b7a65bb0a7d70a9dc24c064113868e5f3b8e6a09 /dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js | |
parent | 72a80fbff7120630576ccd5aa67c20818c2943c7 (diff) |
Initial OpenECOMP UI/DMaapBC commit
Change-Id: Ia492e1b88311b9bed4c31f593b28deaaad73b7e4
Signed-off-by: talasila <talasila@research.att.com>
Diffstat (limited to 'dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js')
-rw-r--r-- | dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js b/dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js new file mode 100644 index 0000000..2c90306 --- /dev/null +++ b/dcae_dmaapbc_webapp/src/main/webapp/static/fusion/raptor/js/persist_table_header.js @@ -0,0 +1,47 @@ + function UpdateTableHeaders() { + $("div.divTableWithFloatingHeader").each(function() { + var originalHeaderRow = $(".tableFloatingHeaderOriginal", this); + var floatingHeaderRow = $(".tableFloatingHeader", this); + var offset = $(this).offset(); + var scrollTop = $(window).scrollTop(); + if ((scrollTop > offset.top) && (scrollTop < offset.top + $(this).height())) { + floatingHeaderRow.css("visibility", "visible"); + floatingHeaderRow.css("top", Math.min(scrollTop - offset.top, $(this).height() - floatingHeaderRow.height()) + "px"); + floatingHeaderRow.css("z-index", "20"); + + // Copy cell widths from original header + $("th", floatingHeaderRow).each(function(index) { + var cellWidth = $("th", originalHeaderRow).eq(index).css('width'); + $(this).css('width', cellWidth); + }); + + // Copy row width from whole table + floatingHeaderRow.css("width", $(this).css("width")); + } + else { + floatingHeaderRow.css("visibility", "hidden"); + floatingHeaderRow.css("top", "0px"); + } + }); + } + + $(document).ready(function() { + $("table.tableWithFloatingHeader").each(function() { + $(this).wrap("<div class=\"divTableWithFloatingHeader\" style=\"position:relative\"></div>"); + + var originalHeaderRow = $("tr:first", this) + originalHeaderRow.before(originalHeaderRow.clone()); + var clonedHeaderRow = $("tr:first", this) + + clonedHeaderRow.addClass("tableFloatingHeader"); + clonedHeaderRow.css("position", "absolute"); + clonedHeaderRow.css("top", "0px"); + clonedHeaderRow.css("left", $(this).css("margin-left")); + clonedHeaderRow.css("visibility", "hidden"); + + originalHeaderRow.addClass("tableFloatingHeaderOriginal"); + }); + UpdateTableHeaders(); + $(window.parent).scroll(UpdateTableHeaders); + $(window.parent).resize(UpdateTableHeaders); + });
\ No newline at end of file |