From 763779586207d469b93c23ec0ba0a4d5b10d35b5 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 4 Jun 2009 20:13:58 +0000
Subject: [PATCH] Various updates to public-view, made comment icons clickable.

---
 .../controllers/PublicViewController.php      |   3 +
 .../views/scripts/public-view/results.phtml   |   3 +-
 .../scripts/public-view/search-box.phtml      |   2 +-
 .../views/scripts/public-view/search.phtml    |   1 -
 .../views/scripts/public-view/view.phtml      |   6 +-
 .../requests/views/scripts/index/index.phtml  |  13 +-
 .../css/courses/public-view/results.css       |   1 -
 .../css/courses/public-view/search-box.css    |   2 +-
 .../javascript/courses/public-view/search.js  | 144 ------------------
 .../javascript/courses/public-view/view.js    |   8 +-
 document_root/javascript/index.js             |  43 ++++++
 11 files changed, 66 insertions(+), 160 deletions(-)
 delete mode 100644 document_root/javascript/courses/public-view/search.js

diff --git a/application/modules/courses/controllers/PublicViewController.php b/application/modules/courses/controllers/PublicViewController.php
index 1271d3df..15073f7b 100644
--- a/application/modules/courses/controllers/PublicViewController.php
+++ b/application/modules/courses/controllers/PublicViewController.php
@@ -398,6 +398,9 @@ class Courses_PublicViewController extends App_Controller_Action {
 	    
 	    $offerings = Courses_ScheduleModel::fetchForCourses($course);
 	
+	    $controllerSession = new Zend_Session_Namespace(__CLASS__);
+	    $this->view->recentSearchCriteria = $controllerSession->recentSearchCriteria;
+	    
 	    $session = new Zend_Session_Namespace(__CLASS__ . __METHOD__);
 	    
 	    // sort offerings
diff --git a/application/modules/courses/views/scripts/public-view/results.phtml b/application/modules/courses/views/scripts/public-view/results.phtml
index 77247fae..2658dfab 100644
--- a/application/modules/courses/views/scripts/public-view/results.phtml
+++ b/application/modules/courses/views/scripts/public-view/results.phtml
@@ -1,5 +1,6 @@
 <?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/courses/public-view/results.css', 'all'); ?>
-<?php $this->headScript()->appendFile($this->baseUrl() . '/javascript/courses/public-view/results.js'); ?>
+<?php $this->layout()->breadcrumbs = array('Curriculum Search'); ?>
+<?php $this->layout()->tagline = 'Curriculum Search'; ?>
 <?php $this->layout()->hideMenu = true; ?>
 
 
diff --git a/application/modules/courses/views/scripts/public-view/search-box.phtml b/application/modules/courses/views/scripts/public-view/search-box.phtml
index 9730c341..5ebcef12 100644
--- a/application/modules/courses/views/scripts/public-view/search-box.phtml
+++ b/application/modules/courses/views/scripts/public-view/search-box.phtml
@@ -2,7 +2,7 @@
 <?php $this->headScript()->appendFile($this->baseUrl() . '/javascript/courses/public-view/search-box.js'); ?>
 
 <div class="helpText">
-    Begin your search by entering or selecting information in at least<br /> on of the following fields:
+    Begin your search by entering or selecting information in at least<br /> one of the following fields:
 </div>
 
 <?php if (!$this->searchBoxFull) { ?>
diff --git a/application/modules/courses/views/scripts/public-view/search.phtml b/application/modules/courses/views/scripts/public-view/search.phtml
index 0069a4b9..a638c95f 100644
--- a/application/modules/courses/views/scripts/public-view/search.phtml
+++ b/application/modules/courses/views/scripts/public-view/search.phtml
@@ -1,5 +1,4 @@
 <?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/courses/public-view/search.css', 'all'); ?>
-<?php $this->headScript()->appendFile($this->baseUrl() . '/javascript/courses/public-view/search.js'); ?>
 <?php $this->layout()->breadcrumbs = array('Curriculum Search'); ?>
 <?php $this->layout()->tagline = 'Curriculum Search'; ?>
 <?php $this->layout()->hideMenu = true; ?>
diff --git a/application/modules/courses/views/scripts/public-view/view.phtml b/application/modules/courses/views/scripts/public-view/view.phtml
index 64a9b7e5..8016e993 100644
--- a/application/modules/courses/views/scripts/public-view/view.phtml
+++ b/application/modules/courses/views/scripts/public-view/view.phtml
@@ -8,8 +8,10 @@
 
     <div id="printAndBackButtons">
         <button id="printButton">Print</button><br />
-        <button id="backToResultsButton">Back to Results</button><br />
-        <button id="returnToHistoryButton">Back to Request History</button>
+        <?php if ($this->recentSearchCriteria) { ?>
+        <button id="backToResultsButton" rel="<?php echo $this->url(array_merge($this->recentSearchCriteria, array('module' => 'courses', 'controller' => 'public-view', 'action' => 'search')), null, true); ?>">Search Results</button><br />
+        <?php } ?>
+        <button id="returnToHistoryButton">Request History</button>
     </div>
     
     <div id="courseDescription">
diff --git a/application/modules/requests/views/scripts/index/index.phtml b/application/modules/requests/views/scripts/index/index.phtml
index 41b605b4..024074d7 100644
--- a/application/modules/requests/views/scripts/index/index.phtml
+++ b/application/modules/requests/views/scripts/index/index.phtml
@@ -203,7 +203,9 @@
                     }
                     if ($newCommentCount > 0) {
                     ?>
-                    <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                    <a class="requestLink<?php echo $linkClass; ?>" href="<?php echo $this->baseUrl(); ?>/requests/view/index/id/<?php echo $request->getId(); ?>">
+                        <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                    </a>
                     <?php
                         echo $newCommentCount;
                     }
@@ -353,7 +355,10 @@ foreach($this->roles as $roleData) {
 	                    }
 	                    if ($newCommentCount > 0) {
 	                    ?>
-	                    <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                        <a class="requestLink<?php echo $linkClass; ?>"
+                           href="<?php echo $this->baseUrl(); ?>/requests/view/index/id/<?php echo $request->getId(); ?>/role/<?php echo $role->getId(); ?>/list/normal">
+	                       <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                        </a>
 	                    <?php
 	                        echo $newCommentCount;
 	                    }
@@ -435,7 +440,9 @@ foreach($this->roles as $roleData) {
                     }
                     if ($newCommentCount > 0) {
                     ?>
-                    <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                    <a class="requestLink<?php echo $linkClass; ?>" href="<?php echo $this->baseUrl(); ?>/requests/view/index/id/<?php echo $request->getId(); ?>/role/<?php echo $role->getId(); ?>/list/watching">
+                        <img src="<?php echo $this->baseUrl(); ?>/images/requests/commentIcon.png" alt="comments" />
+                    </a>
                     <?php
                         echo $newCommentCount;
                     }
diff --git a/document_root/css/courses/public-view/results.css b/document_root/css/courses/public-view/results.css
index 82764a31..4dd58302 100644
--- a/document_root/css/courses/public-view/results.css
+++ b/document_root/css/courses/public-view/results.css
@@ -7,7 +7,6 @@
     #instructions {display: none;}
 }
 
