Skip to content

Loading…

bump to 0.9.9 #12

Merged
merged 1 commit into from

2 participants

@caarlos0

it fixes a anoying issue with tabindexes. please merge it.

@tsechingho tsechingho merged commit 57c3a16 into tsechingho:master
@caarlos0

thanks ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 28, 2012
  1. @caarlos0

    bump to 0.9.9

    caarlos0 committed
View
21 vendor/assets/javascripts/chosen.jquery.coffee
@@ -41,7 +41,7 @@ class Chosen extends AbstractChosen
if @is_multiple
container_div.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" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
else
- container_div.html '<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
+ container_div.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" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
@form_field_jq.hide().after container_div
@container = ($ '#' + @container_id)
@@ -89,12 +89,13 @@ class Chosen extends AbstractChosen
@search_field.blur (evt) => this.input_blur(evt)
@search_field.keyup (evt) => this.keyup_checker(evt)
@search_field.keydown (evt) => this.keydown_checker(evt)
+ @search_field.focus (evt) => this.input_focus(evt)
if @is_multiple
@search_choices.click (evt) => this.choices_click(evt)
- @search_field.focus (evt) => this.input_focus(evt)
else
@container.click (evt) => evt.preventDefault() # gobble click of anchor
+
search_field_disabled: ->
@is_disabled = @form_field_jq[0].disabled
@@ -135,10 +136,6 @@ class Chosen extends AbstractChosen
close_field: ->
$(document).unbind "click", @click_test_action
- if not @is_multiple
- @selected_item.attr "tabindex", @search_field.attr("tabindex")
- @search_field.attr "tabindex", -1
-
@active_field = false
this.results_hide()
@@ -150,10 +147,6 @@ class Chosen extends AbstractChosen
this.search_field_scale()
activate_field: ->
- if not @is_multiple and not @active_field
- @search_field.attr "tabindex", (@selected_item.attr "tabindex")
- @selected_item.attr "tabindex", -1
-
@container.addClass "chzn-container-active"
@active_field = true
@@ -262,12 +255,7 @@ class Chosen extends AbstractChosen
if @form_field_jq.attr "tabindex"
ti = @form_field_jq.attr "tabindex"
@form_field_jq.attr "tabindex", -1
-
- if @is_multiple
- @search_field.attr "tabindex", ti
- else
- @selected_item.attr "tabindex", ti
- @search_field.attr "tabindex", -1
+ @search_field.attr "tabindex", ti
show_search_field_default: ->
if @is_multiple and @choices < 1 and not @active_field
@@ -282,6 +270,7 @@ class Chosen extends AbstractChosen
if target.length
@result_highlight = target
this.result_select(evt)
+ @search_field.focus()
search_results_mouseover: (evt) ->
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
View
21 vendor/assets/javascripts/chosen.proto.coffee
@@ -17,7 +17,7 @@ class Chosen extends AbstractChosen
super()
# HTML Templates
- @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
+ @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" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@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" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
@choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>')
@@ -81,10 +81,10 @@ class Chosen extends AbstractChosen
@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)
if @is_multiple
@search_choices.observe "click", (evt) => this.choices_click(evt)
- @search_field.observe "focus", (evt) => this.input_focus(evt)
else
@container.observe "click", (evt) => evt.preventDefault() # gobble click of anchor
@@ -126,10 +126,6 @@ class Chosen extends AbstractChosen
close_field: ->
document.stopObserving "click", @click_test_action
- if not @is_multiple
- @selected_item.tabIndex = @search_field.tabIndex
- @search_field.tabIndex = -1
-
@active_field = false
this.results_hide()
@@ -141,17 +137,12 @@ class Chosen extends AbstractChosen
this.search_field_scale()
activate_field: ->
- if not @is_multiple and not @active_field
- @search_field.tabIndex = @selected_item.tabIndex
- @selected_item.tabIndex = -1
-
@container.addClassName "chzn-container-active"
@active_field = true
@search_field.value = @search_field.value
@search_field.focus()
-
test_active_click: (evt) ->
if evt.target.up('#' + @container_id)
@active_field = true
@@ -252,12 +243,7 @@ class Chosen extends AbstractChosen
if @form_field.tabIndex
ti = @form_field.tabIndex
@form_field.tabIndex = -1
-
- if @is_multiple
- @search_field.tabIndex = ti
- else
- @selected_item.tabIndex = ti
- @search_field.tabIndex = -1
+ @search_field.tabIndex = ti
show_search_field_default: ->
if @is_multiple and @choices < 1 and not @active_field
@@ -272,6 +258,7 @@ class Chosen extends AbstractChosen
if target
@result_highlight = target
this.result_select(evt)
+ @search_field.focus()
search_results_mouseover: (evt) ->
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
View
8 vendor/assets/javascripts/lib/abstract-chosen.coffee
@@ -7,10 +7,9 @@ root = this
class AbstractChosen
constructor: (@form_field, @options={}) ->
- this.set_default_values()
-
@is_multiple = @form_field.multiple
this.set_default_text()
+ this.set_default_values()
this.setup()
@@ -49,7 +48,10 @@ class AbstractChosen
mouse_leave: -> @mouse_on_container = false
input_focus: (evt) ->
- setTimeout (=> this.container_mousedown()), 50 unless @active_field
+ if @is_multiple
+ setTimeout (=> this.container_mousedown()), 50 unless @active_field
+ else
+ @activate_field() unless @active_field
input_blur: (evt) ->
if not @mouse_on_container
View
34 vendor/assets/stylesheets/chosen.css.sass
@@ -69,7 +69,7 @@
width: 12px
height: 13px
font-size: 1px
- background: image-url('chosen-sprite.png') right top no-repeat
+ background: url('chosen-sprite.png') right top no-repeat
&:hover
background-position: right -11px
&.chzn-disabled .chzn-single abbr:hover
@@ -82,7 +82,7 @@
height: 100%
width: 18px
b
- background: image-url('chosen-sprite.png') no-repeat 0 0
+ background: url('chosen-sprite.png') no-repeat 0 0
display: block
width: 100%
height: 100%
@@ -93,12 +93,12 @@
white-space: nowrap
z-index: 1010
input
- background: white image-url('chosen-sprite.png') no-repeat 100% -22px
- background: image-url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, white))
- background: image-url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(#eeeeee 1%, white 15%)
+ background: white url('chosen-sprite.png') no-repeat 100% -22px
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, white))
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(#eeeeee 1%, white 15%)
margin: 1px 0
padding: 4px 20px 4px 5px
outline: 0
@@ -204,7 +204,7 @@
width: 12px
height: 13px
font-size: 1px
- background: image-url('chosen-sprite.png') right top no-repeat
+ background: url('chosen-sprite.png') right top no-repeat
&:hover
background-position: right -11px
.search-choice-focus .search-choice-close
@@ -281,9 +281,9 @@
.chzn-results-scroll-down
bottom: 0
span
- background: image-url('chosen-sprite.png') no-repeat -4px -3px
+ background: url('chosen-sprite.png') no-repeat -4px -3px
.chzn-results-scroll-up span
- background: image-url('chosen-sprite.png') no-repeat -22px -3px
+ background: url('chosen-sprite.png') no-repeat -22px -3px
/* @end
@@ -374,12 +374,12 @@
&.chzn-container-active .chzn-single-with-drop div
border-right: none
.chzn-search input
- background: white image-url('chosen-sprite.png') no-repeat -38px -22px
- background: image-url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, white))
- background: image-url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, white 15%)
- background: image-url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(#eeeeee 1%, white 15%)
+ background: white url('chosen-sprite.png') no-repeat -38px -22px
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, white))
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, white 15%)
+ background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(#eeeeee 1%, white 15%)
padding: 4px 5px 4px 20px
direction: rtl
Something went wrong with that request. Please try again.