From d3b14656ea856095db3dc6b4aca9ab400beda2bc Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Wed, 20 Jul 2011 11:06:59 -0400 Subject: [PATCH] Use coffeesript's built-in function binding on setTimeouts --- chosen/chosen.jquery.js | 16 ++++++---------- coffee/chosen.jquery.coffee | 6 ++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/chosen/chosen.jquery.js b/chosen/chosen.jquery.js index b43bc4e..796db6a 100644 --- a/chosen/chosen.jquery.js +++ b/chosen/chosen.jquery.js @@ -152,22 +152,18 @@ return this.mouse_on_container = false; }; Chosen.prototype.input_focus = function(evt) { - var binding; - binding = this; if (!this.active_field) { - return setTimeout((function() { - return binding.container_click(); - }), 50); + return setTimeout((__bind(function() { + return this.container_click(); + }, this)), 50); } }; Chosen.prototype.input_blur = function(evt) { - var binding; if (!this.mouse_on_container) { this.active_field = false; - binding = this; - return setTimeout((function() { - return binding.blur_test(); - }), 100); + return setTimeout((__bind(function() { + return this.blur_test(); + }, this)), 100); } }; Chosen.prototype.blur_test = function(evt) { diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index af52c4f..2ff4a10 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -129,14 +129,12 @@ class Chosen mouse_leave: -> @mouse_on_container = false input_focus: (evt) -> - binding = this - setTimeout (-> binding.container_click()), 50 unless @active_field + setTimeout (=> this.container_click()), 50 unless @active_field input_blur: (evt) -> if not @mouse_on_container @active_field = false - binding = this - setTimeout (-> binding.blur_test()), 100 + setTimeout (=> this.blur_test()), 100 blur_test: (evt) -> this.close_field() if not @active_field and @container.hasClass "chzn-container-active"