Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump to 0.9.9 #12

Merged
merged 1 commit into from
Nov 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions vendor/assets/javascripts/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
21 changes: 4 additions & 17 deletions vendor/assets/javascripts/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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>')
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions vendor/assets/javascripts/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions vendor/assets/stylesheets/chosen.css.sass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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%
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down