Skip to content

Commit

Permalink
HTML: don't collapse the dive if hyperlink is clicked
Browse files Browse the repository at this point in the history
fixes the wrong behaviour as dive details must not be closed when
hyperlinks are clicking, So check for Hyperlinks before toggling the
dive.

Fixes subsurface#713

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
  • Loading branch information
gehadelrobey authored and dirkhh committed Mar 25, 2015
1 parent 605d2f7 commit 3ff73d0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions theme/list_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function updateView(start, end)
var divelist = document.getElementById('diveslist');
divelist.innerHTML = "";
for (var i = start; i <= end; i++) {
divelist.innerHTML += '<ul id="' + itemsToShow[i] + '" onclick="toggleExpantion(this)"</ul>';
divelist.innerHTML += '<ul id="' + itemsToShow[i] + '" onclick="toggleExpantion(event, this)"</ul>';
expand(document.getElementById(itemsToShow[i]));
items[itemsToShow[i]].expanded = true;
};
Expand All @@ -63,7 +63,7 @@ function addHTML(indexes)
var divelist = document.getElementById('diveslist');
divelist.innerHTML = "";
for (var i = 0; i < indexes.length; i++) {
divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpantion(this)"</ul>';
divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpantion(event, this)"</ul>';
expand(document.getElementById(indexes[i]));
itemsToShow[indexes[i]].expanded = true;
};
Expand Down Expand Up @@ -165,8 +165,11 @@ function setNumberOfDives(e)
viewInPage();
}

function toggleExpantion(ul)
function toggleExpantion(e, ul)
{
if (e.toElement.localName === "a" ) {
return;
}
if (!items[ul.id].expanded) {
expand(ul);
items[ul.id].expanded = true;
Expand Down Expand Up @@ -773,7 +776,7 @@ function expand_trip(trip)
trips[trip].expanded = true;
var d = document.getElementById("trip_dive_list_" + trip);
for (var j in trips[trip].dives) {
d.innerHTML += '<ul id="' + trips[trip].dives[j].number + '" onclick="toggleExpantion(this)" onmouseover="highlight(this)"' +
d.innerHTML += '<ul id="' + trips[trip].dives[j].number + '" onclick="toggleExpantion(event, this)" onmouseover="highlight(this)"' +
' onmouseout="unhighlight(this)">' + getlimited(trips[trip].dives[j]) + '</ul>';
}
}
Expand Down

0 comments on commit 3ff73d0

Please sign in to comment.