Commit eeba2309d8a9ea8defaeb5cd3f34e6b0fe98f401

Authored by Neil Blakey-Milner
1 parent af784f7f

Allow users to press Enter to search in the navbar.

Submitted by:	Nicolas Quienot


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3196 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 17 additions and 1 deletions
lib/visualpatterns/NavBar.inc
@@ -259,7 +259,8 @@ class NavBar { @@ -259,7 +259,8 @@ class NavBar {
259 if ((strcmp($this->sSection,"Standard Search") == 0) || (strcmp($this->sSection,"Advanced Search") == 0)) { 259 if ((strcmp($this->sSection,"Standard Search") == 0) || (strcmp($this->sSection,"Advanced Search") == 0)) {
260 $bar .= "<INPUT type=\"hidden\" name=\"fSearchText\"/>\n "; 260 $bar .= "<INPUT type=\"hidden\" name=\"fSearchText\"/>\n ";
261 } else { 261 } else {
262 - $bar .= "<INPUT type=\"text\" name=\"fSearchText\" width=\"30\" height = \"10\" />\n"; 262 + $bar .= "<INPUT type=\"text\" name=\"fSearchText\" width=\"30\" height = \"10\" onKeyPress=\"checkKeyPressed(event,
  263 +validateStandardSearch, '" . $default->rootUrl . "/control.php')\"/>\n";
263 (isset($this->iFolderID) ? $bar .= "<INPUT type=\"hidden\" name=\"fFolderID\" value=\"" . $this->iFolderID . "\" />\n " : $bar .= ""); 264 (isset($this->iFolderID) ? $bar .= "<INPUT type=\"hidden\" name=\"fFolderID\" value=\"" . $this->iFolderID . "\" />\n " : $bar .= "");
264 (isset($this->iDocumentID) ? $bar .= "<INPUT type=\"hidden\" name=\"fDocumentID\" value=\"" . $this->iDocumentID . "\" />\n " : $bar .= ""); 265 (isset($this->iDocumentID) ? $bar .= "<INPUT type=\"hidden\" name=\"fDocumentID\" value=\"" . $this->iDocumentID . "\" />\n " : $bar .= "");
265 (isset($this->sCategoryName) ? $bar .= "<INPUT type=\"hidden\" name=\"fCategoryName\" value=\"" . $this->sCategoryName . "\" />\n " : $bar .= ""); 266 (isset($this->sCategoryName) ? $bar .= "<INPUT type=\"hidden\" name=\"fCategoryName\" value=\"" . $this->sCategoryName . "\" />\n " : $bar .= "");
@@ -288,6 +289,21 @@ class NavBar { @@ -288,6 +289,21 @@ class NavBar {
288 function getSearchValidationJavaScript() { 289 function getSearchValidationJavaScript() {
289 $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n "; 290 $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
290 $sToRender .= "<!--\n"; 291 $sToRender .= "<!--\n";
  292 +
  293 + $sToRender .= '
  294 +// From http://www.severnsolutions.co.uk/twblog/archive/2003/09/14/keypressevents
  295 +function checkKeyPressed(evt, func, params)
  296 +{
  297 + evt = (evt) ? evt : (window.event) ? event : null;
  298 + if (evt)
  299 + {
  300 + var charCode = (evt.charCode) ? evt.charCode :
  301 + ((evt.keyCode) ? evt.keyCode :
  302 + ((evt.which) ? evt.which : 0));
  303 + if (charCode == 13) func(params);
  304 + }
  305 +}';
  306 +
291 $sToRender .= "function validateStandardSearch(newAction) {\n"; 307 $sToRender .= "function validateStandardSearch(newAction) {\n";
292 $sToRender .= "\tif (!(validRequired(document.MainForm.fSearchText, 'Search text'))) {\n"; 308 $sToRender .= "\tif (!(validRequired(document.MainForm.fSearchText, 'Search text'))) {\n";
293 $sToRender .= "\t\treturn false;\n\t}\n"; 309 $sToRender .= "\t\treturn false;\n\t}\n";