From d36ba034e18fc026edb6487e6100e5fd1742ba4e Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Thu, 4 Jun 2009 20:14:37 +0000 Subject: [PATCH] Various updates to public-view, made comment icons clickable. --- .../courses/public-view/search-box.js | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 document_root/javascript/courses/public-view/search-box.js diff --git a/document_root/javascript/courses/public-view/search-box.js b/document_root/javascript/courses/public-view/search-box.js new file mode 100644 index 00000000..adefb089 --- /dev/null +++ b/document_root/javascript/courses/public-view/search-box.js @@ -0,0 +1,151 @@ +addLoadEvent(onLoadPublicViewSearch); + +function onLoadPublicViewSearch() +{ + if (document.getElementById('refineSearchLink')) { + document.getElementById('refineSearchLink').onclick = handleRefineSearchLinkClick; + } + document.getElementById('college').onchange = handleChangeSelectHierarchy; + document.getElementById('department').onchange = handleChangeSelectHierarchy; + handleChangeSelectHierarchy(); + + if (document.getElementById('printButton')) { + document.getElementById('printButton').onclick = function() { + window.print(); + }; + } + + var helpLinks = getElementsByClassName('hoverHelp'); + for (var i = 0; i < helpLinks.length; i++) { + helpLinks[i].onmouseover = displayHoverHelp; + helpLinks[i].onmouseout = hideHoverHelp; + helpLinks[i].onclick = function() {return false;}; + } + + document.getElementById('ace').onclick = function() { + document.getElementById('aceOutcomes').disabled = !this.checked; + var options = document.getElementById('aceOutcomes').getElementsByTagName('option'); + for (var i = 0; i < options.length; i++) { + options[i].selected = this.checked; + } + document.getElementById('aceOutcomes').focus(); + } + + if (document.getElementById('reset')) { + document.getElementById('reset').onclick = function() { + clearForm(this.form); + return false; + } + } +} + +function handleRefineSearchLinkClick() +{ + document.getElementById('searchSummary').style.display = 'none'; + document.getElementById('searchForm').style.display = ''; +} + + +function handleChangeSelectHierarchy() +{ + var collegeSelect = document.getElementById('college'); + var departmentSelect = document.getElementById('department'); + var subjectSelect = document.getElementById('subject'); + + var selectedCollegeId = collegeSelect.options[collegeSelect.selectedIndex].value; + var options = departmentSelect.getElementsByTagName('option'); + for (var i = options.length - 1; i >= 0; i--) { + if (options[i].getAttribute('rel') == selectedCollegeId || collegeSelect.value == 0 || options[i].value == 0) { + options[i].style.display = ''; + } else { + options[i].style.display = 'none'; + } + } + + var selectedDepartment = departmentSelect.options[departmentSelect.selectedIndex]; + if (selectedDepartment.style.display == 'none') { + departmentSelect.selectedIndex = 0; + } + + var selectedDepartments = new Array(); + + if (departmentSelect.selectedIndex == 0) { + var options = departmentSelect.getElementsByTagName('option'); + for (var i = options.length - 1; i >= 0; i--) { + if (options[i].style.display == 'none') { + continue; + } + selectedDepartments.push(options[i].value); + } + } else { + selectedDepartments.push(departmentSelect.options[departmentSelect.selectedIndex].value); + } + + options = subjectSelect.getElementsByTagName('option'); + + for (var i = options.length - 1; i >= 0; i--) { + if (selectedDepartments.inArray(options[i].getAttribute('rel')) || options[i].value == 0) { + options[i].style.display = ''; + } else { + options[i].style.display = 'none'; + } + } + + var selectedSubject = subjectSelect.options[subjectSelect.selectedIndex]; + if (selectedSubject.style.display == 'none') { + subjectSelect.selectedIndex = 0; + } +} + + +function displayHoverHelp(e) +{ + + e = e || window.event; + var cursor = {x:0, y:0}; + if (e.pageX || e.pageY) { + cursor.x = e.pageX; + cursor.y = e.pageY; + } + else { + cursor.x = e.clientX + + (document.documentElement.scrollLeft || document.body.scrollLeft) - + (document.documentElement.clientLeft || document.body.clientLeft); + cursor.y = e.clientY + + (document.documentElement.scrollTop || document.body.scrollTop) - + (document.documentElement.clientTop || document.body.clientTop); + } + + var helpDiv, helpText; + if(!document.getElementById('floating_help_text_div')) { + helpDiv = document.createElement('div'); + helpDiv.style.display = 'none'; + helpDiv.id = 'floating_help_text_div'; + helpText = document.createTextNode(''); + helpDiv.style.position = 'absolute'; + helpDiv.appendChild(helpText); + document.body.appendChild(helpDiv); + } else { + helpDiv = document.getElementById('floating_help_text_div'); + } + if(getElementsByClassName('hoverHelpText', this, 'span')[0].childNodes[0]) { + helpDiv.childNodes[0].data = getElementsByClassName('hoverHelpText', this, 'span')[0].childNodes[0].data; + helpDiv.style.borderWidth = '1px'; + if(document.body.clientWidth - cursor.x < cursor.x) { + helpDiv.style.left = ''; + helpDiv.style.right = (document.body.clientWidth - cursor.x + 5) + 'px'; + } else { + helpDiv.style.left = (cursor.x + 5) + 'px'; + helpDiv.style.right = ''; + } + helpDiv.style.top = (cursor.y + 5) + 'px'; + helpDiv.style.display = 'block'; + } +} + +function hideHoverHelp() +{ + if(document.getElementById('floating_help_text_div')) { + document.getElementById('floating_help_text_div').style.display = 'none'; + } +} -- GitLab