// **************************************
// Name: f104_insertheader.js
// Created by Cho for APEX IR. 2011/11/20
// Added 1st line (Table Header) when double clicked.
// Tested OK under IE v7.0 and FF v8.0
//***************************************
/************ Put following line(s) in IR Region Header HTML ******************
box.style.top = docY(e) + "px"; //20120911, modified for firefox
box.style.left = docX(e) + "px"; //20120911, modified for firefox
}
}
function boxVisibility(flg) {
//flg = visible || hidden
//alert(flg);
//var scrollBox = document.getElementById('scrollBox');
box.style.visibility = flg;
$x('boxMessage').style.visibility='hidden'; //hide [copy to clipboard] message box if visible
}
// functions to get (x,y) in a documnet. Work both IE & FF.
function docX(e) {return e.pageX || e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;}
function docY(e) {return e.pageY || e.clientY + document.body.scrollTop + document.documentElement.scrollTop ;}
function plusClicked(e){
var tgt;
if (document.all){tgt = e.srcElement;} //for IE
else{tgt = e.target;} //for FireFox
var lineClicked = tgt.parentNode.parentNode.rowIndex+1;
//alert(lineClicked&#43;'<---'&#43;lineClickedB4)
if (lineClickedB4 != lineClicked){
lineClickedB4 = lineClicked;
var table = document.getElementById(gTable);
makeScrollBox(table, 0, lineClicked);
}
boxVisibility('visible');
// moveTo(event);
moveTo(e); //20120911, modified for firefox
}
function insertHeader2Click(e){
var tgt;
if (document.all){tgt = e.srcElement;} //for IE
else{tgt = e.target;} //for FireFox
var lineClicked = tgt.parentNode.rowIndex;
var table = document.getElementById(gTable);
if (lineClicked>0){
boxVisibility('hidden'); //hide scrollBox when make newHeader
lineClickedB4 = 0; //reset to 0 to prevent confuse.
newHeader(table, 0, lineClicked);
}
}
function makeScrollBox(table, hdLine, bdLine){
if (hdLine<0){hdLine=0;}
if (bdLine<=0){return;} // if bdLine<=0, it's not a table line, so exit(return).
//var tbody = table.tBodies[0]; // Use tbody
var header = table.getElementsByTagName('tr')[hdLine];
var cOntnt= table.getElementsByTagName('tr')[bdLine];
var hdCols = header.getElementsByTagName('th');
var ctCols = contnt.getElementsByTagName('td');
for (var i = 0; i
var row = document.createElement("tr");
// Create a
element and a text node, make the text
// node the contents of the
, and put the
at
// the end of the table row
var cell = document.createElement("td");
var cellText = document.createTextNode(hdCols[i].innerHTML.replace(/<.*?>/gi,'').replace(/&.*?;/,''));
cell.appendChild(cellText);
row.appendChild(cell);
var cell = document.createElement("td");
var cellText = document.createTextNode(ctCols[i].innerHTML.replace(/<.*?>/gi,'').replace(/&.*?;/,''));
cell.appendChild(cellText);
row.appendChild(cell);
tblBody.appendChild(row);
}
// add the row to the end of the table body
//tblBody.appendChild(row);
//}
// put the
in the
tbl.appendChild(tblBody);
// appends
into
//body.appendChild(tbl);
boxContents.appendChild(tbl);
// sets the border attribute of tbl to 2;
tbl.setAttribute("border","1px");
}
function newHeader(table, from, to){
//alert(from&#43;'-->'&#43;to);
if (to<0){to=0;}
if (from<0){from=0;}
var tbody = table.tBodies[0]; // Use tbody
//var trFrom = tbody.rows[from]; // Make sure row stays referenced
//tbody.removeChild(trFrom); // Remove the row before inserting it (dupliate id's
var trTo = tbody.rows[to];
//var trClOne= tbody.rows[from].cloneNode(true); // copy children too
break;
}
newHeader.appendChild(col); // append a column to row
}
tbody.insertBefore(newHeader, trTo); // insert newHeader before trTo
return newHeader;
}
function removeHeader(tgtObj){
//alert(tgtObj.parentNode.parentNode.tagName);
var lineClicked = tgtObj.parentNode.parentNode.rowIndex;
if (lineClicked>0){
var table = document.getElementById(gTable);
table.deleteRow(lineClicked);
}
}
function goHome(e){
//alert('Going Home....');
//window.scrollTo(0, 0); // scroll to position(x,y)
//alert(docY(e));
window.scrollBy(0,-e.pageY||-99999999); // horizontal and vertical scroll increments. SLOW in IE....
//window.scrollBy(0,-9999999999);
}