Add options object for both prototype and jquery version.
This commit is contained in:
parent
718f500c9a
commit
800e3d5502
6 changed files with 23 additions and 25 deletions
|
@ -11,20 +11,15 @@
|
||||||
/*
|
/*
|
||||||
Chosen source: generate output using 'cake build'
|
Chosen source: generate output using 'cake build'
|
||||||
Copyright (c) 2011 by Harvest
|
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); }; };
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
root = this;
|
root = this;
|
||||||
$ = jQuery;
|
$ = jQuery;
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
<<<<<<< HEAD
|
chosen: function(options) {
|
||||||
chosen: function(data, options) {
|
|
||||||
if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
|
if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
chosen: function(options) {
|
|
||||||
>>>>>>> f9674e7db221f119f1f5fb8e33a277c3b37ee013
|
|
||||||
return $(this).each(function(input_field) {
|
return $(this).each(function(input_field) {
|
||||||
if (!($(this)).hasClass("chzn-done")) {
|
if (!($(this)).hasClass("chzn-done")) {
|
||||||
return new Chosen(this, options);
|
return new Chosen(this, options);
|
||||||
|
@ -34,7 +29,8 @@
|
||||||
});
|
});
|
||||||
Chosen = (function() {
|
Chosen = (function() {
|
||||||
function Chosen(elmn, options) {
|
function Chosen(elmn, options) {
|
||||||
this.set_default_values(options || {});
|
this.options = options || {};
|
||||||
|
this.set_default_values();
|
||||||
this.form_field = elmn;
|
this.form_field = elmn;
|
||||||
this.form_field_jq = $(this.form_field);
|
this.form_field_jq = $(this.form_field);
|
||||||
this.is_multiple = this.form_field.multiple;
|
this.is_multiple = this.form_field.multiple;
|
||||||
|
@ -44,7 +40,7 @@
|
||||||
this.register_observers();
|
this.register_observers();
|
||||||
this.form_field_jq.addClass("chzn-done");
|
this.form_field_jq.addClass("chzn-done");
|
||||||
}
|
}
|
||||||
Chosen.prototype.set_default_values = function(options) {
|
Chosen.prototype.set_default_values = function() {
|
||||||
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);
|
||||||
|
@ -54,7 +50,7 @@
|
||||||
this.result_highlighted = null;
|
this.result_highlighted = null;
|
||||||
this.result_single_selected = null;
|
this.result_single_selected = null;
|
||||||
this.choices = 0;
|
this.choices = 0;
|
||||||
return this.results_none_found = options.no_results_text || "No results match";
|
return this.results_none_found = this.options.no_results_text || "No results match";
|
||||||
};
|
};
|
||||||
Chosen.prototype.set_up_html = function() {
|
Chosen.prototype.set_up_html = function() {
|
||||||
var container_div, dd_top, dd_width, sf_width;
|
var container_div, dd_top, dd_width, sf_width;
|
||||||
|
|
6
chosen/chosen.jquery.min.js
vendored
6
chosen/chosen.jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -11,12 +11,12 @@
|
||||||
/*
|
/*
|
||||||
Chosen source: generate output using 'cake build'
|
Chosen source: generate output using 'cake build'
|
||||||
Copyright (c) 2011 by Harvest
|
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); }; };
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
root = this;
|
root = this;
|
||||||
Chosen = (function() {
|
Chosen = (function() {
|
||||||
function Chosen(elmn) {
|
function Chosen(elmn, options) {
|
||||||
|
this.options = options || {};
|
||||||
this.set_default_values();
|
this.set_default_values();
|
||||||
this.form_field = elmn;
|
this.form_field = elmn;
|
||||||
this.is_multiple = this.form_field.multiple;
|
this.is_multiple = this.form_field.multiple;
|
||||||
|
@ -36,10 +36,11 @@
|
||||||
this.result_highlighted = null;
|
this.result_highlighted = null;
|
||||||
this.result_single_selected = null;
|
this.result_single_selected = null;
|
||||||
this.choices = 0;
|
this.choices = 0;
|
||||||
|
this.results_none_found = this.options.no_results_text || "No results match";
|
||||||
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
|
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
|
||||||
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
|
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
|
||||||
this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
|
this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
|
||||||
return this.no_results_temp = new Template('<li class="no-results">No results match "<span>#{terms}</span>"</li>');
|
return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
|
||||||
};
|
};
|
||||||
Chosen.prototype.set_up_html = function() {
|
Chosen.prototype.set_up_html = function() {
|
||||||
var base_template, container_props, dd_top, dd_width, sf_width;
|
var base_template, container_props, dd_top, dd_width, sf_width;
|
||||||
|
|
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
|
@ -16,7 +16,8 @@ $.fn.extend({
|
||||||
class Chosen
|
class Chosen
|
||||||
|
|
||||||
constructor: (elmn, options) ->
|
constructor: (elmn, options) ->
|
||||||
this.set_default_values(options or {})
|
@options = options or {}
|
||||||
|
this.set_default_values()
|
||||||
|
|
||||||
@form_field = elmn
|
@form_field = elmn
|
||||||
@form_field_jq = $ @form_field
|
@form_field_jq = $ @form_field
|
||||||
|
@ -29,7 +30,7 @@ class Chosen
|
||||||
this.register_observers()
|
this.register_observers()
|
||||||
@form_field_jq.addClass "chzn-done"
|
@form_field_jq.addClass "chzn-done"
|
||||||
|
|
||||||
set_default_values: (options) ->
|
set_default_values: ->
|
||||||
|
|
||||||
@click_test_action = (evt) => this.test_active_click(evt)
|
@click_test_action = (evt) => this.test_active_click(evt)
|
||||||
@active_field = false
|
@active_field = false
|
||||||
|
@ -38,7 +39,7 @@ class Chosen
|
||||||
@result_highlighted = null
|
@result_highlighted = null
|
||||||
@result_single_selected = null
|
@result_single_selected = null
|
||||||
@choices = 0
|
@choices = 0
|
||||||
@results_none_found = options.no_results_text or "No results match"
|
@results_none_found = @options.no_results_text or "No results match"
|
||||||
|
|
||||||
set_up_html: ->
|
set_up_html: ->
|
||||||
@container_id = if @form_field.id.length then @form_field.id.replace(/(:|\.)/g, '_') else this.generate_field_id()
|
@container_id = if @form_field.id.length then @form_field.id.replace(/(:|\.)/g, '_') else this.generate_field_id()
|
||||||
|
|
|
@ -6,7 +6,9 @@ root = this
|
||||||
|
|
||||||
class Chosen
|
class Chosen
|
||||||
|
|
||||||
constructor: (elmn) ->
|
constructor: (elmn, options) ->
|
||||||
|
@options = options or {}
|
||||||
|
|
||||||
this.set_default_values()
|
this.set_default_values()
|
||||||
|
|
||||||
@form_field = elmn
|
@form_field = elmn
|
||||||
|
@ -30,11 +32,13 @@ class Chosen
|
||||||
@result_single_selected = null
|
@result_single_selected = null
|
||||||
@choices = 0
|
@choices = 0
|
||||||
|
|
||||||
|
@results_none_found = @options.no_results_text or "No results match"
|
||||||
|
|
||||||
# HTML Templates
|
# HTML Templates
|
||||||
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
|
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
|
||||||
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
|
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
|
||||||
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
|
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
|
||||||
@no_results_temp = new Template('<li class="no-results">No results match "<span>#{terms}</span>"</li>')
|
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
|
||||||
|
|
||||||
|
|
||||||
set_up_html: ->
|
set_up_html: ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue