Commit 797df58e authored by Aaron Wells's avatar Aaron Wells
Browse files

Annotation feedback JS shouldn't rely on window's URL path.

Bug 1431668: This logic doesn't work for sites that are using
cleanURLs, and sites in subdirectories. And anyway, the
annotation.js file only gets loaded on pages where the block
is in "view" mode, so the logic isn't even needed.

Change-Id: I3c2a6505bd95331ab376cde6d5784e3c7e8cd6e2
parent 389df353
......@@ -227,49 +227,44 @@ function connectAddAnnotationFeedbackForms() {
}
function connectAnnotationFeedbackLinks() {
if (window.location.pathname == '/view/view.php') {
// The annotation feedback link is only the view page.
$j(function() {
var links = getElementsByTagAndClassName('a', 'annotationfeedbacklink');
forEach(links, function(link) {
var idprefix = 'annotation_feedback_link_';
if (getNodeAttribute(link, 'id').substring(0, idprefix.length) == idprefix) {
if ($(link)) {
disconnectAll(link);
connect(link, 'onclick', function(e) {
var blockid = getNodeAttribute(link, 'id').substring(idprefix.length);
var chtml = $j('#annotationfeedbacktable_' + blockid).parent();
// Add a 'close' link at the bottom of the list for convenience.
if ($j('#closer_' + blockid).length == 0) {
var closer = $j('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
$j(this).parent().toggle(400, function() {
link.focus();
});
e.preventDefault();
});
chtml.append(closer);
}
var links = getElementsByTagAndClassName('a', 'annotationfeedbacklink');
forEach(links, function(link) {
var idprefix = 'annotation_feedback_link_';
if (getNodeAttribute(link, 'id').substring(0, idprefix.length) == idprefix) {
chtml.toggle(400, function() {
if (chtml.is(':visible')) {
chtml.find('a').first().focus();
}
else {
link.focus();
}
});
if ($(link)) {
disconnectAll(link);
connect(link, 'onclick', function(e) {
var blockid = getNodeAttribute(link, 'id').substring(idprefix.length);
var chtml = $j('#annotationfeedbacktable_' + blockid).parent();
// Add a 'close' link at the bottom of the list for convenience.
if ($j('#closer_' + blockid).length == 0) {
var closer = $j('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
$j(this).parent().toggle(400, function() {
link.focus();
});
e.preventDefault();
});
chtml.append(closer);
}
}
});
});
}
chtml.toggle(400, function() {
if (chtml.is(':visible')) {
chtml.find('a').first().focus();
}
else {
link.focus();
}
});
e.preventDefault();
});
}
}
});
}
addLoadEvent(connectAddAnnotationFeedbackForms);
addLoadEvent(connectAnnotationFeedbackLinks);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment