Updating to latest version
This commit is contained in:
parent
18ea6aa7a6
commit
a3bda96ce9
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 396 B |
|
@ -101,8 +101,10 @@
|
|||
}
|
||||
.chzn-container-single .chzn-search {
|
||||
padding: 3px 4px;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
z-index: 1010;
|
||||
}
|
||||
.chzn-container-single .chzn-search input {
|
||||
background: #fff url('chosen-sprite.png') no-repeat 100% -22px;
|
||||
|
@ -111,7 +113,6 @@
|
|||
background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
margin: 1px 0;
|
||||
padding: 4px 20px 4px 5px;
|
||||
|
@ -130,6 +131,11 @@
|
|||
}
|
||||
/* @end */
|
||||
|
||||
.chzn-container-single-nosearch .chzn-search input {
|
||||
position: absolute;
|
||||
left: -9000px;
|
||||
}
|
||||
|
||||
/* @group Multi Chosen */
|
||||
.chzn-container-multi .chzn-choices {
|
||||
background-color: #fff;
|
||||
|
@ -355,7 +361,6 @@
|
|||
background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
|
||||
padding: 4px 5px 4px 20px;
|
||||
}
|
||||
|
|
|
@ -1,46 +1,107 @@
|
|||
// Chosen, a Select Box Enhancer for jQuery and Protoype
|
||||
// by Patrick Filler for Harvest, http://getharvest.com
|
||||
//
|
||||
// Version 0.9.4
|
||||
// Version 0.9.5
|
||||
// Full source at https://github.com/harvesthq/chosen
|
||||
// Copyright (c) 2011 Harvest http://getharvest.com
|
||||
|
||||
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
|
||||
// This file is generated by `cake build`, do not edit it by hand.
|
||||
(function() {
|
||||
var SelectParser;
|
||||
SelectParser = (function() {
|
||||
function SelectParser() {
|
||||
this.options_index = 0;
|
||||
this.parsed = [];
|
||||
}
|
||||
SelectParser.prototype.add_node = function(child) {
|
||||
if (child.nodeName === "OPTGROUP") {
|
||||
return this.add_group(child);
|
||||
} else {
|
||||
return this.add_option(child);
|
||||
}
|
||||
};
|
||||
SelectParser.prototype.add_group = function(group) {
|
||||
var group_position, option, _i, _len, _ref, _results;
|
||||
group_position = this.parsed.length;
|
||||
this.parsed.push({
|
||||
array_index: group_position,
|
||||
group: true,
|
||||
label: group.label,
|
||||
children: 0,
|
||||
disabled: group.disabled
|
||||
});
|
||||
_ref = group.childNodes;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
option = _ref[_i];
|
||||
_results.push(this.add_option(option, group_position, group.disabled));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
|
||||
if (option.nodeName === "OPTION") {
|
||||
if (option.text !== "") {
|
||||
if (group_position != null) {
|
||||
this.parsed[group_position].children += 1;
|
||||
}
|
||||
this.parsed.push({
|
||||
array_index: this.parsed.length,
|
||||
options_index: this.options_index,
|
||||
value: option.value,
|
||||
text: option.text,
|
||||
html: option.innerHTML,
|
||||
selected: option.selected,
|
||||
disabled: group_disabled === true ? group_disabled : option.disabled,
|
||||
group_array_index: group_position,
|
||||
classes: option.className,
|
||||
style: option.style.cssText
|
||||
});
|
||||
} else {
|
||||
this.parsed.push({
|
||||
array_index: this.parsed.length,
|
||||
options_index: this.options_index,
|
||||
empty: true
|
||||
});
|
||||
}
|
||||
return this.options_index += 1;
|
||||
}
|
||||
};
|
||||
return SelectParser;
|
||||
})();
|
||||
SelectParser.select_to_array = function(select) {
|
||||
var child, parser, _i, _len, _ref;
|
||||
parser = new SelectParser();
|
||||
_ref = select.childNodes;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
child = _ref[_i];
|
||||
parser.add_node(child);
|
||||
}
|
||||
return parser.parsed;
|
||||
};
|
||||
this.SelectParser = SelectParser;
|
||||
}).call(this);
|
||||
(function() {
|
||||
/*
|
||||
Chosen source: generate output using 'cake build'
|
||||
Copyright (c) 2011 by Harvest
|
||||
*/ var $, Chosen, get_side_border_padding, root;
|
||||
*/
|
||||
var AbstractChosen, root;
|
||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
root = this;
|
||||
$ = jQuery;
|
||||
$.fn.extend({
|
||||
chosen: function(options) {
|
||||
if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
|
||||
return this;
|
||||
}
|
||||
return $(this).each(function(input_field) {
|
||||
if (!($(this)).hasClass("chzn-done")) {
|
||||
return new Chosen(this, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Chosen = (function() {
|
||||
function Chosen(form_field, options) {
|
||||
AbstractChosen = (function() {
|
||||
function AbstractChosen(form_field, options) {
|
||||
this.form_field = form_field;
|
||||
this.options = options != null ? options : {};
|
||||
this.set_default_values();
|
||||
this.form_field_jq = $(this.form_field);
|
||||
this.is_multiple = this.form_field.multiple;
|
||||
this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
|
||||
this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
|
||||
this.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option";
|
||||
this.setup();
|
||||
this.set_up_html();
|
||||
this.register_observers();
|
||||
this.form_field_jq.addClass("chzn-done");
|
||||
this.finish_setup();
|
||||
}
|
||||
Chosen.prototype.set_default_values = function() {
|
||||
AbstractChosen.prototype.set_default_values = function() {
|
||||
this.click_test_action = __bind(function(evt) {
|
||||
return this.test_active_click(evt);
|
||||
}, this);
|
||||
|
@ -53,9 +114,161 @@
|
|||
this.result_highlighted = null;
|
||||
this.result_single_selected = null;
|
||||
this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
||||
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
||||
this.choices = 0;
|
||||
return this.results_none_found = this.options.no_results_text || "No results match";
|
||||
};
|
||||
AbstractChosen.prototype.mouse_enter = function() {
|
||||
return this.mouse_on_container = true;
|
||||
};
|
||||
AbstractChosen.prototype.mouse_leave = function() {
|
||||
return this.mouse_on_container = false;
|
||||
};
|
||||
AbstractChosen.prototype.input_focus = function(evt) {
|
||||
if (!this.active_field) {
|
||||
return setTimeout((__bind(function() {
|
||||
return this.container_mousedown();
|
||||
}, this)), 50);
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.input_blur = function(evt) {
|
||||
if (!this.mouse_on_container) {
|
||||
this.active_field = false;
|
||||
return setTimeout((__bind(function() {
|
||||
return this.blur_test();
|
||||
}, this)), 100);
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.result_add_option = function(option) {
|
||||
var classes, style;
|
||||
if (!option.disabled) {
|
||||
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");
|
||||
}
|
||||
if (option.group_array_index != null) {
|
||||
classes.push("group-option");
|
||||
}
|
||||
if (option.classes !== "") {
|
||||
classes.push(option.classes);
|
||||
}
|
||||
style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
|
||||
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.results_update_field = function() {
|
||||
this.result_clear_highlight();
|
||||
this.result_single_selected = null;
|
||||
return this.results_build();
|
||||
};
|
||||
AbstractChosen.prototype.results_toggle = function() {
|
||||
if (this.results_showing) {
|
||||
return this.results_hide();
|
||||
} else {
|
||||
return this.results_show();
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.results_search = function(evt) {
|
||||
if (this.results_showing) {
|
||||
return this.winnow_results();
|
||||
} else {
|
||||
return this.results_show();
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.keyup_checker = function(evt) {
|
||||
var stroke, _ref;
|
||||
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
||||
this.search_field_scale();
|
||||
switch (stroke) {
|
||||
case 8:
|
||||
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
|
||||
return this.keydown_backstroke();
|
||||
} else if (!this.pending_backstroke) {
|
||||
this.result_clear_highlight();
|
||||
return this.results_search();
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
evt.preventDefault();
|
||||
if (this.results_showing) {
|
||||
return this.result_select(evt);
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
if (this.results_showing) {
|
||||
return this.results_hide();
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
case 38:
|
||||
case 40:
|
||||
case 16:
|
||||
case 91:
|
||||
case 17:
|
||||
break;
|
||||
default:
|
||||
return this.results_search();
|
||||
}
|
||||
};
|
||||
AbstractChosen.prototype.generate_field_id = function() {
|
||||
var new_id;
|
||||
new_id = this.generate_random_id();
|
||||
this.form_field.id = new_id;
|
||||
return new_id;
|
||||
};
|
||||
AbstractChosen.prototype.generate_random_char = function() {
|
||||
var chars, newchar, rand;
|
||||
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
||||
rand = Math.floor(Math.random() * chars.length);
|
||||
return newchar = chars.substring(rand, rand + 1);
|
||||
};
|
||||
return AbstractChosen;
|
||||
})();
|
||||
root.AbstractChosen = AbstractChosen;
|
||||
}).call(this);
|
||||
(function() {
|
||||
/*
|
||||
Chosen source: generate output using 'cake build'
|
||||
Copyright (c) 2011 by Harvest
|
||||
*/
|
||||
var $, Chosen, get_side_border_padding, root;
|
||||
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
|
||||
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
|
||||
function ctor() { this.constructor = child; }
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor;
|
||||
child.__super__ = parent.prototype;
|
||||
return child;
|
||||
}, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
root = this;
|
||||
$ = jQuery;
|
||||
$.fn.extend({
|
||||
chosen: function(options) {
|
||||
if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
|
||||
return this;
|
||||
}
|
||||
return $(this).each(function(input_field) {
|
||||
if (!($(this)).hasClass("chzn-done")) {
|
||||
return new Chosen(this, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Chosen = (function() {
|
||||
__extends(Chosen, AbstractChosen);
|
||||
function Chosen() {
|
||||
Chosen.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
Chosen.prototype.setup = function() {
|
||||
this.form_field_jq = $(this.form_field);
|
||||
return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
|
||||
};
|
||||
Chosen.prototype.finish_setup = function() {
|
||||
return this.form_field_jq.addClass("chzn-done");
|
||||
};
|
||||
Chosen.prototype.set_up_html = function() {
|
||||
var container_div, dd_top, dd_width, sf_width;
|
||||
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
|
||||
|
@ -98,7 +311,10 @@
|
|||
});
|
||||
}
|
||||
this.results_build();
|
||||
return this.set_tab_index();
|
||||
this.set_tab_index();
|
||||
return this.form_field_jq.trigger("liszt:ready", {
|
||||
chosen: this
|
||||
});
|
||||
};
|
||||
Chosen.prototype.register_observers = function() {
|
||||
this.container.mousedown(__bind(function(evt) {
|
||||
|
@ -144,30 +360,30 @@
|
|||
}
|
||||
};
|
||||
Chosen.prototype.search_field_disabled = function() {
|
||||
this.is_disabled = this.form_field_jq.attr('disabled');
|
||||
this.is_disabled = this.form_field_jq[0].disabled;
|
||||
if (this.is_disabled) {
|
||||
this.container.addClass('chzn-disabled');
|
||||
this.search_field.attr('disabled', true);
|
||||
this.search_field[0].disabled = true;
|
||||
if (!this.is_multiple) {
|
||||
this.selected_item.unbind("focus", this.activate_action);
|
||||
}
|
||||
return this.close_field();
|
||||
} else {
|
||||
this.container.removeClass('chzn-disabled');
|
||||
this.search_field.attr('disabled', false);
|
||||
this.search_field[0].disabled = false;
|
||||
if (!this.is_multiple) {
|
||||
return this.selected_item.bind("focus", this.activate_action);
|
||||
}
|
||||
}
|
||||
};
|
||||
Chosen.prototype.container_mousedown = function(evt) {
|
||||
var target_node;
|
||||
var target_closelink;
|
||||
if (!this.is_disabled) {
|
||||
target_node = evt != null ? evt.target.nodeName : null;
|
||||
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
|
||||
if (evt && evt.type === "mousedown") {
|
||||
evt.stopPropagation();
|
||||
}
|
||||
if (!this.pending_destroy_click && target_node !== "ABBR") {
|
||||
if (!this.pending_destroy_click && !target_closelink) {
|
||||
if (!this.active_field) {
|
||||
if (this.is_multiple) {
|
||||
this.search_field.val("");
|
||||
|
@ -189,27 +405,6 @@
|
|||
return this.results_reset(evt);
|
||||
}
|
||||
};
|
||||
Chosen.prototype.mouse_enter = function() {
|
||||
return this.mouse_on_container = true;
|
||||
};
|
||||
Chosen.prototype.mouse_leave = function() {
|
||||
return this.mouse_on_container = false;
|
||||
};
|
||||
Chosen.prototype.input_focus = function(evt) {
|
||||
if (!this.active_field) {
|
||||
return setTimeout((__bind(function() {
|
||||
return this.container_mousedown();
|
||||
}, this)), 50);
|
||||
}
|
||||
};
|
||||
Chosen.prototype.input_blur = function(evt) {
|
||||
if (!this.mouse_on_container) {
|
||||
this.active_field = false;
|
||||
return setTimeout((__bind(function() {
|
||||
return this.blur_test();
|
||||
}, this)), 100);
|
||||
}
|
||||
};
|
||||
Chosen.prototype.blur_test = function(evt) {
|
||||
if (!this.active_field && this.container.hasClass("chzn-container-active")) {
|
||||
return this.close_field();
|
||||
|
@ -256,6 +451,11 @@
|
|||
this.choices = 0;
|
||||
} else if (!this.is_multiple) {
|
||||
this.selected_item.find("span").text(this.default_text);
|
||||
if (this.form_field.options.length <= this.disable_search_threshold) {
|
||||
this.container.addClass("chzn-container-single-nosearch");
|
||||
} else {
|
||||
this.container.removeClass("chzn-container-single-nosearch");
|
||||
}
|
||||
}
|
||||
content = '';
|
||||
_ref = this.results_data;
|
||||
|
@ -270,7 +470,7 @@
|
|||
} else if (data.selected && !this.is_multiple) {
|
||||
this.selected_item.find("span").text(data.text);
|
||||
if (this.allow_single_deselect) {
|
||||
this.selected_item.find("span").first().after("<abbr></abbr>");
|
||||
this.single_deselect_control_build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,27 +489,6 @@
|
|||
return "";
|
||||
}
|
||||
};
|
||||
Chosen.prototype.result_add_option = function(option) {
|
||||
var classes;
|
||||
if (!option.disabled) {
|
||||
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");
|
||||
}
|
||||
if (option.group_array_index != null) {
|
||||
classes.push("group-option");
|
||||
}
|
||||
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.html + '</li>';
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
Chosen.prototype.results_update_field = function() {
|
||||
this.result_clear_highlight();
|
||||
this.result_single_selected = null;
|
||||
return this.results_build();
|
||||
};
|
||||
Chosen.prototype.result_do_highlight = function(el) {
|
||||
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
||||
if (el.length) {
|
||||
|
@ -334,13 +513,6 @@
|
|||
}
|
||||
return this.result_highlight = null;
|
||||
};
|
||||
Chosen.prototype.results_toggle = function() {
|
||||
if (this.results_showing) {
|
||||
return this.results_hide();
|
||||
} else {
|
||||
return this.results_show();
|
||||
}
|
||||
};
|
||||
Chosen.prototype.results_show = function() {
|
||||
var dd_top;
|
||||
if (!this.is_multiple) {
|
||||
|
@ -477,7 +649,7 @@
|
|||
} else {
|
||||
this.selected_item.find("span").first().text(item.text);
|
||||
if (this.allow_single_deselect) {
|
||||
this.selected_item.find("span").first().after("<abbr></abbr>");
|
||||
this.single_deselect_control_build();
|
||||
}
|
||||
}
|
||||
if (!(evt.metaKey && this.is_multiple)) {
|
||||
|
@ -506,11 +678,9 @@
|
|||
this.form_field_jq.trigger("change");
|
||||
return this.search_field_scale();
|
||||
};
|
||||
Chosen.prototype.results_search = function(evt) {
|
||||
if (this.results_showing) {
|
||||
return this.winnow_results();
|
||||
} else {
|
||||
return this.results_show();
|
||||
Chosen.prototype.single_deselect_control_build = function() {
|
||||
if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
|
||||
return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
|
||||
}
|
||||
};
|
||||
Chosen.prototype.winnow_results = function() {
|
||||
|
@ -654,41 +824,6 @@
|
|||
}
|
||||
return this.pending_backstroke = null;
|
||||
};
|
||||
Chosen.prototype.keyup_checker = function(evt) {
|
||||
var stroke, _ref;
|
||||
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
||||
this.search_field_scale();
|
||||
switch (stroke) {
|
||||
case 8:
|
||||
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
|
||||
return this.keydown_backstroke();
|
||||
} else if (!this.pending_backstroke) {
|
||||
this.result_clear_highlight();
|
||||
return this.results_search();
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
evt.preventDefault();
|
||||
if (this.results_showing) {
|
||||
return this.result_select(evt);
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
if (this.results_showing) {
|
||||
return this.results_hide();
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
case 38:
|
||||
case 40:
|
||||
case 16:
|
||||
case 91:
|
||||
case 17:
|
||||
break;
|
||||
default:
|
||||
return this.results_search();
|
||||
}
|
||||
};
|
||||
Chosen.prototype.keydown_checker = function(evt) {
|
||||
var stroke, _ref;
|
||||
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
||||
|
@ -701,6 +836,9 @@
|
|||
this.backstroke_length = this.search_field.val().length;
|
||||
break;
|
||||
case 9:
|
||||
if (this.results_showing && !this.is_multiple) {
|
||||
this.result_select(evt);
|
||||
}
|
||||
this.mouse_on_container = false;
|
||||
break;
|
||||
case 13:
|
||||
|
@ -745,12 +883,6 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
Chosen.prototype.generate_field_id = function() {
|
||||
var new_id;
|
||||
new_id = this.generate_random_id();
|
||||
this.form_field.id = new_id;
|
||||
return new_id;
|
||||
};
|
||||
Chosen.prototype.generate_random_id = function() {
|
||||
var string;
|
||||
string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
|
||||
|
@ -759,12 +891,6 @@
|
|||
}
|
||||
return string;
|
||||
};
|
||||
Chosen.prototype.generate_random_char = function() {
|
||||
var chars, newchar, rand;
|
||||
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
||||
rand = Math.floor(Math.random() * chars.length);
|
||||
return newchar = chars.substring(rand, rand + 1);
|
||||
};
|
||||
return Chosen;
|
||||
})();
|
||||
get_side_border_padding = function(elmt) {
|
||||
|
@ -773,75 +899,3 @@
|
|||
};
|
||||
root.get_side_border_padding = get_side_border_padding;
|
||||
}).call(this);
|
||||
(function() {
|
||||
var SelectParser;
|
||||
SelectParser = (function() {
|
||||
function SelectParser() {
|
||||
this.options_index = 0;
|
||||
this.parsed = [];
|
||||
}
|
||||
SelectParser.prototype.add_node = function(child) {
|
||||
if (child.nodeName === "OPTGROUP") {
|
||||
return this.add_group(child);
|
||||
} else {
|
||||
return this.add_option(child);
|
||||
}
|
||||
};
|
||||
SelectParser.prototype.add_group = function(group) {
|
||||
var group_position, option, _i, _len, _ref, _results;
|
||||
group_position = this.parsed.length;
|
||||
this.parsed.push({
|
||||
array_index: group_position,
|
||||
group: true,
|
||||
label: group.label,
|
||||
children: 0,
|
||||
disabled: group.disabled
|
||||
});
|
||||
_ref = group.childNodes;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
option = _ref[_i];
|
||||
_results.push(this.add_option(option, group_position, group.disabled));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
|
||||
if (option.nodeName === "OPTION") {
|
||||
if (option.text !== "") {
|
||||
if (group_position != null) {
|
||||
this.parsed[group_position].children += 1;
|
||||
}
|
||||
this.parsed.push({
|
||||
array_index: this.parsed.length,
|
||||
options_index: this.options_index,
|
||||
value: option.value,
|
||||
text: option.text,
|
||||
html: option.innerHTML,
|
||||
selected: option.selected,
|
||||
disabled: group_disabled === true ? group_disabled : option.disabled,
|
||||
group_array_index: group_position
|
||||
});
|
||||
} else {
|
||||
this.parsed.push({
|
||||
array_index: this.parsed.length,
|
||||
options_index: this.options_index,
|
||||
empty: true
|
||||
});
|
||||
}
|
||||
return this.options_index += 1;
|
||||
}
|
||||
};
|
||||
return SelectParser;
|
||||
})();
|
||||
SelectParser.select_to_array = function(select) {
|
||||
var child, parser, _i, _len, _ref;
|
||||
parser = new SelectParser();
|
||||
_ref = select.childNodes;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
child = _ref[_i];
|
||||
parser.add_node(child);
|
||||
}
|
||||
return parser.parsed;
|
||||
};
|
||||
this.SelectParser = SelectParser;
|
||||
}).call(this);
|
||||
|
|
Loading…
Reference in a new issue