-#results table {color: #a00; text-align: center;}
 #results table th {background-color: #aaa; padding: 0.3em 0.5em; white-space: nowrap;}
 #results table tr.even {background-color: #ddd;}
 #results table td {padding: 0.5em 0.5em;}
diff --git a/document_root/css/courses/public-view/search-box.css b/document_root/css/courses/public-view/search-box.css
index f2e330a5..f79dec11 100644
--- a/document_root/css/courses/public-view/search-box.css
+++ b/document_root/css/courses/public-view/search-box.css
@@ -18,7 +18,7 @@
 #searchFormSmall #activity {width: 100px;} 
 #courseLetter {width: 45px;}
 #aceOutcomes {height: 4em; vertical-align: top;}
-#submit {height: 25px; padding: 0px 1em; color: #fff; font-size: 14px; background-image: url(../../../images/redBlackGrad.png); border: 1px solid #000; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; margin: 0px auto; display: block;}
+#submit {height: 25px; padding: 0px 1em; color: #fff; font-size: 14px; background-image: url(../../../images/redBlackGrad.png); border: 1px solid #000; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; margin: 1em auto; display: block;}
 #reset {display: block; margin: 0.5em auto; color: #c00; border: 0px solid #000; background-color: transparent; }
 
 
diff --git a/document_root/javascript/courses/public-view/search.js b/document_root/javascript/courses/public-view/search.js
deleted file mode 100644
index 6f0ac93e..00000000
--- a/document_root/javascript/courses/public-view/search.js
+++ /dev/null
@@ -1,144 +0,0 @@
-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();
-    }
-}
-
-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';
-    }
-}
diff --git a/document_root/javascript/courses/public-view/view.js b/document_root/javascript/courses/public-view/view.js
index be28eb9d..3bdb4e13 100644
--- a/document_root/javascript/courses/public-view/view.js
+++ b/document_root/javascript/courses/public-view/view.js
@@ -2,13 +2,9 @@ addLoadEvent(onLoadPublicView);
 
 function onLoadPublicView()
 {
-    if (document.getElementById('refineSearchLink')) {
-        document.getElementById('refineSearchLink').onclick = function() {
-            location.href = document.getElementById('refineSearchLink').getAttribute("rel");
-        };
-
+    if (document.getElementById('backToResultsButton')) {
         document.getElementById('backToResultsButton').onclick = function() {
-            history.go(-1);
+            location.href = document.getElementById('backToResultsButton').getAttribute("rel");
         };
     }
     
diff --git a/document_root/javascript/index.js b/document_root/javascript/index.js
index 9a8b8801..05ce0b9b 100644
--- a/document_root/javascript/index.js
+++ b/document_root/javascript/index.js
@@ -346,6 +346,49 @@ Array.prototype.inArray = function (value)
 
 
 
+/* Code for the following function borrowed from http://www.electrictoolbox.com/javascript-clear-form/ */
+
+function clearForm(ele) {
+
+    tags = ele.getElementsByTagName('input');
+    for(i = 0; i < tags.length; i++) {
+        switch(tags[i].type) {
+            case 'password':
+            case 'text':
+                tags[i].value = '';
+                break;
+            case 'checkbox':
+            case 'radio':
+                tags[i].checked = false;
+                break;
+        }
+    }
+   
+    tags = ele.getElementsByTagName('select');
+    for(i = 0; i < tags.length; i++) {
+        if(tags[i].type == 'select-one') {
+            tags[i].selectedIndex = 0;
+        }
+        else {
+            for(j = 0; j < tags[i].options.length; j++) {
+                tags[i].options[j].selected = false;
+            }
+        }
+    }
+
+    tags = ele.getElementsByTagName('textarea');
+    for(i = 0; i < tags.length; i++) {
+        tags[i].value = '';
+    }
+   
+}
+
+/* End borrowed code */
+
+
+
+
+
 
 
 
-- 
GitLab