parent
a06d8e8f79
commit
e859a51772
9 changed files with 203 additions and 13 deletions
@ -0,0 +1,13 @@ |
||||
<!DOCTYPE html> |
||||
<html xmlns="http://www.w3.org/1999/xhtml"> |
||||
<html> |
||||
<head> |
||||
<title>ERROR - Page Expired</title> |
||||
</head> |
||||
<body> |
||||
<h1>Page Expired</h1> |
||||
<p>The page state could not be restored because it was left |
||||
idle too long.</p> |
||||
<p><a href="/main.jsf">Return to Main Page</a></p> |
||||
</body> |
||||
</html> |
@ -0,0 +1,114 @@ |
||||
// scrolltable.js - scroll functions for dataTable
|
||||
|
||||
function scrollAndFocus(rootId, tableId, txtId) { |
||||
scrollToBottom(rootId + ":" + tableId); |
||||
$(rootId +":" + txtId).focus(); |
||||
} |
||||
|
||||
function scrollToBottom(idDataTable) { |
||||
pTable = digestTable(idDataTable); |
||||
|
||||
scrollToRow(pTable, 9999); |
||||
} |
||||
|
||||
function digestTable(idDataTable) { |
||||
pTable = { |
||||
id: idDataTable |
||||
} |
||||
pTable.jqId = '#' + idDataTable.replaceAll(':', '\\:'); |
||||
pTable.jqData = pTable.jqId + "_data"; |
||||
pTable.heignt = $(pTable.jqId + " .ui-datatable-scrollable-body").height(); |
||||
//var lichildren = $(pTable.jqId).children("tr");
|
||||
var lichildren = $(pTable.jqId).find("tr"); |
||||
pTable.itemHeight = lichildren.height(); |
||||
pTable.itemCount = lichildren.length; |
||||
pTable.visibleItemCount = pTable.height / pTable.itemHeight; |
||||
return pTable;
|
||||
} |
||||
|
||||
|
||||
function scrollToRow(pTable, selItem) {
|
||||
var maxScrollItem = pTable.itemCount - pTable.visibleItemCount; |
||||
var scrollTopInPx;
|
||||
if(selItem >= maxScrollItem) |
||||
{ |
||||
// scroll table to the bottom
|
||||
scrollTopInPx = pTable.itemCount * pTable.itemHeight; |
||||
} |
||||
else if(selItem < 2) |
||||
{ |
||||
// scroll table to the top
|
||||
scrollTopInPx = 0; |
||||
} |
||||
else |
||||
{ |
||||
// scroll selected item to the 1.2 th position
|
||||
scrollTopInPx = (selItem - 1.2) * pTable.itemHeight; |
||||
} |
||||
|
||||
$(pTable.jqId + " .ui-datatable-scrollable-body").animate({scrollTop:scrollTopInPx, duration: 20}, scrollTopInPx);
|
||||
|
||||
} |
||||
|
||||
/** |
||||
* This function scrolls the selected Item of a
|
||||
* <p:dataTable id="idDataTable" selectionMode="single"
|
||||
* into the visible area |
||||
* <p:dataTable renderes to a scroll-container with the css-class: ui-datatable-scrollable-body (inside the element with the id : "idDataTable") |
||||
* and to a container holding all items with the id: "idDataTable"_data
|
||||
* |
||||
* @param idDataTable z.B.: idForm:idDataTable |
||||
*/ |
||||
function autoScrollPDatatable(idDataTable)
|
||||
{ |
||||
// for selection in JQuery the ids with : must be encoded with \\:
|
||||
var primfcid = idDataTable.replace(':', '\\:'); |
||||
var idDataTbl = '#' + primfcid; |
||||
var idDataContainer = idDataTbl + "_data"; |
||||
|
||||
var totalHeight = $(idDataTbl + " .ui-datatable-scrollable-body").height(); |
||||
var lichildren = $(idDataContainer).children("tr"); |
||||
var itemHeight = $(idDataContainer).children("tr").height(); |
||||
var anzItems = lichildren.length; |
||||
var anzVisItems = totalHeight / itemHeight; |
||||
var selItem = detectDataTableScrollPos(lichildren);
|
||||
if(selItem == -1) |
||||
{ |
||||
// no selection found...
|
||||
return; |
||||
} |
||||
|
||||
var maxScrollItem = anzItems - anzVisItems; |
||||
var scrollTopInPx;
|
||||
if(selItem >= maxScrollItem) |
||||
{ |
||||
// scroll table to the bottom
|
||||
scrollTopInPx = maxScrollItem * itemHeight; |
||||
} |
||||
else if(selItem < 2) |
||||
{ |
||||
// scroll table to the top
|
||||
scrollTopInPx = 0; |
||||
} |
||||
else |
||||
{ |
||||
// scroll selected item to the 1.2 th position
|
||||
scrollTopInPx = (selItem - 1.2) * itemHeight; |
||||
} |
||||
|
||||
$(idDataTbl + " .ui-datatable-scrollable-body").animate({scrollTop:scrollTopInPx}, scrollTopInPx);
|
||||
} |
||||
|
||||
function detectDataTableScrollPos(liChildren) |
||||
{ |
||||
for (i=0;i< liChildren.length;++i) |
||||
{ |
||||
var chd = liChildren[i]; |
||||
var x = chd.getAttribute("aria-selected"); |
||||
if(x === "true") |
||||
{ |
||||
return i; |
||||
} |
||||
} |
||||
return -1; |
||||
} |
Loading…
Reference in new issue