Permalink
Browse files

show_create_option is now only called from winnow_results

  • Loading branch information...
1 parent 2b6bc61 commit 39aff7b3e6429b4efa218c02c951cf4e5a83fd85 @koenpunt committed May 11, 2013

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -327,7 +327,7 @@ class Chosen extends AbstractChosen
if @result_highlight
high = @result_highlight
- if high.hasClass 'create-option'
+ if high.hasClass "create-option"
this.select_create_option(@search_field.val())
return this.results_hide()
@@ -409,9 +409,6 @@ class Chosen extends AbstractChosen
no_results_html.find("span").first().html(terms)
@search_results.append no_results_html
- if @create_option
- this.show_create_option( terms )
-
show_create_option: (terms) ->
create_option_html = $('<li class="create-option active-result"><a href="javascript:void(0);">' + @create_option_text + '</a>: "' + terms + '"</li>')
@search_results.append create_option_html
@@ -324,7 +324,7 @@ class @Chosen extends AbstractChosen
if @result_highlight
high = @result_highlight
- if high.hasClassName 'create-option'
+ if high.hasClassName "create-option"
this.select_create_option(@search_field.value)
return this.results_hide()
@@ -410,9 +410,6 @@ class @Chosen extends AbstractChosen
@search_results.insert no_results_html
- if @create_option
- this.show_create_option( terms )
-
show_create_option: (terms) ->
create_option_html = @create_option_temp.evaluate( terms: terms, text: @create_option_text )
@search_results.insert create_option_html
@@ -183,6 +183,9 @@ class AbstractChosen
this.update_results_content this.results_option_build()
this.winnow_results_set_highlight()
+ if @create_option and (results < 1 or (exact_result and @persistent_create_option)) and searchText.length
+ this.show_create_option( searchText )
+
search_string_match: (search_string, regex) ->
if regex.test search_string
return true

0 comments on commit 39aff7b

Please sign in to comment.