vendor/assets/javascripts/chosen.proto.coffee in chosen-rails-1.0.2 vs vendor/assets/javascripts/chosen.proto.coffee in chosen-rails-1.1.0

- old
+ new

@@ -71,18 +71,20 @@ @search_field.observe "blur", (evt) => this.input_blur(evt) @search_field.observe "keyup", (evt) => this.keyup_checker(evt) @search_field.observe "keydown", (evt) => this.keydown_checker(evt) @search_field.observe "focus", (evt) => this.input_focus(evt) + @search_field.observe "cut", (evt) => this.clipboard_event_checker(evt) + @search_field.observe "paste", (evt) => this.clipboard_event_checker(evt) if @is_multiple @search_choices.observe "click", (evt) => this.choices_click(evt) else @container.observe "click", (evt) => evt.preventDefault() # gobble click of anchor destroy: -> - document.stopObserving "click", @click_test_action + @container.ownerDocument.stopObserving "click", @click_test_action @form_field.stopObserving() @container.stopObserving() @search_results.stopObserving() @search_field.stopObserving() @@ -119,11 +121,11 @@ evt.stop() if not (evt? and evt.target.hasClassName "search-choice-close") if not @active_field @search_field.clear() if @is_multiple - document.observe "click", @click_test_action + @container.ownerDocument.observe "click", @click_test_action this.results_show() else if not @is_multiple and evt and (evt.target is @selected_item || evt.target.up("a.chosen-single")) this.results_toggle() this.activate_field() @@ -140,11 +142,11 @@ blur_test: (evt) -> this.close_field() if not @active_field and @container.hasClassName("chosen-container-active") close_field: -> - document.stopObserving "click", @click_test_action + @container.ownerDocument.stopObserving "click", @click_test_action @active_field = false this.results_hide() @container.removeClassName "chosen-container-active" @@ -217,18 +219,17 @@ if @is_multiple and @max_selected_options <= this.choices_count() @form_field.fire("chosen:maxselected", {chosen: this}) return false @container.addClassName "chosen-with-drop" - @form_field.fire("chosen:showing_dropdown", {chosen: this}) - @results_showing = true @search_field.focus() @search_field.value = @search_field.value this.winnow_results() + @form_field.fire("chosen:showing_dropdown", {chosen: this}) update_results_content: (content) -> @search_results.update content results_hide: -> @@ -398,9 +399,10 @@ this.result_do_highlight do_high if do_high? no_results: (terms) -> @search_results.insert @no_results_temp.evaluate( terms: terms ) + @form_field.fire("chosen:no_results", {chosen: this}) no_results_clear: -> nr = null nr.remove() while nr = @search_results.down(".no-results")