Prototype version no longer requires ID

abstract-chosen
pfiller 2011-07-26 14:22:51 -04:00
parent 74bef32be4
commit 2e7348d412
2 changed files with 10 additions and 10 deletions

View File

@ -35,7 +35,7 @@
};
Chosen.prototype.set_up_html = function() {
var base_template, container_props, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id + "_chzn";
this.container_id = this.form_field.identify() + "_chzn";
this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth();
container_props = {
'id': this.container_id,
@ -227,7 +227,7 @@
};
Chosen.prototype.result_add_group = function(group) {
if (!group.disabled) {
group.dom_id = this.form_field.id + "chzn_g_" + group.array_index;
group.dom_id = this.container_id + "_g_" + group.array_index;
return '<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>';
} else {
return "";
@ -236,7 +236,7 @@
Chosen.prototype.result_add_option = function(option) {
var classes;
if (!option.disabled) {
option.dom_id = this.form_field.id + "chzn_o_" + option.array_index;
option.dom_id = this.container_id + "_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"];
if (option.selected) {
classes.push("result-selected");
@ -361,7 +361,7 @@
};
Chosen.prototype.choice_build = function(item) {
var choice_id, link;
choice_id = this.form_field.id + "_chzn_c_" + item.array_index;
choice_id = this.container_id + "_c_" + item.array_index;
this.choices += 1;
this.search_container.insert({
before: this.choice_temp.evaluate({
@ -428,7 +428,7 @@
result_data = this.results_data[pos];
result_data.selected = false;
this.form_field.options[result_data.options_index].selected = false;
result = $(this.form_field.id + "chzn_o_" + pos);
result = $(this.container_id + "_o_" + pos);
result.removeClassName("result-selected").addClassName("active-result").show();
this.result_clear_highlight();
this.winnow_results();

View File

@ -41,7 +41,7 @@ class Chosen
set_up_html: ->
@container_id = @form_field.id + "_chzn"
@container_id = @form_field.identify() + "_chzn"
@f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()
@ -200,14 +200,14 @@ class Chosen
result_add_group: (group) ->
if not group.disabled
group.dom_id = @form_field.id + "chzn_g_" + group.array_index
group.dom_id = @container_id + "_g_" + group.array_index
'<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>'
else
""
result_add_option: (option) ->
if not option.disabled
option.dom_id = @form_field.id + "chzn_o_" + option.array_index
option.dom_id = @container_id + "_o_" + option.array_index
classes = if option.selected and @is_multiple then [] else ["active-result"]
classes.push "result-selected" if option.selected
@ -311,7 +311,7 @@ class Chosen
this.results_show()
choice_build: (item) ->
choice_id = @form_field.id + "_chzn_c_" + item.array_index
choice_id = @container_id + "_c_" + item.array_index
@choices += 1
@search_container.insert { before: @choice_temp.evaluate({"id":choice_id, "choice":item.text, "position":item.array_index}) }
link = $(choice_id).down('a')
@ -371,7 +371,7 @@ class Chosen
result_data.selected = false
@form_field.options[result_data.options_index].selected = false
result = $(@form_field.id + "chzn_o_" + pos)
result = $(@container_id + "_o_" + pos)
result.removeClassName("result-selected").addClassName("active-result").show()
this.result_clear_highlight()