Permalink
Browse files

cake build

  • Loading branch information...
1 parent ef1a047 commit 1b6df2a34a24dcfa90998f2db3e8aa410cd8b8d0 @koenpunt koenpunt committed Mar 26, 2013
Showing with 37 additions and 95 deletions.
  1. +17 −47 chosen/chosen.jquery.js
  2. +1 −1 chosen/chosen.jquery.min.js
  3. +18 −46 chosen/chosen.proto.js
  4. +1 −1 chosen/chosen.proto.min.js
View
@@ -11,6 +11,7 @@
var SelectParser;
SelectParser = (function() {
+
function SelectParser() {
this.options_index = 0;
this.parsed = [];
@@ -26,7 +27,6 @@
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,
@@ -79,7 +79,6 @@
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++) {
@@ -92,6 +91,7 @@
this.SelectParser = SelectParser;
}).call(this);
+
/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
@@ -104,6 +104,7 @@ Copyright (c) 2011 by Harvest
root = this;
AbstractChosen = (function() {
+
function AbstractChosen(form_field, options) {
this.form_field = form_field;
this.options = options != null ? options : {};
@@ -118,7 +119,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen.prototype.set_default_values = function() {
var _this = this;
-
this.click_test_action = function(evt) {
return _this.test_active_click(evt);
};
@@ -162,7 +162,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen.prototype.input_focus = function(evt) {
var _this = this;
-
if (this.is_multiple) {
if (!this.active_field) {
return setTimeout((function() {
@@ -178,7 +177,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen.prototype.input_blur = function(evt) {
var _this = this;
-
if (!this.mouse_on_container) {
this.active_field = false;
return setTimeout((function() {
@@ -189,7 +187,6 @@ Copyright (c) 2011 by Harvest
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"];
@@ -237,7 +234,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen.prototype.keyup_checker = function(evt) {
var stroke, _ref;
-
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
switch (stroke) {
@@ -274,15 +270,13 @@ Copyright (c) 2011 by Harvest
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 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
rand = Math.floor(Math.random() * chars.length);
return newchar = chars.substring(rand, rand + 1);
@@ -295,14 +289,15 @@ Copyright (c) 2011 by Harvest
root.AbstractChosen = AbstractChosen;
}).call(this);
+
/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
*/
(function() {
- var $, Chosen, get_side_border_padding, root, _ref,
+ var $, Chosen, get_side_border_padding, root,
__hasProp = {}.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; };
@@ -313,7 +308,6 @@ Copyright (c) 2011 by Harvest
$.fn.extend({
chosen: function(options) {
var browser, match, ua;
-
ua = navigator.userAgent.toLowerCase();
match = /(msie) ([\w.]+)/.exec(ua) || [];
browser = {
@@ -325,7 +319,6 @@ Copyright (c) 2011 by Harvest
}
return this.each(function(input_field) {
var $this;
-
$this = $(this);
if (!$this.hasClass("chzn-done")) {
return $this.data('chosen', new Chosen(this, options));
@@ -335,11 +328,11 @@ Copyright (c) 2011 by Harvest
});
Chosen = (function(_super) {
+
__extends(Chosen, _super);
function Chosen() {
- _ref = Chosen.__super__.constructor.apply(this, arguments);
- return _ref;
+ return Chosen.__super__.constructor.apply(this, arguments);
}
Chosen.prototype.setup = function() {
@@ -354,7 +347,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.set_up_html = function() {
var container_classes, container_div, container_props, dd_top, dd_width, sf_width;
-
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
this.container_id += "_chzn";
container_classes = ["chzn-container"];
@@ -411,7 +403,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.register_observers = function() {
var _this = this;
-
this.container.mousedown(function(evt) {
_this.container_mousedown(evt);
});
@@ -485,7 +476,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.container_mousedown = function(evt) {
var target_closelink;
-
if (!this.is_disabled) {
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown" && !this.results_showing) {
@@ -548,8 +538,7 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.results_build = function() {
- var content, data, _i, _len, _ref1;
-
+ var content, data, _i, _len, _ref;
this.parsing = true;
this.results_data = root.SelectParser.select_to_array(this.form_field);
if (this.is_multiple && this.choices > 0) {
@@ -564,9 +553,9 @@ Copyright (c) 2011 by Harvest
}
}
content = '';
- _ref1 = this.results_data;
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- data = _ref1[_i];
+ _ref = this.results_data;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ data = _ref[_i];
if (data.group) {
content += this.result_add_group(data);
} else if (!data.empty) {
@@ -599,7 +588,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.result_do_highlight = function(el) {
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
-
if (el.length) {
this.result_clear_highlight();
this.result_highlight = el;
@@ -626,7 +614,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.results_show = function() {
var dd_top;
-
if (!this.is_multiple) {
this.selected_item.addClass("chzn-single-with-drop");
if (this.result_single_selected) {
@@ -668,7 +655,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.set_tab_index = function(el) {
var ti;
-
if (this.form_field_jq.attr("tabindex")) {
ti = this.form_field_jq.attr("tabindex");
this.form_field_jq.attr("tabindex", -1);
@@ -688,7 +674,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.search_results_mouseup = function(evt) {
var target;
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
@@ -699,7 +684,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.search_results_mouseover = function(evt) {
var target;
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target) {
return this.result_do_highlight(target);
@@ -722,7 +706,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.choice_build = function(item) {
var choice_id, html, link,
_this = this;
-
if (this.is_multiple && this.max_selected_options <= this.choices) {
this.form_field_jq.trigger("liszt:maxselected", {
chosen: this
@@ -786,7 +769,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;
-
if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
@@ -835,7 +817,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
-
result_data = this.results_data[pos];
if (!this.form_field.options[result_data.options_index].disabled) {
result_data.selected = false;
@@ -861,17 +842,16 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.winnow_results = function() {
- var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;
-
+ var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref;
this.no_results_clear();
results = 0;
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
regexAnchor = this.search_contains ? "" : "^";
regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
- _ref1 = this.results_data;
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- option = _ref1[_i];
+ _ref = this.results_data;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ option = _ref[_i];
if (!option.disabled && !option.empty) {
if (option.group) {
$('#' + option.dom_id).css('display', 'none');
@@ -925,7 +905,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.winnow_results_clear = function() {
var li, lis, _i, _len, _results;
-
this.search_field.val("");
lis = this.search_results.find("li");
_results = [];
@@ -945,7 +924,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.winnow_results_set_highlight = function() {
var do_high, selected_results;
-
if (!this.result_highlight) {
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
@@ -957,7 +935,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.no_results = function(terms) {
var no_results_html;
-
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);
@@ -969,7 +946,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.keydown_arrow = function() {
var first_active, next_sib;
-
if (!this.result_highlight) {
first_active = this.search_results.find("li.active-result").first();
if (first_active) {
@@ -988,7 +964,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.keyup_arrow = function() {
var prev_sibs;
-
if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
@@ -1006,7 +981,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.keydown_backstroke = function() {
var next_available_destroy;
-
if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.find("a").first());
return this.clear_backstroke();
@@ -1031,9 +1005,8 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.keydown_checker = function(evt) {
- var stroke, _ref1;
-
- stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
+ var stroke, _ref;
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
this.clear_backstroke();
@@ -1063,7 +1036,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;
-
if (this.is_multiple) {
h = 0;
w = 0;
@@ -1095,7 +1067,6 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.generate_random_id = function() {
var string;
-
string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
while ($("#" + string).length > 0) {
string += this.generate_random_char();
@@ -1111,7 +1082,6 @@ Copyright (c) 2011 by Harvest
get_side_border_padding = function(elmt) {
var side_border_padding;
-
return side_border_padding = elmt.outerWidth() - elmt.width();
};
Oops, something went wrong.

0 comments on commit 1b6df2a

Please sign in to comment.