Merge branch 'master' of https://github.com/h3adache/chosen into h3adache-master

Conflicts:
	chosen/chosen.jquery.js
	chosen/chosen.jquery.min.js
	coffee/chosen.jquery.coffee
	example.jquery.html
This commit is contained in:
Patrick Filler 2011-09-12 17:21:49 -04:00
commit 718f500c9a
4 changed files with 27 additions and 16 deletions

View file

@ -11,25 +11,30 @@
/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
*/ var $, Chosen, get_side_border_padding, root;
*/
var $, Chosen, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
root = this;
$ = jQuery;
$.fn.extend({
<<<<<<< HEAD
chosen: function(data, options) {
if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
return this;
}
=======
chosen: function(options) {
>>>>>>> f9674e7db221f119f1f5fb8e33a277c3b37ee013
return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) {
return new Chosen(this, data, options);
return new Chosen(this, options);
}
});
}
});
Chosen = (function() {
function Chosen(elmn) {
this.set_default_values();
function Chosen(elmn, options) {
this.set_default_values(options || {});
this.form_field = elmn;
this.form_field_jq = $(this.form_field);
this.is_multiple = this.form_field.multiple;
@ -39,7 +44,7 @@
this.register_observers();
this.form_field_jq.addClass("chzn-done");
}
Chosen.prototype.set_default_values = function() {
Chosen.prototype.set_default_values = function(options) {
this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt);
}, this);
@ -48,7 +53,8 @@
this.results_showing = false;
this.result_highlighted = null;
this.result_single_selected = null;
return this.choices = 0;
this.choices = 0;
return this.results_none_found = options.no_results_text || "No results match";
};
Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width;
@ -546,7 +552,7 @@
};
Chosen.prototype.no_results = function(terms) {
var no_results_html;
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html);
};

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,8 @@
/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
*/ var Chosen, get_side_border_padding, root;
*/
var Chosen, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
root = this;
Chosen = (function() {

View file

@ -6,18 +6,17 @@ root = this
$ = jQuery
$.fn.extend({
chosen: (data, options) ->
# Do no harm and return as soon as possible for unsupported browsers, namely IE6 and IE7
chosen: (options) ->
return this if $.browser is "msie" and ($.browser.version is "6.0" or $.browser.version is "7.0")
$(this).each((input_field) ->
new Chosen(this, data, options) unless ($ this).hasClass "chzn-done"
new Chosen(this, options) unless ($ this).hasClass "chzn-done"
)
})
class Chosen
constructor: (elmn) ->
this.set_default_values()
constructor: (elmn, options) ->
this.set_default_values(options or {})
@form_field = elmn
@form_field_jq = $ @form_field
@ -30,7 +29,7 @@ class Chosen
this.register_observers()
@form_field_jq.addClass "chzn-done"
set_default_values: ->
set_default_values: (options) ->
@click_test_action = (evt) => this.test_active_click(evt)
@active_field = false
@ -39,6 +38,7 @@ class Chosen
@result_highlighted = null
@result_single_selected = null
@choices = 0
@results_none_found = options.no_results_text or "No results match"
set_up_html: ->
@container_id = if @form_field.id.length then @form_field.id.replace(/(:|\.)/g, '_') else this.generate_field_id()
@ -467,7 +467,7 @@ class Chosen
this.result_do_highlight do_high if do_high?
no_results: (terms) ->
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>')
no_results_html = $('<li class="no-results">' + @results_none_found + ' "<span></span>"</li>')
no_results_html.find("span").first().html(terms)
@search_results.append no_results_html