Update chosen to latest version and use latest version of jQuery

This commit is contained in:
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;
@ -134,13 +137,26 @@
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 (!this.is_disabled) {
if (evt && evt.type === "mousedown") { if (evt && evt.type === "mousedown") {
evt.stopPropagation(); evt.stopPropagation();
} }
@ -159,6 +175,7 @@
} else { } else {
return this.pending_destroy_click = false; return this.pending_destroy_click = false;
} }
}
}; };
Chosen.prototype.mouse_enter = function() { Chosen.prototype.mouse_enter = function() {
return this.mouse_on_container = true; return this.mouse_on_container = true;
@ -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);

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();