1
0
mirror of synced 2024-11-22 21:16:10 +03:00

Changed event handlers. Fixes #70

Changed to mouseup for displaying options.
Changed to mousedown for selecting options.

Signed-off-by: Igor Vaynberg <igor.vaynberg@gmail.com>
This commit is contained in:
Kevin Brown 2012-07-28 20:09:46 -04:00 committed by Igor Vaynberg
parent f2460a826e
commit 61603dacc0

View File

@ -1,4 +1,4 @@
/* /*
Copyright 2012 Igor Vaynberg Copyright 2012 Igor Vaynberg
Version: @@ver@@ Timestamp: @@timestamp@@ Version: @@ver@@ Timestamp: @@timestamp@@
@ -521,7 +521,7 @@
search.bind("focus", function () { search.addClass("select2-focused"); if (search.val() === " ") search.val(""); }); search.bind("focus", function () { search.addClass("select2-focused"); if (search.val() === " ") search.val(""); });
search.bind("blur", function () { search.removeClass("select2-focused");}); search.bind("blur", function () { search.removeClass("select2-focused");});
this.dropdown.delegate(resultsSelector, "click", this.bind(function (e) { this.dropdown.delegate(resultsSelector, "mouseup", this.bind(function (e) {
if ($(e.target).closest(".select2-result-selectable:not(.select2-disabled)").length > 0) { if ($(e.target).closest(".select2-result-selectable:not(.select2-disabled)").length > 0) {
this.highlightUnderEvent(e); this.highlightUnderEvent(e);
this.selectHighlighted(e); this.selectHighlighted(e);
@ -1305,7 +1305,7 @@
window.setTimeout(this.bind(function() { this.selection.attr("tabIndex", this.opts.element.attr("tabIndex")); }), 10); window.setTimeout(this.bind(function() { this.selection.attr("tabIndex", this.opts.element.attr("tabIndex")); }), 10);
})); }));
selection.bind("click", this.bind(function (e) { selection.bind("mousedown", this.bind(function (e) {
clickingInside = true; clickingInside = true;
if (this.opened()) { if (this.opened()) {
@ -1319,7 +1319,7 @@
clickingInside = false; clickingInside = false;
})); }));
dropdown.bind("click", this.bind(function() { this.search.focus(); })); dropdown.bind("mousedown", this.bind(function() { this.search.focus(); }));
selection.bind("focus", this.bind(function() { selection.bind("focus", this.bind(function() {
this.container.addClass("select2-container-active"); this.container.addClass("select2-container-active");
@ -1372,7 +1372,7 @@
killEvent(e); killEvent(e);
})); }));
selection.delegate("abbr", "click", this.bind(function (e) { selection.delegate("abbr", "mousedown", this.bind(function (e) {
if (!this.enabled) return; if (!this.enabled) return;
this.clear(); this.clear();
killEvent(e); killEvent(e);
@ -1685,7 +1685,7 @@
this.container.removeClass("select2-container-active"); this.container.removeClass("select2-container-active");
})); }));
this.container.delegate(selector, "click", this.bind(function (e) { this.container.delegate(selector, "mousedown", this.bind(function (e) {
if (!this.enabled) return; if (!this.enabled) return;
this.clearPlaceholder(); this.clearPlaceholder();
this.open(); this.open();