Use coffeesript's built-in function binding on setTimeouts
This commit is contained in:
parent
1ddf68baf0
commit
d3b14656ea
|
@ -152,22 +152,18 @@
|
||||||
return this.mouse_on_container = false;
|
return this.mouse_on_container = false;
|
||||||
};
|
};
|
||||||
Chosen.prototype.input_focus = function(evt) {
|
Chosen.prototype.input_focus = function(evt) {
|
||||||
var binding;
|
|
||||||
binding = this;
|
|
||||||
if (!this.active_field) {
|
if (!this.active_field) {
|
||||||
return setTimeout((function() {
|
return setTimeout((__bind(function() {
|
||||||
return binding.container_click();
|
return this.container_click();
|
||||||
}), 50);
|
}, this)), 50);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Chosen.prototype.input_blur = function(evt) {
|
Chosen.prototype.input_blur = function(evt) {
|
||||||
var binding;
|
|
||||||
if (!this.mouse_on_container) {
|
if (!this.mouse_on_container) {
|
||||||
this.active_field = false;
|
this.active_field = false;
|
||||||
binding = this;
|
return setTimeout((__bind(function() {
|
||||||
return setTimeout((function() {
|
return this.blur_test();
|
||||||
return binding.blur_test();
|
}, this)), 100);
|
||||||
}), 100);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Chosen.prototype.blur_test = function(evt) {
|
Chosen.prototype.blur_test = function(evt) {
|
||||||
|
|
|
@ -129,14 +129,12 @@ class Chosen
|
||||||
mouse_leave: -> @mouse_on_container = false
|
mouse_leave: -> @mouse_on_container = false
|
||||||
|
|
||||||
input_focus: (evt) ->
|
input_focus: (evt) ->
|
||||||
binding = this
|
setTimeout (=> this.container_click()), 50 unless @active_field
|
||||||
setTimeout (-> binding.container_click()), 50 unless @active_field
|
|
||||||
|
|
||||||
input_blur: (evt) ->
|
input_blur: (evt) ->
|
||||||
if not @mouse_on_container
|
if not @mouse_on_container
|
||||||
@active_field = false
|
@active_field = false
|
||||||
binding = this
|
setTimeout (=> this.blur_test()), 100
|
||||||
setTimeout (-> binding.blur_test()), 100
|
|
||||||
|
|
||||||
blur_test: (evt) ->
|
blur_test: (evt) ->
|
||||||
this.close_field() if not @active_field and @container.hasClass "chzn-container-active"
|
this.close_field() if not @active_field and @container.hasClass "chzn-container-active"
|
||||||
|
|
Loading…
Reference in a new issue