Fix some tabbing issues and unexpected fall through on keydown_checker
This commit is contained in:
parent
56dbefa500
commit
2587c9c985
|
@ -184,8 +184,8 @@
|
||||||
Chosen.prototype.close_field = function() {
|
Chosen.prototype.close_field = function() {
|
||||||
$(document).unbind("click", this.click_test_action);
|
$(document).unbind("click", this.click_test_action);
|
||||||
if (!this.is_multiple) {
|
if (!this.is_multiple) {
|
||||||
this.selected_item.attr("tabIndex", this.search_field.attr("tabIndex"));
|
this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
|
||||||
this.search_field.attr("tabIndex", -1);
|
this.search_field.attr("tabindex", -1);
|
||||||
}
|
}
|
||||||
this.active_field = false;
|
this.active_field = false;
|
||||||
this.results_hide();
|
this.results_hide();
|
||||||
|
@ -197,8 +197,8 @@
|
||||||
};
|
};
|
||||||
Chosen.prototype.activate_field = function() {
|
Chosen.prototype.activate_field = function() {
|
||||||
if (!this.is_multiple && !this.active_field) {
|
if (!this.is_multiple && !this.active_field) {
|
||||||
this.search_field.attr("tabIndex", this.selected_item.attr("tabIndex"));
|
this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
|
||||||
this.selected_item.attr("tabIndex", -1);
|
this.selected_item.attr("tabindex", -1);
|
||||||
}
|
}
|
||||||
this.container.addClass("chzn-container-active");
|
this.container.addClass("chzn-container-active");
|
||||||
this.active_field = true;
|
this.active_field = true;
|
||||||
|
@ -273,7 +273,7 @@
|
||||||
};
|
};
|
||||||
Chosen.prototype.result_do_highlight = function(el) {
|
Chosen.prototype.result_do_highlight = function(el) {
|
||||||
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
||||||
if (el) {
|
if (el.length) {
|
||||||
this.result_clear_highlight();
|
this.result_clear_highlight();
|
||||||
this.result_highlight = el;
|
this.result_highlight = el;
|
||||||
this.result_highlight.addClass("highlighted");
|
this.result_highlight.addClass("highlighted");
|
||||||
|
@ -325,14 +325,14 @@
|
||||||
};
|
};
|
||||||
Chosen.prototype.set_tab_index = function(el) {
|
Chosen.prototype.set_tab_index = function(el) {
|
||||||
var ti;
|
var ti;
|
||||||
if (($(this.form_field)).attr("tabIndex")) {
|
if (($(this.form_field)).attr("tabindex")) {
|
||||||
ti = ($(this.form_field)).attr("tabIndex");
|
ti = ($(this.form_field)).attr("tabindex");
|
||||||
($(this.form_field)).attr("tabIndex", -1);
|
($(this.form_field)).attr("tabindex", -1);
|
||||||
if (this.is_multiple) {
|
if (this.is_multiple) {
|
||||||
return this.search_field.attr("tabIndex", ti);
|
return this.search_field.attr("tabindex", ti);
|
||||||
} else {
|
} else {
|
||||||
this.selected_item.attr("tabIndex", ti);
|
this.selected_item.attr("tabindex", ti);
|
||||||
return this.search_field.attr("tabIndex", -1);
|
return this.search_field.attr("tabindex", -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -626,16 +626,21 @@
|
||||||
}
|
}
|
||||||
switch (stroke) {
|
switch (stroke) {
|
||||||
case 8:
|
case 8:
|
||||||
return this.backstroke_length = this.search_field.val().length;
|
this.backstroke_length = this.search_field.val().length;
|
||||||
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
return this.mouse_on_container = false;
|
this.mouse_on_container = false;
|
||||||
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
return evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
break;
|
||||||
case 38:
|
case 38:
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
return this.keyup_arrow();
|
this.keyup_arrow();
|
||||||
|
break;
|
||||||
case 40:
|
case 40:
|
||||||
return this.keydown_arrow();
|
this.keydown_arrow();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Chosen.prototype.search_field_scale = function() {
|
Chosen.prototype.search_field_scale = function() {
|
||||||
|
|
|
@ -147,6 +147,7 @@ class Chosen
|
||||||
setTimeout this.container_click.bind(this), 50 unless @active_field
|
setTimeout this.container_click.bind(this), 50 unless @active_field
|
||||||
|
|
||||||
input_blur: (evt) ->
|
input_blur: (evt) ->
|
||||||
|
console.log "HUH?"
|
||||||
if not @mouse_on_container
|
if not @mouse_on_container
|
||||||
@active_field = false
|
@active_field = false
|
||||||
setTimeout this.blur_test.bind(this), 100
|
setTimeout this.blur_test.bind(this), 100
|
||||||
|
@ -158,8 +159,8 @@ class Chosen
|
||||||
$(document).unbind "click", @click_test_action
|
$(document).unbind "click", @click_test_action
|
||||||
|
|
||||||
if not @is_multiple
|
if not @is_multiple
|
||||||
@selected_item.attr "tabIndex", @search_field.attr("tabIndex")
|
@selected_item.attr "tabindex", @search_field.attr("tabindex")
|
||||||
@search_field.attr "tabIndex", -1
|
@search_field.attr "tabindex", -1
|
||||||
|
|
||||||
@active_field = false
|
@active_field = false
|
||||||
this.results_hide()
|
this.results_hide()
|
||||||
|
@ -173,8 +174,8 @@ class Chosen
|
||||||
|
|
||||||
activate_field: ->
|
activate_field: ->
|
||||||
if not @is_multiple and not @active_field
|
if not @is_multiple and not @active_field
|
||||||
@search_field.attr "tabIndex", @selected_item.attr "tabIndex"
|
@search_field.attr "tabindex", (@selected_item.attr "tabindex")
|
||||||
@selected_item.attr "tabIndex", -1
|
@selected_item.attr "tabindex", -1
|
||||||
|
|
||||||
@container.addClass "chzn-container-active"
|
@container.addClass "chzn-container-active"
|
||||||
@active_field = true
|
@active_field = true
|
||||||
|
@ -241,7 +242,7 @@ class Chosen
|
||||||
this.results_build()
|
this.results_build()
|
||||||
|
|
||||||
result_do_highlight: (el) ->
|
result_do_highlight: (el) ->
|
||||||
if el
|
if el.length
|
||||||
this.result_clear_highlight();
|
this.result_clear_highlight();
|
||||||
|
|
||||||
@result_highlight = el;
|
@result_highlight = el;
|
||||||
|
@ -290,15 +291,15 @@ class Chosen
|
||||||
|
|
||||||
|
|
||||||
set_tab_index: (el) ->
|
set_tab_index: (el) ->
|
||||||
if ($ @form_field).attr "tabIndex"
|
if ($ @form_field).attr "tabindex"
|
||||||
ti = ($ @form_field).attr "tabIndex"
|
ti = ($ @form_field).attr "tabindex"
|
||||||
($ @form_field).attr "tabIndex", -1
|
($ @form_field).attr "tabindex", -1
|
||||||
|
|
||||||
if @is_multiple
|
if @is_multiple
|
||||||
@search_field.attr "tabIndex", ti
|
@search_field.attr "tabindex", ti
|
||||||
else
|
else
|
||||||
@selected_item.attr "tabIndex", ti
|
@selected_item.attr "tabindex", ti
|
||||||
@search_field.attr "tabIndex", -1
|
@search_field.attr "tabindex", -1
|
||||||
|
|
||||||
show_search_field_default: ->
|
show_search_field_default: ->
|
||||||
if @is_multiple and @choices < 1 and not @active_field
|
if @is_multiple and @choices < 1 and not @active_field
|
||||||
|
@ -546,15 +547,20 @@ class Chosen
|
||||||
switch stroke
|
switch stroke
|
||||||
when 8
|
when 8
|
||||||
@backstroke_length = this.search_field.val().length
|
@backstroke_length = this.search_field.val().length
|
||||||
|
break
|
||||||
when 9
|
when 9
|
||||||
@mouse_on_container = false
|
@mouse_on_container = false
|
||||||
|
break
|
||||||
when 13
|
when 13
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
|
break
|
||||||
when 38
|
when 38
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
this.keyup_arrow()
|
this.keyup_arrow()
|
||||||
|
break
|
||||||
when 40
|
when 40
|
||||||
this.keydown_arrow()
|
this.keydown_arrow()
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
search_field_scale: ->
|
search_field_scale: ->
|
||||||
|
|
Loading…
Reference in a new issue