Update chosen to latest version and use latest version of jQuery

gh-pages
Patrick Filler 2011-09-22 15:43:46 -05:00
parent 9cd2fcbb3a
commit 31a708028d
3 changed files with 49 additions and 22 deletions

View File

@ -303,6 +303,15 @@
} }
/* @end */ /* @end */
/* @group Disabled Support */
.chzn-disabled {
cursor: default;
opacity:0.5 !important;
}
.chzn-disabled .chzn-single {
cursor: default;
}
/* @group Right to Left */ /* @group Right to Left */
.chzn-rtl { direction:rtl;text-align: right; } .chzn-rtl { direction:rtl;text-align: right; }
.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; } .chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }

View File

@ -44,6 +44,9 @@
this.click_test_action = __bind(function(evt) { this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt); return this.test_active_click(evt);
}, this); }, this);
this.activate_action = __bind(function(evt) {
return this.activate_field(evt);
}, this);
this.active_field = false; this.active_field = false;
this.mouse_on_container = false; this.mouse_on_container = false;
this.results_showing = false; this.results_showing = false;
@ -60,7 +63,7 @@
this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default; this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
container_div = $("<div />", { container_div = $("<div />", {
id: this.container_id, id: this.container_id,
"class": "chzn-container " + (this.is_rtl ? 'chzn-rtl' : ''), "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
style: 'width: ' + this.f_width + 'px;' style: 'width: ' + this.f_width + 'px;'
}); });
if (this.is_multiple) { if (this.is_multiple) {
@ -134,30 +137,44 @@
return this.search_field.focus(__bind(function(evt) { return this.search_field.focus(__bind(function(evt) {
return this.input_focus(evt); return this.input_focus(evt);
}, this)); }, this));
}
};
Chosen.prototype.search_field_disabled = function() {
this.is_disabled = this.form_field_jq.attr('disabled');
if (this.is_disabled) {
this.container.addClass('chzn-disabled');
this.search_field.attr('disabled', true);
if (!this.is_multiple) {
return this.selected_item.unbind("focus", this.activate_action);
}
} else { } else {
return this.selected_item.focus(__bind(function(evt) { this.container.removeClass('chzn-disabled');
return this.activate_field(evt); this.search_field.attr('disabled', false);
}, this)); if (!this.is_multiple) {
return this.selected_item.bind("focus", this.activate_action);
}
} }
}; };
Chosen.prototype.container_mousedown = function(evt) { Chosen.prototype.container_mousedown = function(evt) {
if (evt && evt.type === "mousedown") { if (!this.is_disabled) {
evt.stopPropagation(); if (evt && evt.type === "mousedown") {
} evt.stopPropagation();
if (!this.pending_destroy_click) { }
if (!this.active_field) { if (!this.pending_destroy_click) {
if (this.is_multiple) { if (!this.active_field) {
this.search_field.val(""); if (this.is_multiple) {
} this.search_field.val("");
$(document).click(this.click_test_action); }
this.results_show(); $(document).click(this.click_test_action);
} else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) { this.results_show();
evt.preventDefault(); } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
this.results_toggle(); evt.preventDefault();
this.results_toggle();
}
return this.activate_field();
} else {
return this.pending_destroy_click = false;
} }
return this.activate_field();
} else {
return this.pending_destroy_click = false;
} }
}; };
Chosen.prototype.mouse_enter = function() { Chosen.prototype.mouse_enter = function() {
@ -243,6 +260,7 @@
} }
} }
} }
this.search_field_disabled();
this.show_search_field_default(); this.show_search_field_default();
this.search_field_scale(); this.search_field_scale();
this.search_results.html(content); this.search_results.html(content);
@ -793,4 +811,4 @@
return parser.parsed; return parser.parsed;
}; };
this.SelectParser = SelectParser; this.SelectParser = SelectParser;
}).call(this); }).call(this);

View File

@ -1288,7 +1288,7 @@
</footer> </footer>
</div> </div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script> <script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
$(".chzn-select").chosen(); $(".chzn-select").chosen();