From 82d607da452465bfafb79d9feeccd1458965157c Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Thu, 23 Jun 2011 15:19:08 -0400 Subject: [PATCH] Attempt to fix single select click issue. --- chosen/chosen.css | 2 ++ chosen/chosen.proto.js | 15 +++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/chosen/chosen.css b/chosen/chosen.css index 75e0f37..d6572b7 100644 --- a/chosen/chosen.css +++ b/chosen/chosen.css @@ -285,6 +285,8 @@ div.chzn-container-active a.chzn-single { div.chzn-container-active a.chzn-single-with-drop { border: 1px solid #BBB; border-width: 1px 1px 1px; + -moz-box-shadow: 0px 1px 0px #FFF inset; + -webkit-box-shadow: 0px 1px 0px #FFF inset; box-shadow: 0px 1px 0px #FFF inset; background: #EEE; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee)); diff --git a/chosen/chosen.proto.js b/chosen/chosen.proto.js index f384694..8ca2019 100644 --- a/chosen/chosen.proto.js +++ b/chosen/chosen.proto.js @@ -96,7 +96,6 @@ Chosen.prototype = { if( !this.is_multiple ){ this.search_container = this.container.down('div.chzn-search'); this.selected_item = this.container.down('.chzn-single'); - this.selected_item.observe("click", this.results_toggle.bindAsEventListener(this)); var sf_width = (dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field)); this.search_field.setStyle( {"width" : sf_width + "px"} ); } @@ -139,13 +138,17 @@ Chosen.prototype = { }, container_click: function(evt){ - if(evt && evt.type=="click"){ evt.preventDefault(); } + if(evt && evt.type=="click"){ evt.stop(); } if( !this.pending_destroy_click ){ if(!this.active_field){ if(this.is_multiple){ this.search_field.clear(); } document.observe("click", this.click_test_action); this.results_show(); } + else if( !this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))){ + this.results_show(); + } + this.search_field.value = this.search_field.value; this.search_field.focus(); @@ -240,14 +243,6 @@ Chosen.prototype = { this.winnow_results(); }, - results_toggle: function(evt){ - evt.preventDefault(); - if( this.active_field ){ - if( this.results_showing ){ this.results_hide(); } - else{ this.results_show(); } - } - }, - results_hide: function(){ if( !this.is_multiple ){ this.selected_item.removeClassName('chzn-single-with-drop'); } this.result_clear_highlight();