Clicking groups chooses all members of a group.
This commit is contained in:
parent
3cae992311
commit
d3eb80470c
|
@ -623,10 +623,21 @@ Copyright (c) 2011 by Harvest
|
||||||
};
|
};
|
||||||
|
|
||||||
Chosen.prototype.search_results_mouseup = function(evt) {
|
Chosen.prototype.search_results_mouseup = function(evt) {
|
||||||
var target;
|
var child, children, group, option, _i, _len;
|
||||||
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
group = $(evt.target).hasClass("group-result") ? $(evt.target) : $(evt.target).parents(".group-result").first();
|
||||||
if (target.length) {
|
if (group.length) {
|
||||||
this.result_highlight = target;
|
children = group.nextUntil(".group-result", ".active-result");
|
||||||
|
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
||||||
|
child = children[_i];
|
||||||
|
this.result_highlight = $(child);
|
||||||
|
this.result_select({
|
||||||
|
metaKey: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
option = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
||||||
|
if (option.length) {
|
||||||
|
this.result_highlight = option;
|
||||||
return this.result_select(evt);
|
return this.result_select(evt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -760,13 +771,13 @@ Copyright (c) 2011 by Harvest
|
||||||
option = _ref[_i];
|
option = _ref[_i];
|
||||||
if (!option.disabled && !option.empty) {
|
if (!option.disabled && !option.empty) {
|
||||||
if (option.group) {
|
if (option.group) {
|
||||||
if (this.winnow_option_group(option)) results += 1;
|
this.winnow_option_group(option);
|
||||||
} else if (!(this.is_multiple && option.selected)) {
|
} else if (!(this.is_multiple && option.selected)) {
|
||||||
found = this.winnow_search_match(this.regex, option.html);
|
found = this.winnow_search_match(this.regex, option.html);
|
||||||
if (found) results += 1;
|
|
||||||
result_id = option.dom_id;
|
result_id = option.dom_id;
|
||||||
result = $("#" + result_id);
|
result = $("#" + result_id);
|
||||||
if (found || ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match)) {
|
if (found || ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match)) {
|
||||||
|
results += 1;
|
||||||
if (this.searchText.length && found) {
|
if (this.searchText.length && found) {
|
||||||
text = this.winnow_search_highlight_match(this.zregex, option.html, this.searchText.length);
|
text = this.winnow_search_highlight_match(this.zregex, option.html, this.searchText.length);
|
||||||
} else {
|
} else {
|
||||||
|
|
2
chosen/chosen.jquery.min.js
vendored
2
chosen/chosen.jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -617,10 +617,25 @@ Copyright (c) 2011 by Harvest
|
||||||
};
|
};
|
||||||
|
|
||||||
Chosen.prototype.search_results_mouseup = function(evt) {
|
Chosen.prototype.search_results_mouseup = function(evt) {
|
||||||
var target;
|
var child, group, option, possible_children, _i, _len;
|
||||||
target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
|
group = evt.target.hasClassName("group-result") ? evt.target : evt.target.up(".group-result");
|
||||||
if (target) {
|
if (group) {
|
||||||
this.result_highlight = target;
|
possible_children = group.nextSiblings();
|
||||||
|
for (_i = 0, _len = possible_children.length; _i < _len; _i++) {
|
||||||
|
child = possible_children[_i];
|
||||||
|
if (child.hasClassName("active-result")) {
|
||||||
|
this.result_highlight = $(child);
|
||||||
|
this.result_select({
|
||||||
|
metaKey: null
|
||||||
|
});
|
||||||
|
} else if (child.hasClassName("group-result")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
option = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
|
||||||
|
if (option) {
|
||||||
|
this.result_highlight = option;
|
||||||
return this.result_select(evt);
|
return this.result_select(evt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -761,12 +776,12 @@ Copyright (c) 2011 by Harvest
|
||||||
option = _ref[_i];
|
option = _ref[_i];
|
||||||
if (!option.disabled && !option.empty) {
|
if (!option.disabled && !option.empty) {
|
||||||
if (option.group) {
|
if (option.group) {
|
||||||
if (this.winnow_option_group(option)) results += 1;
|
this.winnow_option_group(option);
|
||||||
} else if (!(this.is_multiple && option.selected)) {
|
} else if (!(this.is_multiple && option.selected)) {
|
||||||
found = this.winnow_search_match(this.regex, option.html);
|
found = this.winnow_search_match(this.regex, option.html);
|
||||||
if (found) results += 1;
|
|
||||||
result_id = option.dom_id;
|
result_id = option.dom_id;
|
||||||
if (found || ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match)) {
|
if (found || ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match)) {
|
||||||
|
results += 1;
|
||||||
if (this.searchText.length && found) {
|
if (this.searchText.length && found) {
|
||||||
text = this.winnow_search_highlight_match(this.zregex, option.html, this.searchText.length);
|
text = this.winnow_search_highlight_match(this.zregex, option.html, this.searchText.length);
|
||||||
} else {
|
} else {
|
||||||
|
|
2
chosen/chosen.proto.min.js
vendored
2
chosen/chosen.proto.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -270,9 +270,16 @@ class Chosen extends AbstractChosen
|
||||||
@search_field.removeClass "default"
|
@search_field.removeClass "default"
|
||||||
|
|
||||||
search_results_mouseup: (evt) ->
|
search_results_mouseup: (evt) ->
|
||||||
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
|
group = if $(evt.target).hasClass "group-result" then $(evt.target) else $(evt.target).parents(".group-result").first()
|
||||||
if target.length
|
if group.length
|
||||||
@result_highlight = target
|
children = group.nextUntil(".group-result", ".active-result")
|
||||||
|
for child in children
|
||||||
|
@result_highlight = $(child)
|
||||||
|
this.result_select({metaKey: null})
|
||||||
|
|
||||||
|
option = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
|
||||||
|
if option.length
|
||||||
|
@result_highlight = option
|
||||||
this.result_select(evt)
|
this.result_select(evt)
|
||||||
|
|
||||||
search_results_mouseover: (evt) ->
|
search_results_mouseover: (evt) ->
|
||||||
|
@ -389,15 +396,16 @@ class Chosen extends AbstractChosen
|
||||||
for option in @results_data
|
for option in @results_data
|
||||||
if not option.disabled and not option.empty
|
if not option.disabled and not option.empty
|
||||||
if option.group
|
if option.group
|
||||||
results += 1 if this.winnow_option_group(option)
|
this.winnow_option_group(option)
|
||||||
else if not (@is_multiple and option.selected)
|
else if not (@is_multiple and option.selected)
|
||||||
found = this.winnow_search_match(@regex, option.html)
|
found = this.winnow_search_match(@regex, option.html)
|
||||||
results += 1 if found
|
|
||||||
|
|
||||||
result_id = option.dom_id
|
result_id = option.dom_id
|
||||||
result = $("#" + result_id)
|
result = $("#" + result_id)
|
||||||
|
|
||||||
if found or (option.group_array_index? && @results_data[option.group_array_index].search_match)
|
if found or (option.group_array_index? && @results_data[option.group_array_index].search_match)
|
||||||
|
results += 1
|
||||||
|
|
||||||
if @searchText.length and found
|
if @searchText.length and found
|
||||||
text = this.winnow_search_highlight_match(@zregex, option.html, @searchText.length)
|
text = this.winnow_search_highlight_match(@zregex, option.html, @searchText.length)
|
||||||
else
|
else
|
||||||
|
@ -420,8 +428,8 @@ class Chosen extends AbstractChosen
|
||||||
$('#' + group.dom_id).css('display', 'none')
|
$('#' + group.dom_id).css('display', 'none')
|
||||||
|
|
||||||
group.search_match = this.winnow_search_match(@regex, group.label)
|
group.search_match = this.winnow_search_match(@regex, group.label)
|
||||||
text = if @searchText.length and group.search_match then this.winnow_search_highlight_match(@zregex, group.label, @searchText.length) else group.label
|
|
||||||
|
|
||||||
|
text = if @searchText.length and group.search_match then this.winnow_search_highlight_match(@zregex, group.label, @searchText.length) else group.label
|
||||||
$("##{group.dom_id}").html(text)
|
$("##{group.dom_id}").html(text)
|
||||||
|
|
||||||
return group.search_match
|
return group.search_match
|
||||||
|
|
|
@ -261,9 +261,20 @@ class Chosen extends AbstractChosen
|
||||||
@search_field.removeClassName "default"
|
@search_field.removeClassName "default"
|
||||||
|
|
||||||
search_results_mouseup: (evt) ->
|
search_results_mouseup: (evt) ->
|
||||||
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
|
|
||||||
if target
|
group = if evt.target.hasClassName("group-result") then evt.target else evt.target.up(".group-result")
|
||||||
@result_highlight = target
|
if group
|
||||||
|
possible_children = group.nextSiblings()
|
||||||
|
for child in possible_children
|
||||||
|
if child.hasClassName("active-result")
|
||||||
|
@result_highlight = $(child)
|
||||||
|
this.result_select({metaKey: null})
|
||||||
|
else if child.hasClassName("group-result")
|
||||||
|
return false
|
||||||
|
|
||||||
|
option = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
|
||||||
|
if option
|
||||||
|
@result_highlight = option
|
||||||
this.result_select(evt)
|
this.result_select(evt)
|
||||||
|
|
||||||
search_results_mouseover: (evt) ->
|
search_results_mouseover: (evt) ->
|
||||||
|
@ -380,14 +391,15 @@ class Chosen extends AbstractChosen
|
||||||
for option in @results_data
|
for option in @results_data
|
||||||
if not option.disabled and not option.empty
|
if not option.disabled and not option.empty
|
||||||
if option.group
|
if option.group
|
||||||
results += 1 if this.winnow_option_group(option)
|
this.winnow_option_group(option)
|
||||||
else if not (@is_multiple and option.selected)
|
else if not (@is_multiple and option.selected)
|
||||||
found = this.winnow_search_match(@regex, option.html)
|
found = this.winnow_search_match(@regex, option.html)
|
||||||
results += 1 if found
|
|
||||||
|
|
||||||
result_id = option.dom_id
|
result_id = option.dom_id
|
||||||
|
|
||||||
if found or (option.group_array_index? && @results_data[option.group_array_index].search_match)
|
if found or (option.group_array_index? && @results_data[option.group_array_index].search_match)
|
||||||
|
results += 1
|
||||||
|
|
||||||
if @searchText.length and found
|
if @searchText.length and found
|
||||||
text = this.winnow_search_highlight_match(@zregex, option.html, @searchText.length)
|
text = this.winnow_search_highlight_match(@zregex, option.html, @searchText.length)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue