Skip to content

Commit

Permalink
Merge pull request RomeroMsk#5 from beowulfenator/master
Browse files Browse the repository at this point in the history
updated chosen to 1.3.0
  • Loading branch information
RomeroMsk committed Feb 5, 2015
2 parents c81c50b + 6f8f171 commit 881afa0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ChosenAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @copyright Copyright (c) 2014 Roman Ovchinnikov
* @link https://github.com/RomeroMsk
* @version 1.0.0
* @version 1.0.1
*/
namespace nex\chosen;

Expand Down
56 changes: 42 additions & 14 deletions assets/js/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Chosen, a Select Box Enhancer for jQuery and Prototype
by Patrick Filler for Harvest, http://getharvest.com
Version 1.1.0
Version 1.3.0
Full source at https://github.com/harvesthq/chosen
Copyright (c) 2011 Harvest http://getharvest.com
Copyright (c) 2011-2014 Harvest http://getharvest.com
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
Expand Down Expand Up @@ -37,7 +37,8 @@ This file is generated by `grunt build`, do not edit it by hand.
group: true,
label: this.escapeExpression(group.label),
children: 0,
disabled: group.disabled
disabled: group.disabled,
classes: group.className
});
_ref = group.childNodes;
_results = [];
Expand Down Expand Up @@ -126,6 +127,7 @@ This file is generated by `grunt build`, do not edit it by hand.
this.setup();
this.set_up_html();
this.register_observers();
this.on_ready();
}

AbstractChosen.prototype.set_default_values = function() {
Expand Down Expand Up @@ -252,15 +254,20 @@ This file is generated by `grunt build`, do not edit it by hand.
};

AbstractChosen.prototype.result_add_group = function(group) {
var group_el;
var classes, group_el;
if (!(group.search_match || group.group_match)) {
return '';
}
if (!(group.active_options > 0)) {
return '';
}
classes = [];
classes.push("group-result");
if (group.classes) {
classes.push(group.classes);
}
group_el = document.createElement("li");
group_el.className = "group-result";
group_el.className = classes.join(" ");
group_el.innerHTML = group.search_text;
return this.outerHTML(group_el);
};
Expand Down Expand Up @@ -309,14 +316,13 @@ This file is generated by `grunt build`, do not edit it by hand.
};

AbstractChosen.prototype.winnow_results = function() {
var escapedSearchText, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
this.no_results_clear();
results = 0;
searchText = this.get_search_text();
escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
regexAnchor = this.search_contains ? "" : "^";
regex = new RegExp(regexAnchor + escapedSearchText, 'i');
zregex = new RegExp(escapedSearchText, 'i');
regex = this.get_search_regex(escapedSearchText);
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
Expand All @@ -335,7 +341,7 @@ This file is generated by `grunt build`, do not edit it by hand.
results_group.active_options += 1;
}
if (!(option.group && !this.group_search)) {
option.search_text = option.group ? option.label : option.html;
option.search_text = option.group ? option.label : option.text;
option.search_match = this.search_string_match(option.search_text, regex);
if (option.search_match && !option.group) {
results += 1;
Expand Down Expand Up @@ -365,6 +371,12 @@ This file is generated by `grunt build`, do not edit it by hand.
}
};

AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
var regex_anchor;
regex_anchor = this.search_contains ? "" : "^";
return new RegExp(regex_anchor + escaped_search_string, 'i');
};

AbstractChosen.prototype.search_string_match = function(search_string, regex) {
var part, parts, _i, _len;
if (regex.test(search_string)) {
Expand Down Expand Up @@ -531,9 +543,9 @@ This file is generated by `grunt build`, do not edit it by hand.
var $this, chosen;
$this = $(this);
chosen = $this.data('chosen');
if (options === 'destroy' && chosen) {
if (options === 'destroy' && chosen instanceof Chosen) {
chosen.destroy();
} else if (!chosen) {
} else if (!(chosen instanceof Chosen)) {
$this.data('chosen', new Chosen(this, options));
}
});
Expand Down Expand Up @@ -593,14 +605,23 @@ This file is generated by `grunt build`, do not edit it by hand.
}
this.results_build();
this.set_tab_index();
this.set_label_behavior();
return this.set_label_behavior();
};

Chosen.prototype.on_ready = function() {
return this.form_field_jq.trigger("chosen:ready", {
chosen: this
});
};

Chosen.prototype.register_observers = function() {
var _this = this;
this.container.bind('touchstart.chosen', function(evt) {
_this.container_mousedown(evt);
});
this.container.bind('touchend.chosen', function(evt) {
_this.container_mouseup(evt);
});
this.container.bind('mousedown.chosen', function(evt) {
_this.container_mousedown(evt);
});
Expand Down Expand Up @@ -733,7 +754,7 @@ This file is generated by `grunt build`, do not edit it by hand.
Chosen.prototype.search_results_mousewheel = function(evt) {
var delta;
if (evt.originalEvent) {
delta = -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
}
if (delta != null) {
evt.preventDefault();
Expand Down Expand Up @@ -1163,7 +1184,14 @@ This file is generated by `grunt build`, do not edit it by hand.
this.mouse_on_container = false;
break;
case 13:
evt.preventDefault();
if (this.results_showing) {
evt.preventDefault();
}
break;
case 32:
if (this.disable_search) {
evt.preventDefault();
}
break;
case 38:
evt.preventDefault();
Expand Down

0 comments on commit 881afa0

Please sign in to comment.