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

Revert previous clip-deprecation fixes in favor of hybrid clip and clip-path. #2989

Merged
merged 4 commits into from
May 31, 2018
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
22 changes: 3 additions & 19 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class Chosen extends AbstractChosen
@form_field_jq.hide().after @container
@dropdown = @container.find('div.chosen-drop').first()

@search_field = @container.find('input.chosen-search-input')
@focus_field = @container.find('input.chosen-focus-input')
@search_field = @container.find('input').first()
@search_results = @container.find('ul.chosen-results').first()
this.search_field_scale()

Expand Down Expand Up @@ -106,18 +105,6 @@ class Chosen extends AbstractChosen
else
@container.on 'click.chosen', (evt) -> evt.preventDefault(); return # gobble click of anchor

@focus_field.on 'blur.chosen', (evt) => this.input_blur(evt); return
@focus_field.on 'focus.chosen', (evt) => this.input_focus(evt); return

transfer_value = () =>
@search_field.val(@focus_field.val())
@focus_field.val('')

@focus_field.on 'keyup.chosen', (evt) => transfer_value(); this.keyup_checker(evt); return
@focus_field.on 'keydown.chosen', (evt) => transfer_value(); this.keydown_checker(evt); return
@focus_field.on 'cut.chosen', (evt) => setTimeout(transfer_value, 0); this.clipboard_event_checker(evt); return
@focus_field.on 'paste.chosen', (evt) => setTimeout(transfer_value, 0); this.clipboard_event_checker(evt); return

destroy: ->
$(@container[0].ownerDocument).off 'click.chosen', @click_test_action
@form_field_label.off 'click.chosen' if @form_field_label.length > 0
Expand Down Expand Up @@ -192,8 +179,10 @@ class Chosen extends AbstractChosen
@container.addClass "chosen-container-active"
@active_field = true

@search_field.val(@search_field.val())
@search_field.focus()


test_active_click: (evt) ->
active_container = $(evt.target).closest('.chosen-container')
if active_container.length and @container[0] == active_container[0]
Expand All @@ -213,11 +202,9 @@ class Chosen extends AbstractChosen
this.single_set_selected_text()
if @disable_search or @form_field.options.length <= @disable_search_threshold
@search_field[0].readOnly = true
@focus_field[0].readOnly = true
@container.addClass "chosen-container-single-nosearch"
else
@search_field[0].readOnly = false
@focus_field[0].readOnly = false
@container.removeClass "chosen-container-single-nosearch"

this.update_results_content this.results_option_build({first:true})
Expand Down Expand Up @@ -272,8 +259,6 @@ class Chosen extends AbstractChosen
if @results_showing
this.result_clear_highlight()

setTimeout((() => @focus_field.focus()), 0)

@container.removeClass "chosen-with-drop"
@form_field_jq.trigger("chosen:hiding_dropdown", {chosen: this})

Expand All @@ -285,7 +270,6 @@ class Chosen extends AbstractChosen
ti = @form_field.tabIndex
@form_field.tabIndex = -1
@search_field[0].tabIndex = ti
@focus_field[0]?.tabIndex = ti

set_label_behavior: ->
@form_field_label = @form_field_jq.parents("label") # first check for a parent label
Expand Down
21 changes: 2 additions & 19 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class @Chosen extends AbstractChosen
@form_field.hide().insert({ after: @container })
@dropdown = @container.down('div.chosen-drop')

@search_field = @container.down('input.chosen-search-input')
@focus_field = @container.down('input.chosen-focus-input')
@search_field = @container.down('input')
@search_results = @container.down('ul.chosen-results')
this.search_field_scale()

Expand Down Expand Up @@ -85,18 +84,6 @@ class @Chosen extends AbstractChosen
else
@container.observe "click", (evt) => evt.preventDefault() # gobble click of anchor

@focus_field.observe "blur", (evt) => this.input_blur(evt)
@focus_field.observe "focus", (evt) => this.input_focus(evt)

transfer_value = () =>
@search_field.value = @focus_field.value
@focus_field.value = ""

@focus_field.observe "keyup", (evt) => transfer_value(); this.keyup_checker(evt)
@focus_field.observe "keydown", (evt) => transfer_value(); this.keydown_checker(evt)
@focus_field.observe "cut", (evt) => setTimeout(transfer_value, 0); this.clipboard_event_checker(evt)
@focus_field.observe "paste", (evt) => setTimeout(transfer_value, 0); this.clipboard_event_checker(evt)

destroy: ->
@container.ownerDocument.stopObserving "click", @click_test_action

Expand Down Expand Up @@ -187,6 +174,7 @@ class @Chosen extends AbstractChosen
@container.addClassName "chosen-container-active"
@active_field = true

@search_field.value = this.get_search_field_value()
@search_field.focus()

test_active_click: (evt) ->
Expand All @@ -207,11 +195,9 @@ class @Chosen extends AbstractChosen
this.single_set_selected_text()
if @disable_search or @form_field.options.length <= @disable_search_threshold
@search_field.readOnly = true
@focus_field?.readOnly = true
@container.addClassName "chosen-container-single-nosearch"
else
@search_field.readOnly = false
@focus_field?.readOnly = false
@container.removeClassName "chosen-container-single-nosearch"

this.update_results_content this.results_option_build({first:true})
Expand Down Expand Up @@ -265,8 +251,6 @@ class @Chosen extends AbstractChosen
if @results_showing
this.result_clear_highlight()

setTimeout((() => @focus_field?.focus()), 0)

@container.removeClassName "chosen-with-drop"
@form_field.fire("chosen:hiding_dropdown", {chosen: this})

Expand All @@ -278,7 +262,6 @@ class @Chosen extends AbstractChosen
ti = @form_field.tabIndex
@form_field.tabIndex = -1
@search_field.tabIndex = ti
@focus_field?.tabIndex = ti

set_label_behavior: ->
@form_field_label = @form_field.up("label") # first check for a parent label
Expand Down
1 change: 0 additions & 1 deletion coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ class AbstractChosen
get_single_html: ->
"""
<a class="chosen-single chosen-default">
<input class="chosen-focus-input" type="text" autocomplete="off" />
<span>#{@default_text}</span>
<div><b></b></div>
</a>
Expand Down
17 changes: 6 additions & 11 deletions sass/chosen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ $chosen-sprite-retina: url('[email protected]') !default;
border-top: 0;
background: #fff;
box-shadow: 0 4px 5px rgba(#000,.15);
display: none;
clip: rect(0,0,0,0);
clip-path: inset(100% 100%);
}
&.chosen-with-drop .chosen-drop {
display: block;
clip: auto;
clip-path: none;
}
a{
cursor: pointer;
Expand Down Expand Up @@ -65,13 +67,6 @@ $chosen-sprite-retina: url('[email protected]') !default;
text-decoration: none;
white-space: nowrap;
line-height: 24px;

input[type="text"] {
cursor: pointer;
opacity: 0;
position: absolute;
width: 0;
}
}
.chosen-default {
color: #999;
Expand Down Expand Up @@ -144,8 +139,8 @@ $chosen-sprite-retina: url('[email protected]') !default;
}
&.chosen-container-single-nosearch .chosen-search {
position: absolute;
opacity: 0;
pointer-events: none;
clip: rect(0,0,0,0);
clip-path: inset(100% 100%);
}
}
/* @end */
Expand Down