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 259 if ((strcmp($this->sSection,"Standard Search") == 0) || (strcmp($this->sSection,"Advanced Search") == 0)) {
260 260 $bar .= "<INPUT type=\"hidden\" name=\"fSearchText\"/>\n ";
261 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 264 (isset($this->iFolderID) ? $bar .= "<INPUT type=\"hidden\" name=\"fFolderID\" value=\"" . $this->iFolderID . "\" />\n " : $bar .= "");
264 265 (isset($this->iDocumentID) ? $bar .= "<INPUT type=\"hidden\" name=\"fDocumentID\" value=\"" . $this->iDocumentID . "\" />\n " : $bar .= "");
265 266 (isset($this->sCategoryName) ? $bar .= "<INPUT type=\"hidden\" name=\"fCategoryName\" value=\"" . $this->sCategoryName . "\" />\n " : $bar .= "");
... ... @@ -288,6 +289,21 @@ class NavBar {
288 289 function getSearchValidationJavaScript() {
289 290 $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
290 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 307 $sToRender .= "function validateStandardSearch(newAction) {\n";
292 308 $sToRender .= "\tif (!(validRequired(document.MainForm.fSearchText, 'Search text'))) {\n";
293 309 $sToRender .= "\t\treturn false;\n\t}\n";
... ...