From 7e787cca760cbc15334dbc5707edf91175082283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Perrin?= Date: Tue, 9 Feb 2016 18:00:16 +0100 Subject: [PATCH] Compile JS versions --- lib/ajax-chosen.js | 35 ++++++++++++++++++----------------- lib/ajax-chosen.min.js | 11 +++++------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/ajax-chosen.js b/lib/ajax-chosen.js index 5b6073d..538cae2 100644 --- a/lib/ajax-chosen.js +++ b/lib/ajax-chosen.js @@ -1,5 +1,4 @@ -// Generated by CoffeeScript 1.6.1 - +// Generated by CoffeeScript 1.10.0 (function($) { var ajaxChosen, defaultOptions; defaultOptions = { @@ -10,10 +9,9 @@ lookingForMsg: "Looking for" }; return ajaxChosen = (function() { - - function ajaxChosen(element, settings, callback, chosenOptions) { + function ajaxChosen(element1, settings, callback, chosenOptions) { var chosenXhr; - this.element = element; + this.element = element1; chosenXhr = null; this.callback_function = callback; this.options = $.extend({}, defaultOptions, this.element.data(), settings); @@ -24,13 +22,16 @@ } ajaxChosen.prototype.register_observers = function() { - var _this = this; - this.search_field.keyup(function(evt) { - _this.update_list(evt); - }); - return this.search_field.focus(function(evt) { - _this.search_field_focused(evt); - }); + this.search_field.keyup((function(_this) { + return function(evt) { + _this.update_list(evt); + }; + })(this)); + return this.search_field.focus((function(_this) { + return function(evt) { + _this.search_field_focused(evt); + }; + })(this)); }; ajaxChosen.prototype.search_field_focused = function(evt) { @@ -40,8 +41,7 @@ }; ajaxChosen.prototype.update_list = function(evt) { - var msg, options, val, _this; - this.untrimmed_val = this.search_field.val(); + var _this, msg, options, val; val = $.trim(this.search_field.val()); msg = val.length < this.options.minTermLength ? this.options.keepTypingMsg : this.options.lookingForMsg + (" '" + val + "'"); this.element.next('.chosen-container').find('.no-results').text(msg); @@ -76,7 +76,7 @@ }; ajaxChosen.prototype.show_results = function(data) { - var items, nbItems, selected_values, _this; + var _this, items, nbItems, selected_values, val_before_trigger; if (data == null) { return; } @@ -130,15 +130,16 @@ } }); if (nbItems) { + val_before_trigger = this.search_field.val(); this.element.trigger("chosen:updated"); + this.search_field.val(val_before_trigger); } else { this.element.data().chosen.no_results_clear(); this.element.data().chosen.no_results(this.search_field.val()); } if (this.success != null) { - this.success(data); + return this.success(data); } - return this.search_field.val(this.untrimmed_val); }; $.fn.ajaxChosen = function(options, callback, chosenOptions) { diff --git a/lib/ajax-chosen.min.js b/lib/ajax-chosen.min.js index 4eda0b4..65bba12 100644 --- a/lib/ajax-chosen.min.js +++ b/lib/ajax-chosen.min.js @@ -1,17 +1,16 @@ -(function($){var ajaxChosen,defaultOptions;defaultOptions={minTermLength:3,afterTypeDelay:500,jsonTermKey:"term",keepTypingMsg:"Keep typing...",lookingForMsg:"Looking for"};return ajaxChosen=(function(){function ajaxChosen(element,settings,callback,chosenOptions){var chosenXhr;this.element=element;chosenXhr=null;this.callback_function=callback;this.options=$.extend({},defaultOptions,this.element.data(),settings);this.success=settings.success;this.element.chosen(chosenOptions?chosenOptions:{});this.search_field=this.element.next('.chosen-container').find(".search-field > input, .chosen-search > input");this.register_observers();} -ajaxChosen.prototype.register_observers=function(){var _this=this;this.search_field.keyup(function(evt){_this.update_list(evt);});return this.search_field.focus(function(evt){_this.search_field_focused(evt);});};ajaxChosen.prototype.search_field_focused=function(evt){if(this.options.minTermLength===0&&this.search_field.val().length===0){return this.update_list(evt);}};ajaxChosen.prototype.update_list=function(evt){var msg,options,val,_this;this.untrimmed_val=this.search_field.val();val=$.trim(this.search_field.val());msg=val.length input, .chosen-search > input");this.register_observers();} +ajaxChosen.prototype.register_observers=function(){this.search_field.keyup((function(_this){return function(evt){_this.update_list(evt);};})(this));return this.search_field.focus((function(_this){return function(evt){_this.search_field_focused(evt);};})(this));};ajaxChosen.prototype.search_field_focused=function(evt){if(this.options.minTermLength===0&&this.search_field.val().length===0){return this.update_list(evt);}};ajaxChosen.prototype.update_list=function(evt){var _this,msg,options,val;val=$.trim(this.search_field.val());msg=val.length");} group.attr('label',element.text).appendTo(_this.element);return $.each(element.items,function(i,element){var text,value;if(typeof element==="string"){value=i;text=element;}else{value=element.value;text=element.text;} if($.inArray(value+"-"+text,selected_values)===-1){return $("