ing-web-es 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ing-web-es might be problematic. Click here for more details.

Files changed (207) hide show
  1. package/45210.py +84 -0
  2. package/EMBEDDED_IFRAME_ON_WEB_PAGE.flv +0 -0
  3. package/FinalPoc.ogx +0 -0
  4. package/SCOPE_ing +20 -0
  5. package/brandportal.ing.com/dump-scripts.py +83 -0
  6. package/brandportal.ing.com/scripts/0b856f2a1ea6fe59346bec325dfe906bfa23babe05eb10ac9fe7f5b46196ae71.js +0 -0
  7. package/brandportal.ing.com/scripts/accounting.min.js +155 -0
  8. package/brandportal.ing.com/scripts/assetWindowContainer.bundle.js +23827 -0
  9. package/brandportal.ing.com/scripts/assets.js +1223 -0
  10. package/brandportal.ing.com/scripts/bootstrap-select.min.js +1287 -0
  11. package/brandportal.ing.com/scripts/bootstrap.min.js +1530 -0
  12. package/brandportal.ing.com/scripts/chosen.jquery.min.js +1238 -0
  13. package/brandportal.ing.com/scripts/core.main.js +1059 -0
  14. package/brandportal.ing.com/scripts/en_120.js +5247 -0
  15. package/brandportal.ing.com/scripts/hoverIntent.js +139 -0
  16. package/brandportal.ing.com/scripts/jquery-3.5.1.min.js +3242 -0
  17. package/brandportal.ing.com/scripts/jquery-ui-timepicker-addon.js +1471 -0
  18. package/brandportal.ing.com/scripts/jquery-ui.min.js +6711 -0
  19. package/brandportal.ing.com/scripts/jquery.are-you-sure.js +197 -0
  20. package/brandportal.ing.com/scripts/jquery.autotabs.js +42 -0
  21. package/brandportal.ing.com/scripts/jquery.backstretch.min.js +543 -0
  22. package/brandportal.ing.com/scripts/jquery.blockUI.js +442 -0
  23. package/brandportal.ing.com/scripts/jquery.datePicker.js +1151 -0
  24. package/brandportal.ing.com/scripts/jquery.dialogextend.2_0_4.pack.js +300 -0
  25. package/brandportal.ing.com/scripts/jquery.fileupload-audio.js +103 -0
  26. package/brandportal.ing.com/scripts/jquery.fileupload-image.js +313 -0
  27. package/brandportal.ing.com/scripts/jquery.fileupload-process.js +172 -0
  28. package/brandportal.ing.com/scripts/jquery.fileupload-ui.js +700 -0
  29. package/brandportal.ing.com/scripts/jquery.fileupload-validate.js +117 -0
  30. package/brandportal.ing.com/scripts/jquery.fileupload-video.js +103 -0
  31. package/brandportal.ing.com/scripts/jquery.fileupload.js +1451 -0
  32. package/brandportal.ing.com/scripts/jquery.form.js +892 -0
  33. package/brandportal.ing.com/scripts/jquery.number.min.js +150 -0
  34. package/brandportal.ing.com/scripts/jquery.ui.datepicker-en.js +26 -0
  35. package/brandportal.ing.com/scripts/jquery.ui.timepicker-en.js +6 -0
  36. package/brandportal.ing.com/scripts/jquery.validate.min.js +844 -0
  37. package/brandportal.ing.com/scripts/layout.bundle.js +673 -0
  38. package/brandportal.ing.com/scripts/load-image.all.min.js +770 -0
  39. package/brandportal.ing.com/scripts/local.bundle.js +310 -0
  40. package/brandportal.ing.com/scripts/moment.min.js +1562 -0
  41. package/brandportal.ing.com/scripts/nl.js +88 -0
  42. package/brandportal.ing.com/scripts/paginator.js +267 -0
  43. package/brandportal.ing.com/scripts/popper.min.js +844 -0
  44. package/brandportal.ing.com/scripts/selectAssetBrowser.bundle.js +47577 -0
  45. package/brandportal.ing.com/scripts/selectables.custom.js +174 -0
  46. package/brandportal.ing.com/scripts/slick.min.js +687 -0
  47. package/brandportal.ing.com/scripts/superfish.js +279 -0
  48. package/brandportal.ing.com/scripts/upload-main.js +90 -0
  49. package/brandportal.ing.com/scripts/video.min.js +12517 -0
  50. package/brandportal.ing.com/scripts/videojs.wavesurfer.min.js +495 -0
  51. package/brandportal.ing.com/scripts/wavesurfer.min.js +2775 -0
  52. package/burping.json +783 -0
  53. package/dump-scripts.py +83 -0
  54. package/ing.com.txt +365 -0
  55. package/ing.com_200List.txt +30 -0
  56. package/ing.com_DIRSEARCH.txt +8220 -0
  57. package/ing_notes +1 -0
  58. package/nmap +1224 -0
  59. package/nuclei_ing.com.txt +9 -0
  60. package/package.json +12 -0
  61. package/poc.html +116 -0
  62. package/scope.txt +141 -0
  63. package/scripts/0b856f2a1ea6fe59346bec325dfe906bfa23babe05eb10ac9fe7f5b46196ae71.js +0 -0
  64. package/scripts/AliasCtrl.js +0 -0
  65. package/scripts/ChangePasswordCtrl.js +0 -0
  66. package/scripts/CustomErrorCtrl.js +0 -0
  67. package/scripts/ErrorCtrl.js +0 -0
  68. package/scripts/HeaderCtrl.js +0 -0
  69. package/scripts/LoginValidationService.js +0 -0
  70. package/scripts/NipValidator.js +0 -0
  71. package/scripts/Psd2AliasCtrl.js +0 -0
  72. package/scripts/RegonValidator.js +0 -0
  73. package/scripts/SmsCtrl.js +0 -0
  74. package/scripts/TimeZoneInfoCollectorPanel-ver-1634885786000.js +2 -0
  75. package/scripts/accounting.min.js +155 -0
  76. package/scripts/angular-animate.min.js +0 -0
  77. package/scripts/angular-cookies.min.js +0 -0
  78. package/scripts/angular-translate.min.js +0 -0
  79. package/scripts/angular-ui-router.js +0 -0
  80. package/scripts/angular.min.js +0 -0
  81. package/scripts/assetWindowContainer.bundle.js +23827 -0
  82. package/scripts/assets.js +1223 -0
  83. package/scripts/bootstrap-select.min.js +1287 -0
  84. package/scripts/bootstrap.min.js +1530 -0
  85. package/scripts/chosen.jquery.min.js +1238 -0
  86. package/scripts/core.main.js +1059 -0
  87. package/scripts/criticalMessageService.js +0 -0
  88. package/scripts/data-dir-cookies-bar.js +0 -0
  89. package/scripts/data-dir-progress-pie.js +0 -0
  90. package/scripts/dir-critical-message.js +0 -0
  91. package/scripts/dir-login-keyboard.js +0 -0
  92. package/scripts/dir-login-validation.js +0 -0
  93. package/scripts/en_120.js +5247 -0
  94. package/scripts/environment.js +22 -0
  95. package/scripts/gemius-init.js +0 -0
  96. package/scripts/gemiusID.js +0 -0
  97. package/scripts/hoverIntent.js +139 -0
  98. package/scripts/ing-vendor.min-ver-1634885786000.js +2 -0
  99. package/scripts/ing-ver-1634885786000.js +2 -0
  100. package/scripts/jquery-3.5.1.min.js +3242 -0
  101. package/scripts/jquery-ui-timepicker-addon.js +1471 -0
  102. package/scripts/jquery-ui.min.js +6711 -0
  103. package/scripts/jquery.are-you-sure.js +197 -0
  104. package/scripts/jquery.autotabs.js +42 -0
  105. package/scripts/jquery.backstretch.min.js +543 -0
  106. package/scripts/jquery.blockUI.js +442 -0
  107. package/scripts/jquery.datePicker.js +1151 -0
  108. package/scripts/jquery.dialogextend.2_0_4.pack.js +300 -0
  109. package/scripts/jquery.fileupload-audio.js +103 -0
  110. package/scripts/jquery.fileupload-image.js +313 -0
  111. package/scripts/jquery.fileupload-process.js +172 -0
  112. package/scripts/jquery.fileupload-ui.js +700 -0
  113. package/scripts/jquery.fileupload-validate.js +117 -0
  114. package/scripts/jquery.fileupload-video.js +103 -0
  115. package/scripts/jquery.fileupload.js +1451 -0
  116. package/scripts/jquery.form.js +892 -0
  117. package/scripts/jquery.number.min.js +150 -0
  118. package/scripts/jquery.ui.datepicker-en.js +26 -0
  119. package/scripts/jquery.ui.timepicker-en.js +6 -0
  120. package/scripts/jquery.validate.min.js +844 -0
  121. package/scripts/jsbn-ver-1634886518000.js +2 -0
  122. package/scripts/layout.bundle.js +673 -0
  123. package/scripts/load-image.all.min.js +770 -0
  124. package/scripts/local.bundle.js +310 -0
  125. package/scripts/login-app.js +0 -0
  126. package/scripts/login-en.js +0 -0
  127. package/scripts/login-pl.js +0 -0
  128. package/scripts/login-states.js +0 -0
  129. package/scripts/main.js +23 -0
  130. package/scripts/mobileAuthCtrl.js +0 -0
  131. package/scripts/moment.min.js +1562 -0
  132. package/scripts/mon_ing_init.js +22 -0
  133. package/scripts/nl.js +88 -0
  134. package/scripts/paginator.js +267 -0
  135. package/scripts/pinLoginDefault-ver-1634885786000.js +2 -0
  136. package/scripts/popper.min.js +844 -0
  137. package/scripts/prng4-ver-1634886518000.js +2 -0
  138. package/scripts/psd2-states.js +0 -0
  139. package/scripts/rng-ver-1634886518000.js +2 -0
  140. package/scripts/rsa_jsbn-ver-1634886518000.js +2 -0
  141. package/scripts/selectAssetBrowser.bundle.js +47577 -0
  142. package/scripts/selectables.custom.js +174 -0
  143. package/scripts/sgemius.js +0 -0
  144. package/scripts/sha1.js +0 -0
  145. package/scripts/slick.min.js +687 -0
  146. package/scripts/superfish.js +279 -0
  147. package/scripts/upload-main.js +90 -0
  148. package/scripts/video.min.js +12517 -0
  149. package/scripts/videojs.wavesurfer.min.js +495 -0
  150. package/scripts/wavesurfer.min.js +2775 -0
  151. package/scripts/webtrekk_v4-ver-1634885786000.js +2 -0
  152. package/setup-feature.js +47 -0
  153. package/start.ingbusiness.pl/dump-scripts.py +83 -0
  154. package/start.ingbusiness.pl/form.html_v=202110040949 +52 -0
  155. package/start.ingbusiness.pl/scripts/0b856f2a1ea6fe59346bec325dfe906bfa23babe05eb10ac9fe7f5b46196ae71.js +0 -0
  156. package/start.ingbusiness.pl/scripts/AliasCtrl.js +136 -0
  157. package/start.ingbusiness.pl/scripts/ChangePasswordCtrl.js +162 -0
  158. package/start.ingbusiness.pl/scripts/CustomErrorCtrl.js +9 -0
  159. package/start.ingbusiness.pl/scripts/ErrorCtrl.js +30 -0
  160. package/start.ingbusiness.pl/scripts/HeaderCtrl.js +84 -0
  161. package/start.ingbusiness.pl/scripts/LoginService.js +86 -0
  162. package/start.ingbusiness.pl/scripts/LoginValidationService.js +52 -0
  163. package/start.ingbusiness.pl/scripts/NipValidator.js +30 -0
  164. package/start.ingbusiness.pl/scripts/PasswordCtrl.js +179 -0
  165. package/start.ingbusiness.pl/scripts/Psd2AliasCtrl.js +12 -0
  166. package/start.ingbusiness.pl/scripts/RegonValidator.js +73 -0
  167. package/start.ingbusiness.pl/scripts/RequestService.js +26 -0
  168. package/start.ingbusiness.pl/scripts/SmsCtrl.js +91 -0
  169. package/start.ingbusiness.pl/scripts/UnlockUserCtrl.js +79 -0
  170. package/start.ingbusiness.pl/scripts/angular-animate.min.js +1535 -0
  171. package/start.ingbusiness.pl/scripts/angular-cookies.min.js +62 -0
  172. package/start.ingbusiness.pl/scripts/angular-translate.min.js +871 -0
  173. package/start.ingbusiness.pl/scripts/angular-ui-router.js +1561 -0
  174. package/start.ingbusiness.pl/scripts/angular.min.js +9845 -0
  175. package/start.ingbusiness.pl/scripts/criticalMessageService.js +24 -0
  176. package/start.ingbusiness.pl/scripts/data-dir-button-loader.js +30 -0
  177. package/start.ingbusiness.pl/scripts/data-dir-compile-template.js +17 -0
  178. package/start.ingbusiness.pl/scripts/data-dir-cookies-bar.js +37 -0
  179. package/start.ingbusiness.pl/scripts/data-dir-progress-pie.js +102 -0
  180. package/start.ingbusiness.pl/scripts/data-dir-svg-icon.js +633 -0
  181. package/start.ingbusiness.pl/scripts/data-gemius-event.js +119 -0
  182. package/start.ingbusiness.pl/scripts/dir-critical-message.js +9 -0
  183. package/start.ingbusiness.pl/scripts/dir-help-panel-content.js +29 -0
  184. package/start.ingbusiness.pl/scripts/dir-login-keyboard.js +346 -0
  185. package/start.ingbusiness.pl/scripts/dir-login-validation.js +20 -0
  186. package/start.ingbusiness.pl/scripts/dir-nav-links.js +26 -0
  187. package/start.ingbusiness.pl/scripts/dir-title.js +21 -0
  188. package/start.ingbusiness.pl/scripts/gemius-init.js +12 -0
  189. package/start.ingbusiness.pl/scripts/gemiusID.js +32 -0
  190. package/start.ingbusiness.pl/scripts/hashService.js +91 -0
  191. package/start.ingbusiness.pl/scripts/helpPanelPasswordService.js +26 -0
  192. package/start.ingbusiness.pl/scripts/helpPanelService.js +92 -0
  193. package/start.ingbusiness.pl/scripts/jquery-3.5.1.min.js +3242 -0
  194. package/start.ingbusiness.pl/scripts/login-app.js +107 -0
  195. package/start.ingbusiness.pl/scripts/login-en.js +73 -0
  196. package/start.ingbusiness.pl/scripts/login-pl.js +74 -0
  197. package/start.ingbusiness.pl/scripts/login-states.js +156 -0
  198. package/start.ingbusiness.pl/scripts/maskService.js +194 -0
  199. package/start.ingbusiness.pl/scripts/maskUtilService.js +302 -0
  200. package/start.ingbusiness.pl/scripts/mobileAuthCtrl.js +189 -0
  201. package/start.ingbusiness.pl/scripts/psd2-states.js +67 -0
  202. package/start.ingbusiness.pl/scripts/securityPolicyService.js +119 -0
  203. package/start.ingbusiness.pl/scripts/sgemius.js +257 -0
  204. package/start.ingbusiness.pl/scripts/sha1.js +210 -0
  205. package/start.ingbusiness.pl/scripts/sprintf.js +115 -0
  206. package/start.ingbusiness.pl/scripts/tabletScalingService.js +59 -0
  207. package/start.ingbusiness.pl/scripts/userAgentResolverService.js +12 -0
