From e5df3d81adbfcb3017e80226fce42c5304f26d7e Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sat, 26 Jan 2013 16:17:58 +0100 Subject: [PATCH] Bug fixes (selection on in the proposals). see #333 --- modoboa/static/js/autocompleter.js | 39 ++++++++++++++++-------------- modoboa/static/js/history.js | 1 - 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/modoboa/static/js/autocompleter.js b/modoboa/static/js/autocompleter.js index 534f21d42..1448e3ba3 100644 --- a/modoboa/static/js/autocompleter.js +++ b/modoboa/static/js/autocompleter.js @@ -82,26 +82,29 @@ }, select_entry: function(evt) { - var $link; - if (evt != undefined) { - evt.preventDefault(); - $link = $(evt.target); - } else { - $link = this.$menu.find('.active > a'); - } - var curvalue = this.$element.attr("value"); - - if (curvalue == undefined || curvalue == "") { - if (this.options.empty_choice) { - this.options.empty_choice(); + if (this.$menu.is(":visible")) { + var $link; + if (evt != undefined) { + evt.preventDefault(); + $link = $(evt.target); + } else { + $link = this.$menu.find('.active > a'); } - return; - } + var curvalue = this.$element.attr("value"); - this.$element.attr("value", curvalue.substr( - 0, curvalue.indexOf(this.options.from_character) + 1 - ) + $link.attr("name")); - this.hide_menu(); + if (curvalue == undefined || curvalue == "") { + if (this.options.empty_choice) { + this.options.empty_choice(); + } + return; + } + if ($link.length) { + this.$element.attr("value", curvalue.substr( + 0, curvalue.indexOf(this.options.from_character) + 1 + ) + $link.attr("name")); + } + this.hide_menu(); + } if (this.options.choice_selected) { this.options.choice_selected(this.$element.attr('value')); } diff --git a/modoboa/static/js/history.js b/modoboa/static/js/history.js index 3b4f7202f..562aa4605 100644 --- a/modoboa/static/js/history.js +++ b/modoboa/static/js/history.js @@ -213,7 +213,6 @@ History.prototype = { check: function() { var rawhash = this.get_raw_hash(); - if (this.serialized == rawhash && this.force === undefined) { return; }