
|
If you were logged in you would be able to see more operations.
|
|
|
AppFuse
Created: 10/Oct/07 11:21 PM
Updated: 03/May/08 11:09 PM
|
|
| Component/s: |
Web - General
|
| Affects Version/s: |
2.0 Final
|
| Fix Version/s: |
2.1
|
|
|
The highlightTableRows function in global.js causes an entire row of a table to link to the href of the first anchor in the first cell in the row if the first cell contains an anchor. So, if the table looks like:
<table>
<tr>
<td>My Link</td>
<td>Something here</td>
<td>My Other Link</td>
</tr>
</table>
then the whole row is linked to mylink.html, and clicking on 'My Other Link' goes to mylink.html instead of myOtherLink.html.
I changed this so that a) If there is more than one link in the entire row, it doesn't assign any onclick behavior to the row so each individual link works; b) If there is exactly one link in the row, it uses that link even if it is not in the first column.
Code:
function highlightTableRows(tableId) {
var previousClass = null;
var table = document.getElementById(tableId);
var tbody = table.getElementsByTagName("tbody")[0];
var rows;
if (tbody == null) {
rows = table.getElementsByTagName("tr");
} else {
rows = tbody.getElementsByTagName("tr");
}
// add event handlers so rows light up and are clickable
for (i=0; i < rows.length; i++) {
rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
rows[i].onmouseout = function() { this.className=previousClass };
// GE: Added conditional to prevent whole row from becoming a link when more than
// one link is present in the row. Also, gets the first link in the entire column
// rather than the first link in the first row.
if(rows[i].getElementsByTagName("a").length == 1)
{
var _row = rows[i];
rows[i].onclick = function() {
var link = _row.getElementsByTagName("a")[0];
if (link.onclick) {
call = link.getAttribute("onclick");
if (call.indexOf("return ") == 0) {
call = call.substring(7);
}
// this will not work for links with onclick handlers that return false
eval(call);
} else {
location.href = link.getAttribute("href");
}
this.style.cursor="wait";
return false;
}
}
}
}
|
|
Description
|
The highlightTableRows function in global.js causes an entire row of a table to link to the href of the first anchor in the first cell in the row if the first cell contains an anchor. So, if the table looks like:
<table>
<tr>
<td>My Link</td>
<td>Something here</td>
<td>My Other Link</td>
</tr>
</table>
then the whole row is linked to mylink.html, and clicking on 'My Other Link' goes to mylink.html instead of myOtherLink.html.
I changed this so that a) If there is more than one link in the entire row, it doesn't assign any onclick behavior to the row so each individual link works; b) If there is exactly one link in the row, it uses that link even if it is not in the first column.
Code:
function highlightTableRows(tableId) {
var previousClass = null;
var table = document.getElementById(tableId);
var tbody = table.getElementsByTagName("tbody")[0];
var rows;
if (tbody == null) {
rows = table.getElementsByTagName("tr");
} else {
rows = tbody.getElementsByTagName("tr");
}
// add event handlers so rows light up and are clickable
for (i=0; i < rows.length; i++) {
rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
rows[i].onmouseout = function() { this.className=previousClass };
// GE: Added conditional to prevent whole row from becoming a link when more than
// one link is present in the row. Also, gets the first link in the entire column
// rather than the first link in the first row.
if(rows[i].getElementsByTagName("a").length == 1)
{
var _row = rows[i];
rows[i].onclick = function() {
var link = _row.getElementsByTagName("a")[0];
if (link.onclick) {
call = link.getAttribute("onclick");
if (call.indexOf("return ") == 0) {
call = call.substring(7);
}
// this will not work for links with onclick handlers that return false
eval(call);
} else {
location.href = link.getAttribute("href");
}
this.style.cursor="wait";
return false;
}
}
}
}
|
Show » |
|
I also changed the mouse pointer from an hourglass (???) to a hand.
function highlightTableRows(tableId) {
var previousClass = null;
var table = document.getElementById(tableId);
var tbody = table.getElementsByTagName("tbody")[0];
var rows;
if (tbody == null) {
rows = table.getElementsByTagName("tr");
} else {
rows = tbody.getElementsByTagName("tr");
}
// add event handlers so rows light up and are clickable
for (i=0; i < rows.length; i++) {
rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
rows[i].onmouseout = function() { this.className=previousClass };
// GE: Added conditional to prevent whole row from becoming a link when more than
// one link is present in the row. Also, gets the first link in the entire column
// rather than the first link in the first row. Also, changed cursor style to
// from 'wait' (an hourglass) to 'pointer' (a hand).
if(rows[i].getElementsByTagName("a").length == 1)
{
rows[i].onclick = function(evt) {
evt = (evt) ? evt : ((window.event) ? window.event : "")
if (evt) {
var elem
if (evt.target) {
elem = (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target
} else {
elem = evt.srcElement
}
if (elem) {
var nodeName = elem.nodeName.toLowerCase();
var link;
if(nodeName == 'a')
{
link = elem;
}
else
{
while(nodeName != 'tr')
{
elem = elem.parentNode;
nodeName = elem.nodeName.toLowerCase();
}
link = elem.getElementsByTagName('a')[0];
}
if (link.onclick) {
var call = link.getAttribute("onclick");
if (call.indexOf("return ") == 0) {
call = call.substring(7);
}
// this will not work for links with onclick handlers that return false
eval(call);
} else {
location.href = link.getAttribute("href");
}
this.style.cursor="pointer";
}
}
return false;
}
}
}
}