@@ -0,0 +1,1238 @@
1
+ (function() {
2
+ var $, AbstractChosen, Chosen, SelectParser, _ref, __hasProp = {}.hasOwnProperty,
3
+ __extends = function(child, parent) {
4
+ for (var key in parent) {
5
+ if (__hasProp.call(parent, key)) child[key] = parent[key];
6
+ }
7
+
8
+ function ctor() {
9
+ this.constructor = child;
10
+ }
11
+ ctor.prototype = parent.prototype;
12
+ child.prototype = new ctor();
13
+ child.__super__ = parent.prototype;
14
+ return child;
15
+ };
16
+ SelectParser = (function() {
17
+ function SelectParser() {
18
+ this.options_index = 0;
19
+ this.parsed = [];
20
+ }
21
+ SelectParser.prototype.add_node = function(child) {
22
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
23
+ return this.add_group(child);
24
+ } else {
25
+ return this.add_option(child);
26
+ }
27
+ };
28
+ SelectParser.prototype.add_group = function(group) {
29
+ var group_position, option, _i, _len, _ref, _results;
30
+ group_position = this.parsed.length;
31
+ this.parsed.push({
32
+ array_index: group_position,
33
+ group: true,
34
+ label: this.escapeExpression(group.label),
35
+ title: group.title ? group.title : void 0,
36
+ children: 0,
37
+ disabled: group.disabled,
38
+ classes: group.className
39
+ });
40
+ _ref = group.childNodes;
41
+ _results = [];
42
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
43
+ option = _ref[_i];
44
+ _results.push(this.add_option(option, group_position, group.disabled));
45
+ }
46
+ return _results;
47
+ };
48
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
49
+ if (option.nodeName.toUpperCase() === "OPTION") {
50
+ if (option.text !== "") {
51
+ if (group_position != null) {
52
+ this.parsed[group_position].children += 1;
53
+ }
54
+ this.parsed.push({
55
+ array_index: this.parsed.length,
56
+ options_index: this.options_index,
57
+ value: option.value,
58
+ text: option.text,
59
+ html: option.innerHTML,
60
+ title: option.title ? option.title : void 0,
61
+ selected: option.selected,
62
+ disabled: group_disabled === true ? group_disabled : option.disabled,
63
+ group_array_index: group_position,
64
+ group_label: group_position != null ? this.parsed[group_position].label : null,
65
+ classes: option.className,
66
+ style: option.style.cssText
67
+ });
68
+ } else {
69
+ this.parsed.push({
70
+ array_index: this.parsed.length,
71
+ options_index: this.options_index,
72
+ empty: true
73
+ });
74
+ }
75
+ return this.options_index += 1;
76
+ }
77
+ };
78
+ SelectParser.prototype.escapeExpression = function(text) {
79
+ var map, unsafe_chars;
80
+ if ((text == null) || text === false) {
81
+ return "";
82
+ }
83
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
84
+ return text;
85
+ }
86
+ map = {
87
+ "<": "&lt;",
88
+ ">": "&gt;",
89
+ '"': "&quot;",
90
+ "'": "&#x27;",
91
+ "`": "&#x60;"
92
+ };
93
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
94
+ return text.replace(unsafe_chars, function(chr) {
95
+ return map[chr] || "&amp;";
96
+ });
97
+ };
98
+ return SelectParser;
99
+ })();
100
+ SelectParser.select_to_array = function(select) {
101
+ var child, parser, _i, _len, _ref;
102
+ parser = new SelectParser();
103
+ _ref = select.childNodes;
104
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
105
+ child = _ref[_i];
106
+ parser.add_node(child);
107
+ }
108
+ return parser.parsed;
109
+ };
110
+ AbstractChosen = (function() {
111
+ function AbstractChosen(form_field, options) {
112
+ this.form_field = form_field;
113
+ this.options = options != null ? options : {};
114
+ if (!AbstractChosen.browser_is_supported()) {
115
+ return;
116
+ }
117
+ this.is_multiple = this.form_field.multiple;
118
+ this.set_default_text();
119
+ this.set_default_values();
120
+ this.setup();
121
+ this.set_up_html();
122
+ this.register_observers();
123
+ this.on_ready();
124
+ }
125
+ AbstractChosen.prototype.set_default_values = function() {
126
+ var _this = this;
127
+ this.click_test_action = function(evt) {
128
+ return _this.test_active_click(evt);
129
+ };
130
+ this.activate_action = function(evt) {
131
+ return _this.activate_field(evt);
132
+ };
133
+ this.active_field = false;
134
+ this.mouse_on_container = false;
135
+ this.results_showing = false;
136
+ this.result_highlighted = null;
137
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
138
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
139
+ this.disable_search = this.options.disable_search || false;
140
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
141
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
142
+ this.search_contains = this.options.search_contains || false;
143
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
144
+ this.max_selected_options = this.options.max_selected_options || Infinity;
145
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
146
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
147
+ this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
148
+ this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
149
+ return this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
150
+ };
151
+ AbstractChosen.prototype.set_default_text = function() {
152
+ if (this.form_field.getAttribute("data-placeholder")) {
153
+ this.default_text = this.form_field.getAttribute("data-placeholder");
154
+ } else if (this.is_multiple) {
155
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
156
+ } else {
157
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
158
+ }
159
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
160
+ };
161
+ AbstractChosen.prototype.choice_label = function(item) {
162
+ if (this.include_group_label_in_selected && (item.group_label != null)) {
163
+ return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
164
+ } else {
165
+ return item.html;
166
+ }
167
+ };
168
+ AbstractChosen.prototype.mouse_enter = function() {
169
+ return this.mouse_on_container = true;
170
+ };
171
+ AbstractChosen.prototype.mouse_leave = function() {
172
+ return this.mouse_on_container = false;
173
+ };
174
+ AbstractChosen.prototype.input_focus = function(evt) {
175
+ var _this = this;
176
+ if (this.is_multiple) {
177
+ if (!this.active_field) {
178
+ return setTimeout((function() {
179
+ return _this.container_mousedown();
180
+ }), 50);
181
+ }
182
+ } else {
183
+ if (!this.active_field) {
184
+ return this.activate_field();
185
+ }
186
+ }
187
+ };
188
+ AbstractChosen.prototype.input_blur = function(evt) {
189
+ var _this = this;
190
+ if (!this.mouse_on_container) {
191
+ this.active_field = false;
192
+ return setTimeout((function() {
193
+ return _this.blur_test();
194
+ }), 100);
195
+ }
196
+ };
197
+ AbstractChosen.prototype.results_option_build = function(options) {
198
+ var content, data, data_content, shown_results, _i, _len, _ref;
199
+ content = '';
200
+ shown_results = 0;
201
+ _ref = this.results_data;
202
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
203
+ data = _ref[_i];
204
+ data_content = '';
205
+ if (data.group) {
206
+ data_content = this.result_add_group(data);
207
+ } else {
208
+ data_content = this.result_add_option(data);
209
+ }
210
+ if (data_content !== '') {
211
+ shown_results++;
212
+ content += data_content;
213
+ }
214
+ if (options != null ? options.first : void 0) {
215
+ if (data.selected && this.is_multiple) {
216
+ this.choice_build(data);
217
+ } else if (data.selected && !this.is_multiple) {
218
+ this.single_set_selected_text(this.choice_label(data));
219
+ }
220
+ }
221
+ if (shown_results >= this.max_shown_results) {
222
+ break;
223
+ }
224
+ }
225
+ return content;
226
+ };
227
+ AbstractChosen.prototype.result_add_option = function(option) {
228
+ var classes, option_el;
229
+ if (!option.search_match) {
230
+ return '';
231
+ }
232
+ if (!this.include_option_in_results(option)) {
233
+ return '';
234
+ }
235
+ classes = [];
236
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
237
+ classes.push("active-result");
238
+ }
239
+ if (option.disabled && !(option.selected && this.is_multiple)) {
240
+ classes.push("disabled-result");
241
+ }
242
+ if (option.selected) {
243
+ classes.push("result-selected");
244
+ }
245
+ if (option.group_array_index != null) {
246
+ classes.push("group-option");
247
+ }
248
+ if (option.classes !== "") {
249
+ classes.push(option.classes);
250
+ }
251
+ option_el = document.createElement("li");
252
+ option_el.className = classes.join(" ");
253
+ option_el.style.cssText = option.style;
254
+ option_el.setAttribute("data-option-array-index", option.array_index);
255
+ option_el.innerHTML = option.search_text;
256
+ if (option.title) {
257
+ option_el.title = option.title;
258
+ }
259
+ return this.outerHTML(option_el);
260
+ };
261
+ AbstractChosen.prototype.result_add_group = function(group) {
262
+ var classes, group_el;
263
+ if (!(group.search_match || group.group_match)) {
264
+ return '';
265
+ }
266
+ if (!(group.active_options > 0)) {
267
+ return '';
268
+ }
269
+ classes = [];
270
+ classes.push("group-result");
271
+ if (group.classes) {
272
+ classes.push(group.classes);
273
+ }
274
+ group_el = document.createElement("li");
275
+ group_el.className = classes.join(" ");
276
+ group_el.innerHTML = group.search_text;
277
+ if (group.title) {
278
+ group_el.title = group.title;
279
+ }
280
+ return this.outerHTML(group_el);
281
+ };
282
+ AbstractChosen.prototype.results_update_field = function() {
283
+ this.set_default_text();
284
+ if (!this.is_multiple) {
285
+ this.results_reset_cleanup();
286
+ }
287
+ this.result_clear_highlight();
288
+ this.results_build();
289
+ if (this.results_showing) {
290
+ return this.winnow_results();
291
+ }
292
+ };
293
+ AbstractChosen.prototype.reset_single_select_options = function() {
294
+ var result, _i, _len, _ref, _results;
295
+ _ref = this.results_data;
296
+ _results = [];
297
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
298
+ result = _ref[_i];
299
+ if (result.selected) {
300
+ _results.push(result.selected = false);
301
+ } else {
302
+ _results.push(void 0);
303
+ }
304
+ }
305
+ return _results;
306
+ };
307
+ AbstractChosen.prototype.results_toggle = function() {
308
+ if (this.results_showing) {
309
+ return this.results_hide();
310
+ } else {
311
+ return this.results_show();
312
+ }
313
+ };
314
+ AbstractChosen.prototype.results_search = function(evt) {
315
+ if (this.results_showing) {
316
+ return this.winnow_results();
317
+ } else {
318
+ return this.results_show();
319
+ }
320
+ };
321
+ AbstractChosen.prototype.winnow_results = function() {
322
+ var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
323
+ this.no_results_clear();
324
+ results = 0;
325
+ searchText = this.get_search_text();
326
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
327
+ zregex = new RegExp(escapedSearchText, 'i');
328
+ regex = this.get_search_regex(escapedSearchText);
329
+ _ref = this.results_data;
330
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
331
+ option = _ref[_i];
332
+ option.search_match = false;
333
+ results_group = null;
334
+ if (this.include_option_in_results(option)) {
335
+ if (option.group) {
336
+ option.group_match = false;
337
+ option.active_options = 0;
338
+ }
339
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
340
+ results_group = this.results_data[option.group_array_index];
341
+ if (results_group.active_options === 0 && results_group.search_match) {
342
+ results += 1;
343
+ }
344
+ results_group.active_options += 1;
345
+ }
346
+ option.search_text = option.group ? option.label : option.html;
347
+ if (!(option.group && !this.group_search)) {
348
+ option.search_match = this.search_string_match(option.search_text, regex);
349
+ if (option.search_match && !option.group) {
350
+ results += 1;
351
+ }
352
+ if (option.search_match) {
353
+ if (searchText.length) {
354
+ startpos = option.search_text.search(zregex);
355
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
356
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
357
+ }
358
+ if (results_group != null) {
359
+ results_group.group_match = true;
360
+ }
361
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
362
+ option.search_match = true;
363
+ }
364
+ }
365
+ }
366
+ }
367
+ this.result_clear_highlight();
368
+ if (results < 1 && searchText.length) {
369
+ this.update_results_content("");
370
+ return this.no_results(searchText);
371
+ } else {
372
+ this.update_results_content(this.results_option_build());
373
+ return this.winnow_results_set_highlight();
374
+ }
375
+ };
376
+ AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
377
+ var regex_anchor;
378
+ regex_anchor = this.search_contains ? "" : "^";
379
+ return new RegExp(regex_anchor + escaped_search_string, 'i');
380
+ };
381
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
382
+ var part, parts, _i, _len;
383
+ if (regex.test(search_string)) {
384
+ return true;
385
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
386
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
387
+ if (parts.length) {
388
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
389
+ part = parts[_i];
390
+ if (regex.test(part)) {
391
+ return true;
392
+ }
393
+ }
394
+ }
395
+ }
396
+ };
397
+ AbstractChosen.prototype.choices_count = function() {
398
+ var option, _i, _len, _ref;
399
+ if (this.selected_option_count != null) {
400
+ return this.selected_option_count;
401
+ }
402
+ this.selected_option_count = 0;
403
+ _ref = this.form_field.options;
404
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
405
+ option = _ref[_i];
406
+ if (option.selected) {
407
+ this.selected_option_count += 1;
408
+ }
409
+ }
410
+ return this.selected_option_count;
411
+ };
412
+ AbstractChosen.prototype.choices_click = function(evt) {
413
+ evt.preventDefault();
414
+ if (!(this.results_showing || this.is_disabled)) {
415
+ return this.results_show();
416
+ }
417
+ };
418
+ AbstractChosen.prototype.keyup_checker = function(evt) {
419
+ var stroke, _ref;
420
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
421
+ this.search_field_scale();
422
+ switch (stroke) {
423
+ case 8:
424
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
425
+ return this.keydown_backstroke();
426
+ } else if (!this.pending_backstroke) {
427
+ this.result_clear_highlight();
428
+ return this.results_search();
429
+ }
430
+ break;
431
+ case 13:
432
+ evt.preventDefault();
433
+ if (this.results_showing) {
434
+ return this.result_select(evt);
435
+ }
436
+ break;
437
+ case 27:
438
+ if (this.results_showing) {
439
+ this.results_hide();
440
+ }
441
+ return true;
442
+ case 9:
443
+ case 38:
444
+ case 40:
445
+ case 16:
446
+ case 91:
447
+ case 17:
448
+ case 18:
449
+ break;
450
+ default:
451
+ return this.results_search();
452
+ }
453
+ };
454
+ AbstractChosen.prototype.clipboard_event_checker = function(evt) {
455
+ var _this = this;
456
+ return setTimeout((function() {
457
+ return _this.results_search();
458
+ }), 50);
459
+ };
460
+ AbstractChosen.prototype.container_width = function() {
461
+ if (this.options.width != null) {
462
+ return this.options.width;
463
+ } else {
464
+ return "" + this.form_field.offsetWidth + "px";
465
+ }
466
+ };
467
+ AbstractChosen.prototype.include_option_in_results = function(option) {
468
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
469
+ return false;
470
+ }
471
+ if (!this.display_disabled_options && option.disabled) {
472
+ return false;
473
+ }
474
+ if (option.empty) {
475
+ return false;
476
+ }
477
+ return true;
478
+ };
479
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
480
+ this.touch_started = true;
481
+ return this.search_results_mouseover(evt);
482
+ };
483
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
484
+ this.touch_started = false;
485
+ return this.search_results_mouseout(evt);
486
+ };
487
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
488
+ if (this.touch_started) {
489
+ return this.search_results_mouseup(evt);
490
+ }
491
+ };
492
+ AbstractChosen.prototype.outerHTML = function(element) {
493
+ var tmp;
494
+ if (element.outerHTML) {
495
+ return element.outerHTML;
496
+ }
497
+ tmp = document.createElement("div");
498
+ tmp.appendChild(element);
499
+ return tmp.innerHTML;
500
+ };
501
+ AbstractChosen.browser_is_supported = function() {
502
+ if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
503
+ return false;
504
+ }
505
+ if (/Android/i.test(window.navigator.userAgent)) {
506
+ if (/Mobile/i.test(window.navigator.userAgent)) {
507
+ return false;
508
+ }
509
+ }
510
+ if (/IEMobile/i.test(window.navigator.userAgent)) {
511
+ return false;
512
+ }
513
+ if (/Windows Phone/i.test(window.navigator.userAgent)) {
514
+ return false;
515
+ }
516
+ if (/BlackBerry/i.test(window.navigator.userAgent)) {
517
+ return false;
518
+ }
519
+ if (/BB10/i.test(window.navigator.userAgent)) {
520
+ return false;
521
+ }
522
+ if (window.navigator.appName === "Microsoft Internet Explorer") {
523
+ return document.documentMode >= 8;
524
+ }
525
+ return true;
526
+ };
527
+ AbstractChosen.default_multiple_text = "Select Some Options";
528
+ AbstractChosen.default_single_text = "Select an Option";
529
+ AbstractChosen.default_no_result_text = "No results match";
530
+ return AbstractChosen;
531
+ })();
532
+ $ = jQuery;
533
+ $.fn.extend({
534
+ chosen: function(options) {
535
+ if (!AbstractChosen.browser_is_supported()) {
536
+ return this;
537
+ }
538
+ return this.each(function(input_field) {
539
+ var $this, chosen;
540
+ $this = $(this);
541
+ chosen = $this.data('chosen');
542
+ if (options === 'destroy') {
543
+ if (chosen instanceof Chosen) {
544
+ chosen.destroy();
545
+ }
546
+ return;
547
+ }
548
+ if (!(chosen instanceof Chosen)) {
549
+ $this.data('chosen', new Chosen(this, options));
550
+ }
551
+ });
552
+ }
553
+ });
554
+ Chosen = (function(_super) {
555
+ __extends(Chosen, _super);
556
+
557
+ function Chosen() {
558
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
559
+ return _ref;
560
+ }
561
+ Chosen.prototype.setup = function() {
562
+ this.form_field_jq = $(this.form_field);
563
+ this.current_selectedIndex = this.form_field.selectedIndex;
564
+ return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
565
+ };
566
+ Chosen.prototype.set_up_html = function() {
567
+ var container_classes, container_props;
568
+ container_classes = ["chosen-container"];
569
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
570
+ if (this.inherit_select_classes && this.form_field.className) {
571
+ container_classes.push(this.form_field.className);
572
+ }
573
+ if (this.is_rtl) {
574
+ container_classes.push("chosen-rtl");
575
+ }
576
+ container_props = {
577
+ 'class': container_classes.join(' '),
578
+ 'style': "width: " + (this.container_width()) + ";",
579
+ 'title': this.form_field.title
580
+ };
581
+ if (this.form_field.id.length) {
582
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
583
+ }
584
+ this.container = $("<div />", container_props);
585
+ if (this.is_multiple) {
586
+ this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
587
+ } else {
588
+ this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
589
+ }
590
+ this.form_field_jq.hide().after(this.container);
591
+ this.dropdown = this.container.find('div.chosen-drop').first();
592
+ this.search_field = this.container.find('input').first();
593
+ this.search_results = this.container.find('ul.chosen-results').first();
594
+ this.search_field_scale();
595
+ this.search_no_results = this.container.find('li.no-results').first();
596
+ if (this.is_multiple) {
597
+ this.search_choices = this.container.find('ul.chosen-choices').first();
598
+ this.search_container = this.container.find('li.search-field').first();
599
+ } else {
600
+ this.search_container = this.container.find('div.chosen-search').first();
601
+ this.selected_item = this.container.find('.chosen-single').first();
602
+ }
603
+ this.results_build();
604
+ this.set_tab_index();
605
+ return this.set_label_behavior();
606
+ };
607
+ Chosen.prototype.on_ready = function() {
608
+ return this.form_field_jq.trigger("chosen:ready", {
609
+ chosen: this
610
+ });
611
+ };
612
+ Chosen.prototype.register_observers = function() {
613
+ var _this = this;
614
+ this.container.bind('touchstart.chosen', function(evt) {
615
+ _this.container_mousedown(evt);
616
+ return evt.preventDefault();
617
+ });
618
+ this.container.bind('touchend.chosen', function(evt) {
619
+ _this.container_mouseup(evt);
620
+ return evt.preventDefault();
621
+ });
622
+ this.container.bind('mousedown.chosen', function(evt) {
623
+ _this.container_mousedown(evt);
624
+ });
625
+ this.container.bind('mouseup.chosen', function(evt) {
626
+ _this.container_mouseup(evt);
627
+ });
628
+ this.container.bind('mouseenter.chosen', function(evt) {
629
+ _this.mouse_enter(evt);
630
+ });
631
+ this.container.bind('mouseleave.chosen', function(evt) {
632
+ _this.mouse_leave(evt);
633
+ });
634
+ this.search_results.bind('mouseup.chosen', function(evt) {
635
+ _this.search_results_mouseup(evt);
636
+ });
637
+ this.search_results.bind('mouseover.chosen', function(evt) {
638
+ _this.search_results_mouseover(evt);
639
+ });
640
+ this.search_results.bind('mouseout.chosen', function(evt) {
641
+ _this.search_results_mouseout(evt);
642
+ });
643
+ this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
644
+ _this.search_results_mousewheel(evt);
645
+ });
646
+ this.search_results.bind('touchstart.chosen', function(evt) {
647
+ _this.search_results_touchstart(evt);
648
+ });
649
+ this.search_results.bind('touchmove.chosen', function(evt) {
650
+ _this.search_results_touchmove(evt);
651
+ });
652
+ this.search_results.bind('touchend.chosen', function(evt) {
653
+ _this.search_results_touchend(evt);
654
+ });
655
+ this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
656
+ _this.results_update_field(evt);
657
+ });
658
+ this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
659
+ _this.activate_field(evt);
660
+ });
661
+ this.form_field_jq.bind("chosen:open.chosen", function(evt) {
662
+ _this.container_mousedown(evt);
663
+ });
664
+ this.form_field_jq.bind("chosen:close.chosen", function(evt) {
665
+ _this.input_blur(evt);
666
+ });
667
+ this.search_field.bind('blur.chosen', function(evt) {
668
+ _this.input_blur(evt);
669
+ });
670
+ this.search_field.bind('keyup.chosen', function(evt) {
671
+ _this.keyup_checker(evt);
672
+ });
673
+ this.search_field.bind('keydown.chosen', function(evt) {
674
+ _this.keydown_checker(evt);
675
+ });
676
+ this.search_field.bind('focus.chosen', function(evt) {
677
+ _this.input_focus(evt);
678
+ });
679
+ this.search_field.bind('cut.chosen', function(evt) {
680
+ _this.clipboard_event_checker(evt);
681
+ });
682
+ this.search_field.bind('paste.chosen', function(evt) {
683
+ _this.clipboard_event_checker(evt);
684
+ });
685
+ if (this.is_multiple) {
686
+ return this.search_choices.bind('click.chosen', function(evt) {
687
+ _this.choices_click(evt);
688
+ });
689
+ } else {
690
+ return this.container.bind('click.chosen', function(evt) {
691
+ evt.preventDefault();
692
+ });
693
+ }
694
+ };
695
+ Chosen.prototype.destroy = function() {
696
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
697
+ if (this.search_field[0].tabIndex) {
698
+ this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
699
+ }
700
+ this.container.remove();
701
+ this.form_field_jq.removeData('chosen');
702
+ return this.form_field_jq.show();
703
+ };
704
+ Chosen.prototype.search_field_disabled = function() {
705
+ this.is_disabled = this.form_field_jq[0].disabled;
706
+ if (this.is_disabled) {
707
+ this.container.addClass('chosen-disabled');
708
+ this.search_field[0].disabled = true;
709
+ if (!this.is_multiple) {
710
+ this.selected_item.unbind("focus.chosen", this.activate_action);
711
+ }
712
+ return this.close_field();
713
+ } else {
714
+ this.container.removeClass('chosen-disabled');
715
+ this.search_field[0].disabled = false;
716
+ if (!this.is_multiple) {
717
+ return this.selected_item.bind("focus.chosen", this.activate_action);
718
+ }
719
+ }
720
+ };
721
+ Chosen.prototype.container_mousedown = function(evt) {
722
+ if (!this.is_disabled) {
723
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
724
+ evt.preventDefault();
725
+ }
726
+ if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
727
+ if (!this.active_field) {
728
+ if (this.is_multiple) {
729
+ this.search_field.val("");
730
+ }
731
+ $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
732
+ this.results_show();
733
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
734
+ evt.preventDefault();
735
+ this.results_toggle();
736
+ }
737
+ return this.activate_field();
738
+ }
739
+ }
740
+ };
741
+ Chosen.prototype.container_mouseup = function(evt) {
742
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
743
+ return this.results_reset(evt);
744
+ }
745
+ };
746
+ Chosen.prototype.search_results_mousewheel = function(evt) {
747
+ var delta;
748
+ if (evt.originalEvent) {
749
+ delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
750
+ }
751
+ if (delta != null) {
752
+ evt.preventDefault();
753
+ if (evt.type === 'DOMMouseScroll') {
754
+ delta = delta * 40;
755
+ }
756
+ return this.search_results.scrollTop(delta + this.search_results.scrollTop());
757
+ }
758
+ };
759
+ Chosen.prototype.blur_test = function(evt) {
760
+ if (!this.active_field && this.container.hasClass("chosen-container-active")) {
761
+ return this.close_field();
762
+ }
763
+ };
764
+ Chosen.prototype.close_field = function() {
765
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
766
+ this.active_field = false;
767
+ this.results_hide();
768
+ this.container.removeClass("chosen-container-active");
769
+ this.clear_backstroke();
770
+ this.show_search_field_default();
771
+ return this.search_field_scale();
772
+ };
773
+ Chosen.prototype.activate_field = function() {
774
+ this.container.addClass("chosen-container-active");
775
+ this.active_field = true;
776
+ this.search_field.val(this.search_field.val());
777
+ return this.search_field.focus();
778
+ };
779
+ Chosen.prototype.test_active_click = function(evt) {
780
+ var active_container;
781
+ active_container = $(evt.target).closest('.chosen-container');
782
+ if (active_container.length && this.container[0] === active_container[0]) {
783
+ return this.active_field = true;
784
+ } else {
785
+ return this.close_field();
786
+ }
787
+ };
788
+ Chosen.prototype.results_build = function() {
789
+ this.parsing = true;
790
+ this.selected_option_count = null;
791
+ this.results_data = SelectParser.select_to_array(this.form_field);
792
+ if (this.is_multiple) {
793
+ this.search_choices.find("li.search-choice").remove();
794
+ } else if (!this.is_multiple) {
795
+ this.single_set_selected_text();
796
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
797
+ this.search_field[0].readOnly = true;
798
+ this.container.addClass("chosen-container-single-nosearch");
799
+ } else {
800
+ this.search_field[0].readOnly = false;
801
+ this.container.removeClass("chosen-container-single-nosearch");
802
+ }
803
+ }
804
+ this.update_results_content(this.results_option_build({
805
+ first: true
806
+ }));
807
+ this.search_field_disabled();
808
+ this.show_search_field_default();
809
+ this.search_field_scale();
810
+ return this.parsing = false;
811
+ };
812
+ Chosen.prototype.result_do_highlight = function(el) {
813
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
814
+ if (el.length) {
815
+ this.result_clear_highlight();
816
+ this.result_highlight = el;
817
+ this.result_highlight.addClass("highlighted");
818
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
819
+ visible_top = this.search_results.scrollTop();
820
+ visible_bottom = maxHeight + visible_top;
821
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
822
+ high_bottom = high_top + this.result_highlight.outerHeight();
823
+ if (high_bottom >= visible_bottom) {
824
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
825
+ } else if (high_top < visible_top) {
826
+ return this.search_results.scrollTop(high_top);
827
+ }
828
+ }
829
+ };
830
+ Chosen.prototype.result_clear_highlight = function() {
831
+ if (this.result_highlight) {
832
+ this.result_highlight.removeClass("highlighted");
833
+ }
834
+ return this.result_highlight = null;
835
+ };
836
+ Chosen.prototype.results_show = function() {
837
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
838
+ this.form_field_jq.trigger("chosen:maxselected", {
839
+ chosen: this
840
+ });
841
+ return false;
842
+ }
843
+ this.container.addClass("chosen-with-drop");
844
+ this.results_showing = true;
845
+ this.search_field.focus();
846
+ this.search_field.val(this.search_field.val());
847
+ this.winnow_results();
848
+ return this.form_field_jq.trigger("chosen:showing_dropdown", {
849
+ chosen: this
850
+ });
851
+ };
852
+ Chosen.prototype.update_results_content = function(content) {
853
+ return this.search_results.html(content);
854
+ };
855
+ Chosen.prototype.results_hide = function() {
856
+ if (this.results_showing) {
857
+ this.result_clear_highlight();
858
+ this.container.removeClass("chosen-with-drop");
859
+ this.form_field_jq.trigger("chosen:hiding_dropdown", {
860
+ chosen: this
861
+ });
862
+ }
863
+ return this.results_showing = false;
864
+ };
865
+ Chosen.prototype.set_tab_index = function(el) {
866
+ var ti;
867
+ if (this.form_field.tabIndex) {
868
+ ti = this.form_field.tabIndex;
869
+ this.form_field.tabIndex = -1;
870
+ return this.search_field[0].tabIndex = ti;
871
+ }
872
+ };
873
+ Chosen.prototype.set_label_behavior = function() {
874
+ var _this = this;
875
+ this.form_field_label = this.form_field_jq.parents("label");
876
+ if (!this.form_field_label.length && this.form_field.id.length) {
877
+ this.form_field_label = $("label[for='" + this.form_field.id + "']");
878
+ }
879
+ if (this.form_field_label.length > 0) {
880
+ return this.form_field_label.bind('click.chosen', function(evt) {
881
+ if (_this.is_multiple) {
882
+ return _this.container_mousedown(evt);
883
+ } else {
884
+ return _this.activate_field();
885
+ }
886
+ });
887
+ }
888
+ };
889
+ Chosen.prototype.show_search_field_default = function() {
890
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
891
+ this.search_field.val(this.default_text);
892
+ return this.search_field.addClass("default");
893
+ } else {
894
+ this.search_field.val("");
895
+ return this.search_field.removeClass("default");
896
+ }
897
+ };
898
+ Chosen.prototype.search_results_mouseup = function(evt) {
899
+ var target;
900
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
901
+ if (target.length) {
902
+ this.result_highlight = target;
903
+ this.result_select(evt);
904
+ return this.search_field.focus();
905
+ }
906
+ };
907
+ Chosen.prototype.search_results_mouseover = function(evt) {
908
+ var target;
909
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
910
+ if (target) {
911
+ return this.result_do_highlight(target);
912
+ }
913
+ };
914
+ Chosen.prototype.search_results_mouseout = function(evt) {
915
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
916
+ return this.result_clear_highlight();
917
+ }
918
+ };
919
+ Chosen.prototype.choice_build = function(item) {
920
+ var choice, close_link, _this = this;
921
+ choice = $('<li />', {
922
+ "class": "search-choice"
923
+ }).html("<span>" + (this.choice_label(item)) + "</span>");
924
+ if (item.disabled) {
925
+ choice.addClass('search-choice-disabled');
926
+ } else {
927
+ close_link = $('<a />', {
928
+ "class": 'search-choice-close',
929
+ 'data-option-array-index': item.array_index
930
+ });
931
+ close_link.bind('click.chosen', function(evt) {
932
+ return _this.choice_destroy_link_click(evt);
933
+ });
934
+ choice.append(close_link);
935
+ }
936
+ return this.search_container.before(choice);
937
+ };
938
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
939
+ evt.preventDefault();
940
+ evt.stopPropagation();
941
+ if (!this.is_disabled) {
942
+ return this.choice_destroy($(evt.target));
943
+ }
944
+ };
945
+ Chosen.prototype.choice_destroy = function(link) {
946
+ if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
947
+ this.show_search_field_default();
948
+ if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
949
+ this.results_hide();
950
+ }
951
+ link.parents('li').first().remove();
952
+ return this.search_field_scale();
953
+ }
954
+ };
955
+ Chosen.prototype.results_reset = function() {
956
+ this.reset_single_select_options();
957
+ this.form_field.options[0].selected = true;
958
+ this.single_set_selected_text();
959
+ this.show_search_field_default();
960
+ this.results_reset_cleanup();
961
+ this.form_field_jq.trigger("change");
962
+ if (this.active_field) {
963
+ return this.results_hide();
964
+ }
965
+ };
966
+ Chosen.prototype.results_reset_cleanup = function() {
967
+ this.current_selectedIndex = this.form_field.selectedIndex;
968
+ return this.selected_item.find("abbr").remove();
969
+ };
970
+ Chosen.prototype.result_select = function(evt) {
971
+ var high, item;
972
+ if (this.result_highlight) {
973
+ high = this.result_highlight;
974
+ this.result_clear_highlight();
975
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
976
+ this.form_field_jq.trigger("chosen:maxselected", {
977
+ chosen: this
978
+ });
979
+ return false;
980
+ }
981
+ if (this.is_multiple) {
982
+ high.removeClass("active-result");
983
+ } else {
984
+ this.reset_single_select_options();
985
+ }
986
+ high.addClass("result-selected");
987
+ item = this.results_data[high[0].getAttribute("data-option-array-index")];
988
+ if (typeof item === 'undefined') {
989
+ return false
990
+ };
991
+ item.selected = true;
992
+ this.form_field.options[item.options_index].selected = true;
993
+ this.selected_option_count = null;
994
+ if (this.is_multiple) {
995
+ this.choice_build(item);
996
+ } else {
997
+ this.single_set_selected_text(this.choice_label(item));
998
+ }
999
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1000
+ this.results_hide();
1001
+ }
1002
+ this.show_search_field_default();
1003
+ if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1004
+ this.form_field_jq.trigger("change", {
1005
+ 'selected': this.form_field.options[item.options_index].value
1006
+ });
1007
+ }
1008
+ this.current_selectedIndex = this.form_field.selectedIndex;
1009
+ evt.preventDefault();
1010
+ return this.search_field_scale();
1011
+ }
1012
+ };
1013
+ Chosen.prototype.single_set_selected_text = function(text) {
1014
+ if (text == null) {
1015
+ text = this.default_text;
1016
+ }
1017
+ if (text === this.default_text) {
1018
+ this.selected_item.addClass("chosen-default");
1019
+ } else {
1020
+ this.single_deselect_control_build();
1021
+ this.selected_item.removeClass("chosen-default");
1022
+ }
1023
+ return this.selected_item.find("span").html(text);
1024
+ };
1025
+ Chosen.prototype.result_deselect = function(pos) {
1026
+ var result_data;
1027
+ result_data = this.results_data[pos];
1028
+ if (!this.form_field.options[result_data.options_index].disabled) {
1029
+ result_data.selected = false;
1030
+ this.form_field.options[result_data.options_index].selected = false;
1031
+ this.selected_option_count = null;
1032
+ this.result_clear_highlight();
1033
+ if (this.results_showing) {
1034
+ this.winnow_results();
1035
+ }
1036
+ this.form_field_jq.trigger("change", {
1037
+ deselected: this.form_field.options[result_data.options_index].value
1038
+ });
1039
+ this.search_field_scale();
1040
+ return true;
1041
+ } else {
1042
+ return false;
1043
+ }
1044
+ };
1045
+ Chosen.prototype.single_deselect_control_build = function() {
1046
+ if (!this.allow_single_deselect) {
1047
+ return;
1048
+ }
1049
+ if (!this.selected_item.find("abbr").length) {
1050
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1051
+ }
1052
+ return this.selected_item.addClass("chosen-single-with-deselect");
1053
+ };
1054
+ Chosen.prototype.get_search_text = function() {
1055
+ return $('<div/>').text($.trim(this.search_field.val())).html();
1056
+ };
1057
+ Chosen.prototype.winnow_results_set_highlight = function() {
1058
+ var do_high, selected_results;
1059
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1060
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1061
+ if (do_high != null) {
1062
+ return this.result_do_highlight(do_high);
1063
+ }
1064
+ };
1065
+ Chosen.prototype.no_results = function(terms) {
1066
+ var no_results_html;
1067
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1068
+ no_results_html.find("span").first().html(terms);
1069
+ this.search_results.append(no_results_html);
1070
+ return this.form_field_jq.trigger("chosen:no_results", {
1071
+ chosen: this
1072
+ });
1073
+ };
1074
+ Chosen.prototype.no_results_clear = function() {
1075
+ return this.search_results.find(".no-results").remove();
1076
+ };
1077
+ Chosen.prototype.keydown_arrow = function() {
1078
+ var next_sib;
1079
+ if (this.results_showing && this.result_highlight) {
1080
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1081
+ if (next_sib) {
1082
+ return this.result_do_highlight(next_sib);
1083
+ }
1084
+ } else {
1085
+ return this.results_show();
1086
+ }
1087
+ };
1088
+ Chosen.prototype.keyup_arrow = function() {
1089
+ var prev_sibs;
1090
+ if (!this.results_showing && !this.is_multiple) {
1091
+ return this.results_show();
1092
+ } else if (this.result_highlight) {
1093
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1094
+ if (prev_sibs.length) {
1095
+ return this.result_do_highlight(prev_sibs.first());
1096
+ } else {
1097
+ if (this.choices_count() > 0) {
1098
+ this.results_hide();
1099
+ }
1100
+ return this.result_clear_highlight();
1101
+ }
1102
+ }
1103
+ };
1104
+ Chosen.prototype.keydown_backstroke = function() {
1105
+ var next_available_destroy;
1106
+ if (this.pending_backstroke) {
1107
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1108
+ return this.clear_backstroke();
1109
+ } else {
1110
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1111
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1112
+ this.pending_backstroke = next_available_destroy;
1113
+ if (this.single_backstroke_delete) {
1114
+ return this.keydown_backstroke();
1115
+ } else {
1116
+ return this.pending_backstroke.addClass("search-choice-focus");
1117
+ }
1118
+ }
1119
+ }
1120
+ };
1121
+ Chosen.prototype.clear_backstroke = function() {
1122
+ if (this.pending_backstroke) {
1123
+ this.pending_backstroke.removeClass("search-choice-focus");
1124
+ }
1125
+ return this.pending_backstroke = null;
1126
+ };
1127
+ Chosen.prototype.keydown_checker = function(evt) {
1128
+ var stroke, _ref1;
1129
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1130
+ this.search_field_scale();
1131
+ if (stroke !== 8 && this.pending_backstroke) {
1132
+ this.clear_backstroke();
1133
+ }
1134
+ switch (stroke) {
1135
+ case 8:
1136
+ this.backstroke_length = this.search_field.val().length;
1137
+ break;
1138
+ case 9:
1139
+ if (this.results_showing && !this.is_multiple) {
1140
+ this.result_select(evt);
1141
+ }
1142
+ this.mouse_on_container = false;
1143
+ break;
1144
+ case 13:
1145
+ if (this.results_showing) {
1146
+ evt.preventDefault();
1147
+ }
1148
+ break;
1149
+ case 32:
1150
+ if (this.disable_search) {
1151
+ evt.preventDefault();
1152
+ }
1153
+ break;
1154
+ case 38:
1155
+ evt.preventDefault();
1156
+ this.keyup_arrow();
1157
+ break;
1158
+ case 40:
1159
+ evt.preventDefault();
1160
+ this.keydown_arrow();
1161
+ break;
1162
+ }
1163
+ };
1164
+ Chosen.prototype.search_field_scale = function() {
1165
+ var div, f_width, h, style, style_block, styles, w, _i, _len;
1166
+ if (this.is_multiple) {
1167
+ h = 0;
1168
+ w = 0;
1169
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1170
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1171
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1172
+ style = styles[_i];
1173
+ style_block += style + ":" + this.search_field.css(style) + ";";
1174
+ }
1175
+ div = $('<div />', {
1176
+ 'style': style_block
1177
+ });
1178
+ div.text(this.search_field.val());
1179
+ $('body').append(div);
1180
+ w = div.width() + 25;
1181
+ div.remove();
1182
+ f_width = this.container.outerWidth();
1183
+ if (w > f_width - 10) {
1184
+ w = f_width - 10;
1185
+ }
1186
+ return this.search_field.css({
1187
+ 'width': w + 'px'
1188
+ });
1189
+ }
1190
+ };
1191
+ return Chosen;
1192
+ })(AbstractChosen);
1193
+ }).call(this);
1194
+
1195
+ function fixChosenClipping($chosenSelect) {
1196
+ $chosenSelect
1197
+ .bind('chosen:showing_dropdown', function() {
1198
+ $(this).next('.chosen-container')
1199
+ .bind("mousewheel", function() {
1200
+ return false;
1201
+ });
1202
+ })
1203
+ .bind('chosen:hiding_dropdown', function() {
1204
+ $(this).next('.chosen-container')
1205
+ .unbind('mousewheel');
1206
+ });
1207
+ $('.chosen-container')
1208
+ .bind('mouseenter.chosen', function() {
1209
+ var x = $(this).offset().left,
1210
+ y = $(this).offset().top + $(this).height(),
1211
+ w = $(this).width(),
1212
+ $dropdown = $(this).find('.chosen-drop');
1213
+ var parents = $(this).parents().filter(function() {
1214
+ var overflow = $(this).css('overflow');
1215
+ return overflow === 'auto' || overflow === 'hidden' || overflow === 'scroll';
1216
+ });
1217
+ for (var i = 0; i < parents.length; i++) {
1218
+ var parentEdge = $(parents[i]).offset().top + $(parents[i]).outerHeight();
1219
+ if (y > parentEdge) {
1220
+ $dropdown.css({
1221
+ 'display': 'none'
1222
+ });
1223
+ return false;
1224
+ }
1225
+ }
1226
+ $dropdown.addClass('fixed')
1227
+ .css({
1228
+ 'top': y - $(document).scrollTop(),
1229
+ 'left': x,
1230
+ 'width': w
1231
+ });
1232
+ })
1233
+ .bind('mouseleave.chosen', function() {
1234
+ $(this).find('.chosen-drop')
1235
+ .removeClass('fixed')
1236
+ .attr('style', '');
1237
+ });
1238
+ }