Skip to content
Browse files

Add an option to configure the select_all_options text

I've also included a change to the help docs to make select_all_options
easier to test
  • Loading branch information...
1 parent f301b10 commit b6a69f44f76f0eedeb4527cd9bfe391a48c845d5 @Pezmc Pezmc committed May 28, 2015
Showing with 41 additions and 2 deletions.
  1. +1 −1 coffee/chosen.jquery.coffee
  2. +1 −1 coffee/chosen.proto.coffee
  3. +2 −0 coffee/lib/abstract-chosen.coffee
  4. +37 −0 public/index.html
View
2 coffee/chosen.jquery.coffee
@@ -249,7 +249,7 @@ class Chosen extends AbstractChosen
select_all_setup: ->
@select_all_link = $("<a />", { class: "chzn-select-all" })
- .html("Select all options")
+ .html(@select_all_results)
.click((evt) => this.select_all_options(evt))
@dropdown.append(@select_all_link)
View
2 coffee/chosen.proto.coffee
@@ -243,7 +243,7 @@ class @Chosen extends AbstractChosen
@results_showing = false
select_all_setup: ->
- @dropdown.insert(@select_all_temp.evaluate({ "copy": "Select all options" }))
+ @dropdown.insert(@select_all_temp.evaluate({ "copy": @select_all_results }))
@select_all_link = @dropdown.down(".chzn-select-all")
@select_all_link.observe("click", (evt) => this.select_all_options(evt))
View
2 coffee/lib/abstract-chosen.coffee
@@ -46,6 +46,7 @@ class AbstractChosen
@default_text = @options.placeholder_text_single || @options.placeholder_text || AbstractChosen.default_single_text
@results_none_found = @form_field.getAttribute("data-no_results_text") || @options.no_results_text || AbstractChosen.default_no_result_text
+ @select_all_results = @form_field.getAttribute("data-select_all_results_text") || @options.select_all_results_text || AbstractChosen.default_select_all_results_text
mouse_enter: -> @mouse_on_container = true
mouse_leave: -> @mouse_on_container = false
@@ -244,3 +245,4 @@ class AbstractChosen
@default_multiple_text: "Select Some Options"
@default_single_text: "Select an Option"
@default_no_result_text: "No results match"
+ @default_select_all_results_text: "Select all options"
View
37 public/index.html
@@ -1270,6 +1270,41 @@
</div>
</div>
+ <h2><a name="select-all-results-text-support" class="anchor" href="#select-all-results-text-support">Select all Results Support</a></h2>
+ <div class="side-by-side clearfix">
+ <p>Adding an option to select all results is as simple as passing an option, the text can also be customised:</p>
+ <pre><code class="language-javascript"> $(".chzn-select").chosen({enable_select_all: true, select_all_results_text: "Select all results!"}); </code></pre>
+ <p></p>
+ <div>
+ <em>Multiple Select</em>
+ <select style="width:350px;" multiple class="chzn-select-all-results" tabindex="12">
+ <option value=""></option>
+ <option>American Black Bear</option>
+ <option>Asiatic Black Bear</option>
+ <option>Brown Bear</option>
+ <option>Giant Panda</option>
+ <option>Sloth Bear</option>
+ <option>Sun Bear</option>
+ <option>Polar Bear</option>
+ <option>Spectacled Bear</option>
+ </select>
+ </div>
+ <div>
+ <em>Multiple Select Custom Message</em>
+ <select style="width:350px;" multiple class="chzn-select-all-results-custom" tabindex="13">
+ <option value=""></option>
+ <option>American Black Bear</option>
+ <option>Asiatic Black Bear</option>
+ <option>Brown Bear</option>
+ <option>Giant Panda</option>
+ <option>Sloth Bear</option>
+ <option>Sun Bear</option>
+ <option>Polar Bear</option>
+ <option>Spectacled Bear</option>
+ </select>
+ </div>
+ </div>
+
<h2><a name="limit-selected-options-in-multiselect" class="anchor" href="#limit-selected-options-in-multiselect">Limit Selected Options in Multiselect</a></h2>
<div class="side-by-side clearfix">
<p>You can easily limit how many options the user can select:</p>
@@ -1462,6 +1497,8 @@
'.chzn-select-deselect' : {allow_single_deselect:true},
'.chzn-select-no-single' : {disable_search_threshold:10},
'.chzn-select-no-results': {no_results_text:'Oops, nothing found!'},
+ '.chzn-select-all-results': {enable_select_all:true},
+ '.chzn-select-all-results-custom': {enable_select_all:true, select_all_results_text: "Select all results!"},
'.chzn-select-width' : {width:"95%"}
}
for (var selector in config) {

0 comments on commit b6a69f4

Please sign in to comment.
Something went wrong with that request. Please try again.