Skip to content

Commit 038e71f

Browse files
committed
Merge branch 'master' into optionally-show-selected-disabled
2 parents d54c9a8 + 6638dd7 commit 038e71f

14 files changed

+112
-85
lines changed

Gruntfile.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module.exports = (grunt) ->
3030
dest: "public/chosen.proto.js"
3131

3232
coffee:
33+
options:
34+
join: true
3335
compile:
3436
files:
3537
'public/chosen.jquery.js': ['coffee/lib/select-parser.coffee', 'coffee/lib/abstract-chosen.coffee', 'coffee/chosen.jquery.coffee']

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ We welcome all to participate in making Chosen the best software it can be. The
2424

2525
- Concept and development by [Patrick Filler](http://patrickfiller.com) for [Harvest](http://getharvest.com/).
2626
- Design and CSS by [Matthew Lettini](http://matthewlettini.com/)
27-
- Repository maintained by [@pfiller](http://github.com/pfiller), [@kenearley](http://github.com/kenearley) and [@stof](http://github.com/stof).
27+
- Repository maintained by [@pfiller](http://github.com/pfiller), [@kenearley](http://github.com/kenearley), [@stof](http://github.com/stof) and [@koenpunt](http://github.com/koenpunt).
2828
- Chosen includes [contributions by many fine folks](https://github.com/harvesthq/chosen/contributors).

chosen.jquery.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
{
3434
"name": "Ken Earley",
3535
"url": "https://github.com/kenearley"
36+
},
37+
{
38+
"name": "Koen Punt",
39+
"url": "https://github.com/koenpunt"
3640
}
3741
],
3842
"download": "https://github.com/harvesthq/chosen/releases",

coffee/chosen.jquery.coffee

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
root = this
21
$ = jQuery
32

43
$.fn.extend({
@@ -40,7 +39,7 @@ class Chosen extends AbstractChosen
4039
if @is_multiple
4140
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>'
4241
else
43-
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
42+
@container.html '<a class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
4443

4544
@form_field_jq.hide().after @container
4645
@dropdown = @container.find('div.chzn-drop').first()
@@ -159,7 +158,7 @@ class Chosen extends AbstractChosen
159158
@parsing = true
160159
@selected_option_count = null
161160

162-
@results_data = root.SelectParser.select_to_array @form_field
161+
@results_data = SelectParser.select_to_array @form_field
163162

164163
if @is_multiple
165164
@search_choices.find("li.search-choice").remove()
@@ -232,10 +231,10 @@ class Chosen extends AbstractChosen
232231

233232

234233
set_tab_index: (el) ->
235-
if @form_field_jq.attr "tabindex"
236-
ti = @form_field_jq.attr "tabindex"
237-
@form_field_jq.attr "tabindex", -1
238-
@search_field.attr "tabindex", ti
234+
if @form_field.tabIndex
235+
ti = @form_field.tabIndex
236+
@form_field.tabIndex = -1
237+
@search_field[0].tabIndex = ti
239238

240239
set_label_behavior: ->
241240
@form_field_label = @form_field_jq.parents("label") # first check for a parent label
@@ -273,7 +272,7 @@ class Chosen extends AbstractChosen
273272
if item.disabled
274273
choice.addClass 'search-choice-disabled'
275274
else
276-
close_link = $('<a />', { href: '#', class: 'search-choice-close', rel: item.array_index })
275+
close_link = $('<a />', { class: 'search-choice-close', 'data-option-array-index': item.array_index })
277276
close_link.click (evt) => this.choice_destroy_link_click(evt)
278277
choice.append close_link
279278

@@ -285,7 +284,7 @@ class Chosen extends AbstractChosen
285284
this.choice_destroy $(evt.target) unless @is_disabled
286285

287286
choice_destroy: (link) ->
288-
if this.result_deselect (link.attr "rel")
287+
if this.result_deselect( link[0].getAttribute("data-option-array-index") )
289288
this.show_search_field_default()
290289

291290
this.results_hide() if @is_multiple and this.choices_count() > 0 and @search_field.val().length < 1
@@ -320,7 +319,11 @@ class Chosen extends AbstractChosen
320319
if @is_multiple
321320
high.removeClass("active-result")
322321
else
323-
@search_results.find(".result-selected").removeClass "result-selected"
322+
if @result_single_selected
323+
@result_single_selected.removeClass("result-selected")
324+
selected_index = @result_single_selected[0].getAttribute('data-option-array-index')
325+
@results_data[selected_index].selected = false
326+
324327
@result_single_selected = high
325328

326329
high.addClass "result-selected"
@@ -482,5 +485,3 @@ class Chosen extends AbstractChosen
482485
w = f_width - 10
483486

484487
@search_field.css({'width': w + 'px'})
485-
486-
root.Chosen = Chosen

coffee/chosen.proto.coffee

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
root = this
2-
3-
class Chosen extends AbstractChosen
1+
class @Chosen extends AbstractChosen
42

53
setup: ->
64
@current_selectedIndex = @form_field.selectedIndex
@@ -13,7 +11,7 @@ class Chosen extends AbstractChosen
1311
super()
1412

1513
# HTML Templates
16-
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
14+
@single_temp = new Template('<a class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
1715
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>')
1816
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
1917

@@ -148,7 +146,7 @@ class Chosen extends AbstractChosen
148146
@parsing = true
149147
@selected_option_count = null
150148

151-
@results_data = root.SelectParser.select_to_array @form_field
149+
@results_data = SelectParser.select_to_array @form_field
152150

153151
if @is_multiple
154152
@search_choices.select("li.search-choice").invoke("remove")
@@ -308,7 +306,11 @@ class Chosen extends AbstractChosen
308306
if @is_multiple
309307
high.removeClassName("active-result")
310308
else
311-
@search_results.descendants(".result-selected").invoke "removeClassName", "result-selected"
309+
if @result_single_selected
310+
@result_single_selected.removeClassName("result-selected")
311+
selected_index = @result_single_selected.getAttribute('data-option-array-index')
312+
@results_data[selected_index].selected = false
313+
312314
@result_single_selected = high
313315

314316
high.addClassName("result-selected")
@@ -473,5 +475,3 @@ class Chosen extends AbstractChosen
473475
w = f_width - 10
474476

475477
@search_field.setStyle({'width': w + 'px'})
476-
477-
root.Chosen = Chosen

coffee/lib/abstract-chosen.coffee

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
root = this
2-
31
class AbstractChosen
42

53
constructor: (@form_field, @options={}) ->
@@ -29,7 +27,7 @@ class AbstractChosen
2927
@enable_split_word_search = if @options.enable_split_word_search? then @options.enable_split_word_search else true
3028
@group_search = if @options.group_search? then @options.group_search else true
3129
@search_contains = @options.search_contains || false
32-
@single_backstroke_delete = @options.single_backstroke_delete || false
30+
@single_backstroke_delete = if @options.single_backstroke_delete? then @options.single_backstroke_delete else true
3331
@max_selected_options = @options.max_selected_options || Infinity
3432
@inherit_select_classes = @options.inherit_select_classes || false
3533
@display_selected_options = if @options.display_selected_options? then @options.display_selected_options else true
@@ -228,11 +226,13 @@ class AbstractChosen
228226

229227
@browser_is_supported: ->
230228
if window.navigator.appName == "Microsoft Internet Explorer"
231-
return null isnt document.documentMode >= 8
229+
return document.documentMode >= 8
230+
if /iP(od|hone)/i.test(window.navigator.userAgent)
231+
return false
232+
if /Android/i.test(window.navigator.userAgent)
233+
return false if /Mobile/i.test(window.navigator.userAgent)
232234
return true
233235

234236
@default_multiple_text: "Select Some Options"
235237
@default_single_text: "Select an Option"
236238
@default_no_result_text: "No results match"
237-
238-
root.AbstractChosen = AbstractChosen

coffee/lib/select-parser.coffee

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,4 @@ class SelectParser
6161
SelectParser.select_to_array = (select) ->
6262
parser = new SelectParser()
6363
parser.add_node( child ) for child in select.childNodes
64-
parser.parsed
65-
66-
this.SelectParser = SelectParser
64+
parser.parsed

contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ and [submitting pull requests](#pull-requests), but please respect the
2121
following restrictions:
2222

2323
* Please **do not** use the issue tracker for personal support requests (use
24-
[Stack Overflow](http://stackoverflow.com)).
24+
[Stack Overflow](http://stackoverflow.com/search?q=chosen)).
2525

2626
* Please **do not** derail or troll issues. Keep the discussion on topic and
2727
respect the opinions of others.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
{
5858
"name": "Ken Earley",
5959
"url": "https://github.com/kenearley"
60+
},
61+
{
62+
"name": "Koen Punt",
63+
"url": "https://github.com/koenpunt"
6064
}
6165
],
6266
"download": "https://github.com/harvesthq/chosen/releases",

public/docsupport/style.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav,
55

66
blockquote, q { quotes: none; }
77
blockquote:before, blockquote:after, q:before, q:after { content: ""; content: none; }
8-
ins { background-color: #ff9; color: #000; text-decoration: none; }
8+
ins { background-color: #ff9; color: #000; text-decoration: none; }
99
mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; }
1010
del { text-decoration: line-through; }
1111
abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; }
@@ -133,7 +133,7 @@ strong { font-weight: bold; }
133133
border: 0;
134134
margin-top: -10px;
135135
display: block;
136-
height: 58px;
136+
height: 58px;
137137
background: #F36C00 url(oss-credit.png) no-repeat 20px 22px;
138138
padding: 22px 20px 12px 20px;
139139
text-indent: 120%; /* stupid padding */
@@ -186,3 +186,16 @@ strong { font-weight: bold; }
186186
font-size: 12px;
187187
padding: 2px 4px;
188188
}
189+
190+
.anchor {
191+
color: inherit;
192+
position: relative;
193+
}
194+
195+
.anchor:hover {
196+
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSI3Ij48ZyBmaWxsPSIjNDE0MDQyIj48cGF0aCBkPSJNOS44IDdoLS45bC0uOS0uMWMtLjctLjMtMS40LS43LTEuOC0xLjMtLjItLjEtLjMtLjMtLjMtLjVsLS4zLS40Yy0uMS0uNC0uMi0uOC0uMi0xLjIgMC0uNC4xLS44LjItMS4yaDEuN2MtLjMuNC0uNC44LS40IDEuMiAwIC40LjEuOC4zIDEuMS4xLjIuMi4zLjQuNC4xLjEuMi4yLjQuMy4zLjIuNy4zIDEgLjNoMy40YzEuMiAwIDIuMi0uOSAyLjItMi4xcy0xLTIuMS0yLjItMi4xaC0xLjRjLS4zLS42LS43LTEtMS4yLTEuNGgyLjZjMiAwIDMuNiAxLjYgMy42IDMuNXMtMS42IDMuNS0zLjYgMy41aC0yLjZ6TTguNCAyYy0uMS0uMS0uMi0uMy0uNC0uMy0uMy0uMi0uNy0uMy0xLS4zaC0zLjRjLTEuMiAwLTIuMi45LTIuMiAyLjEgMCAxLjIgMSAyLjEgMi4yIDIuMWgxLjRjLjMuNS43IDEgMS4yIDEuNGgtMi42Yy0yIDAtMy42LTEuNi0zLjYtMy41czEuNi0zLjUgMy42LTMuNWgzLjUwMDAwMDAwMDAwMDAwMDRsLjkuMWMuNy4yIDEuNC43IDEuOCAxLjMuMS4xLjIuMy4zLjUuMS4xLjIuMy4yLjUuMS40LjIuOC4yIDEuMiAwIC40LS4xLjgtLjIgMS4yaC0xLjZjLjMtLjUuNC0uOS40LTEuM3MtLjEtLjgtLjMtMS4xYy0uMS0uMi0uMi0uMy0uNC0uNHoiLz48L2c+PC9zdmc+) 0 50% no-repeat;
197+
background-size: 21px 9px;
198+
margin-left: -27px;
199+
padding-left: 27px;
200+
text-decoration: none;
201+
}

0 commit comments

Comments
 (0)