From 40cf9835eecbbacb2ae8be602e9f6d18be4393a0 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 19 Sep 2011 09:11:38 -0400
Subject: [PATCH] Fixed bug that caused the wrong list to be loaded when the return key was pressed in a search text field of a list.

---
 interface/web/themes/default_combobox/templates/main.tpl.htm |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/interface/web/themes/default_combobox/templates/main.tpl.htm b/interface/web/themes/default_combobox/templates/main.tpl.htm
index 0e38072..6c1b46d 100644
--- a/interface/web/themes/default_combobox/templates/main.tpl.htm
+++ b/interface/web/themes/default_combobox/templates/main.tpl.htm
@@ -6,7 +6,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=<tmpl_var name="html_content_encoding">"/>
 	<meta http-equiv="X-UA-Compatible" content="IE=8"/>
     <link href="themes/default/css/central.css" rel="stylesheet" type="text/css"/>
-    <link href="themes/default/css/screen/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css"/>
+    <link href="themes/default_combobox/css/additional.css" rel="stylesheet" type="text/css"/>
     <!--[if lte IE 7]>
 	    <link href="themes/default/css/patches/central.css" rel="stylesheet" type="text/css" />
     <![endif]-->
@@ -67,10 +67,17 @@
 			document.getElementsByTagName("head")[0].appendChild(style);
 		}
 
+
 		jQuery(document).ready(function() {
 			loadInitContent();
 		});
 
+		jQuery(document).bind("change", function(event) {
+			if ($(".panel #Filter").length > 0 && event.target.localName == 'select') {
+				$(".panel #Filter").attr("onsubmit",$(".panel #Filter").attr("onclick")).submit();
+			}
+		});
+		
 		//Use jQuery submit with kespress Enter in panel filterbar
 		jQuery(document).bind("keypress", function(event) {
 			if (event.which == '13' && $(".panel #Filter").length > 0) {
@@ -78,20 +85,19 @@
 			}
 		});
 
-// 		jQuery(document).ready( function(){
-// 		  
-// 		});
-
 		(function( $ ) {
 		$.widget( "ui.combobox", {
 			_create: function() {
 				var self = this,
+					oldWidth = this.element.width(),
 					select = this.element.hide(),
 					selected = select.children( ":selected" ),
 					value = selected.val() ? selected.text() : "";
 				var input = this.input = $( "<input>" )
 					.insertAfter( select )
+					.width( oldWidth )
 					.val( value )
+					.css("float","left")
 					.autocomplete({
 						delay: 0,
 						minLength: 0,
@@ -99,7 +105,7 @@
 							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
 							response( select.children( "option" ).map(function() {
 								var text = $( this ).text();
-								if ( this.value && ( !request.term || matcher.test(text) ) )
+								if (( !request.term || matcher.test(text) ) )
 									return {
 										label: text.replace(
 											new RegExp(
@@ -136,7 +142,19 @@
 									return false;
 								}
 							}
-						}
+						},
+						// open: function(event, ui) { }, alternativ event for check by enter input
+						search: function(event, ui) {
+							if ( !ui.item ) {
+								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+									valid = false;
+								select.children( "option" ).each(function() {
+									if ( $( this ).text().match( matcher ) ) {
+										this.selected = valid = true;
+										return false;
+									}
+								});
+							} }
 					})
 					.addClass( "ui-widget ui-widget-content ui-corner-left" );
 
@@ -150,6 +168,8 @@
 				this.button = $( "<button type='button'>&nbsp;</button>" )
 					.attr( "tabIndex", -1 )
 					.attr( "title", "Show All Items" )
+					.height($(input).outerHeight())
+					.css("float","left")
 					.insertAfter( input )
 					.button({
 						icons: {
@@ -183,10 +203,11 @@
 			}
 		});
 	})( jQuery );
+ 
 
-	jQuery("#pageContent").live("blur" function(){
-	  if(jQuery(".panel select").css("display") != "none"){
-	    jQuery(".panel select").combobox();
+	jQuery("body").live("mouseover", function(){
+	  if(jQuery(".panel .list td select").css("display") != "none"){
+	    jQuery(".panel .list td select").combobox();
 	  }
 	});
 	</script>

--
Gitblit v1.9.1