alchemy 1.0.3 → 8.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +24 -17
  3. data/README.md +538 -4
  4. data/lib/alchemy.rb +3 -2
  5. metadata +61 -223
  6. data/Rakefile +0 -21
  7. data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.eot +0 -0
  8. data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.svg +0 -154
  9. data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.ttf +0 -0
  10. data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.woff +0 -0
  11. data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.eot +0 -0
  12. data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.svg +0 -154
  13. data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.ttf +0 -0
  14. data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.woff +0 -0
  15. data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.eot +0 -0
  16. data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.svg +0 -154
  17. data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.ttf +0 -0
  18. data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.woff +0 -0
  19. data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.eot +0 -0
  20. data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.svg +0 -154
  21. data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.ttf +0 -0
  22. data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.woff +0 -0
  23. data/app/assets/fonts/alchemy/Red Hat Liberation License.txt +0 -78
  24. data/app/assets/fonts/alchemy/overpass_bold-web.eot +0 -0
  25. data/app/assets/fonts/alchemy/overpass_bold-web.svg +0 -470
  26. data/app/assets/fonts/alchemy/overpass_bold-web.ttf +0 -0
  27. data/app/assets/fonts/alchemy/overpass_bold-web.woff +0 -0
  28. data/app/assets/fonts/alchemy/overpass_regular-web.eot +0 -0
  29. data/app/assets/fonts/alchemy/overpass_regular-web.svg +0 -470
  30. data/app/assets/fonts/alchemy/overpass_regular-web.ttf +0 -0
  31. data/app/assets/fonts/alchemy/overpass_regular-web.woff +0 -0
  32. data/app/assets/images/alchemy/icons/action-icons.png +0 -0
  33. data/app/assets/images/alchemy/icons/arrow_icon.png +0 -0
  34. data/app/assets/images/alchemy/icons/chosen-sprite.png +0 -0
  35. data/app/assets/images/alchemy/icons/error_icon.png +0 -0
  36. data/app/assets/images/alchemy/icons/objects.png +0 -0
  37. data/app/assets/images/alchemy/icons/spinner.gif +0 -0
  38. data/app/assets/images/alchemy/icons/spinner_head.gif +0 -0
  39. data/app/assets/images/alchemy/icons/success_icon.png +0 -0
  40. data/app/assets/images/alchemy/icons/warning_icon.png +0 -0
  41. data/app/assets/javascripts/alchemy/flash_messages.js +0 -12
  42. data/app/assets/javascripts/alchemy/forms.js +0 -25
  43. data/app/assets/javascripts/alchemy/i18n.js +0 -36
  44. data/app/assets/javascripts/alchemy/login.js +0 -130
  45. data/app/assets/javascripts/alchemy/password.js +0 -99
  46. data/app/assets/stylesheets/alchemy/components/_chosen.scss +0 -423
  47. data/app/assets/stylesheets/alchemy/components/_content.scss +0 -58
  48. data/app/assets/stylesheets/alchemy/components/_helpers.scss +0 -38
  49. data/app/assets/stylesheets/alchemy/components/_media.scss +0 -49
  50. data/app/assets/stylesheets/alchemy/components/_media_object.scss +0 -22
  51. data/app/assets/stylesheets/alchemy/components/_normalize.scss +0 -396
  52. data/app/assets/stylesheets/alchemy/components/_shared.scss +0 -18
  53. data/app/assets/stylesheets/alchemy/components/buttons/_buttons.scss +0 -278
  54. data/app/assets/stylesheets/alchemy/components/buttons/_buttons_vars.scss +0 -11
  55. data/app/assets/stylesheets/alchemy/components/flash_messages/_flash_messages.scss +0 -93
  56. data/app/assets/stylesheets/alchemy/components/flash_messages/_flash_messages_vars.scss +0 -3
  57. data/app/assets/stylesheets/alchemy/components/fonts/_liberation.scss +0 -44
  58. data/app/assets/stylesheets/alchemy/components/fonts/_overpass.scss +0 -24
  59. data/app/assets/stylesheets/alchemy/components/footer/_footer.scss +0 -53
  60. data/app/assets/stylesheets/alchemy/components/footer/_footer_vars.scss +0 -4
  61. data/app/assets/stylesheets/alchemy/components/forms/_forms.scss +0 -552
  62. data/app/assets/stylesheets/alchemy/components/forms/_forms_ie.scss +0 -45
  63. data/app/assets/stylesheets/alchemy/components/forms/_forms_mixins.scss +0 -18
  64. data/app/assets/stylesheets/alchemy/components/forms/_forms_responsive.scss +0 -167
  65. data/app/assets/stylesheets/alchemy/components/forms/_forms_vars.scss +0 -25
  66. data/app/assets/stylesheets/alchemy/components/header/_header.scss +0 -216
  67. data/app/assets/stylesheets/alchemy/components/header/_header_vars.scss +0 -11
  68. data/app/assets/stylesheets/alchemy/components/login/_login.scss +0 -173
  69. data/app/assets/stylesheets/alchemy/components/login/_login_mixins.scss +0 -7
  70. data/app/assets/stylesheets/alchemy/components/login/_login_vars.scss +0 -19
  71. data/app/assets/stylesheets/alchemy/components/sprites/_sprites.scss +0 -110
  72. data/app/assets/stylesheets/alchemy/components/sprites/_sprites_mixins.scss +0 -9
  73. data/app/assets/stylesheets/alchemy/components/text/_text.scss +0 -30
  74. data/app/assets/stylesheets/alchemy/components/text/_text_vars.scss +0 -1
  75. data/app/assets/stylesheets/alchemy/composites/content_elements.scss +0 -6
  76. data/app/assets/stylesheets/alchemy/composites/login.scss +0 -9
  77. data/app/assets/stylesheets/alchemy/composites/shell.scss +0 -4
  78. data/app/assets/stylesheets/alchemy/partials/_base.scss +0 -8
  79. data/app/assets/stylesheets/alchemy/partials/_colors.scss +0 -99
  80. data/app/assets/stylesheets/alchemy/partials/_mixins.scss +0 -24
  81. data/app/assets/stylesheets/alchemy/partials/_vars.scss +0 -31
  82. data/app/helpers/alchemy/gettext_translations.rb +0 -28
  83. data/app/helpers/alchemy/layout_helper.rb +0 -35
  84. data/app/helpers/alchemy/rails_translations.rb +0 -21
  85. data/app/helpers/alchemy/translation_helper.rb +0 -19
  86. data/app/views/alchemy/layouts/_change_password_layout.html.haml +0 -20
  87. data/app/views/alchemy/layouts/_common_i18n.haml +0 -4
  88. data/app/views/alchemy/layouts/_header_layout.haml +0 -13
  89. data/app/views/alchemy/layouts/_login_layout.html.haml +0 -58
  90. data/app/views/alchemy/layouts/_user_session_layout.haml +0 -17
  91. data/app/views/alchemy/layouts/base.html.haml +0 -20
  92. data/app/views/alchemy/layouts/shell_layout.haml +0 -10
  93. data/lib/alchemy/engine.rb +0 -8
  94. data/lib/alchemy/version.rb +0 -3
  95. data/test/alchemy_test.rb +0 -7
  96. data/test/test_helper.rb +0 -9
  97. data/vendor/assets/javascripts/alchemy/handlebars.js +0 -2201
  98. data/vendor/assets/javascripts/alchemy/html5shiv.js +0 -298
  99. data/vendor/assets/javascripts/alchemy/jquery/jquery-1.6.2.js +0 -8981
  100. data/vendor/assets/javascripts/alchemy/jquery/plugins/chosen.jquery.js +0 -1003
  101. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/excanvas.js +0 -1427
  102. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/excanvas.min.js +0 -1
  103. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.colorhelpers.js +0 -179
  104. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.colorhelpers.min.js +0 -1
  105. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.crosshair.js +0 -167
  106. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.crosshair.min.js +0 -1
  107. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.fillbetween.js +0 -183
  108. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.fillbetween.min.js +0 -1
  109. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.image.js +0 -238
  110. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.image.min.js +0 -1
  111. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.js +0 -2599
  112. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.min.js +0 -6
  113. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.navigate.js +0 -336
  114. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.navigate.min.js +0 -1
  115. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.pie.js +0 -750
  116. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.pie.min.js +0 -1
  117. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.resize.js +0 -60
  118. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.resize.min.js +0 -1
  119. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.selection.js +0 -344
  120. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.selection.min.js +0 -1
  121. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.stack.js +0 -184
  122. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.stack.min.js +0 -1
  123. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.symbol.js +0 -70
  124. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.symbol.min.js +0 -1
  125. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.threshold.js +0 -103
  126. data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.threshold.min.js +0 -1
  127. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/blank.svg +0 -3
  128. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/custom_test.js +0 -67
  129. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.css +0 -9
  130. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.js +0 -1101
  131. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.min.js +0 -7
  132. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.pack.js +0 -7
  133. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.js +0 -396
  134. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.min.js +0 -7
  135. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.pack.js +0 -7
  136. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.js +0 -1337
  137. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.min.js +0 -7
  138. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.pack.js +0 -7
  139. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/lion.svg +0 -161
  140. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/test.js +0 -714
  141. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ajaxfileupload.js +0 -205
  142. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ba-bbq.js +0 -1137
  143. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ba-resize.js +0 -246
  144. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.cookie.js +0 -92
  145. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.easing.1.3.js +0 -205
  146. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.fancyqueries.js +0 -106
  147. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.flash.js +0 -288
  148. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.form.js +0 -964
  149. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.hoverIntent.js +0 -106
  150. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jeditable.ajaxupload.js +0 -62
  151. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jeditable.js +0 -556
  152. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jnotify.js +0 -210
  153. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jscrollpane.js +0 -1390
  154. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jscrollpane.min.js +0 -11
  155. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.linkHover.js +0 -89
  156. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.loadmask.min.js +0 -10
  157. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.mousewheel.js +0 -78
  158. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.multiselect.filter.js +0 -176
  159. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.multiselect.js +0 -668
  160. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.pack.js +0 -11
  161. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.periodicalupdater.js +0 -175
  162. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.sortElements.js +0 -75
  163. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.sparkline.min.js +0 -94
  164. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.text-overflow.js +0 -60
  165. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.timepickr.js +0 -214
  166. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.timers.js +0 -142
  167. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.tipsy.js +0 -358
  168. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.treeTable.js +0 -226
  169. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.trunk8.js +0 -203
  170. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ui.multiselect.js +0 -338
  171. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ui.totop.js +0 -58
  172. data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.uitablefilter.js +0 -95
  173. data/vendor/assets/javascripts/alchemy/jquery/plugins/ui.spinner.js +0 -683
  174. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  175. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  176. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_75_dadada_1x100.png +0 -0
  177. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_75_e6e6e6_1x100.png +0 -0
  178. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_95_ffffff_1x100.png +0 -0
  179. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-soft_80_e0e0e0_1x100.png +0 -0
  180. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_inset-hard_65_ffffff_1x100.png +0 -0
  181. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
  182. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_8f8f8f_256x240.png +0 -0
  183. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_97baed_256x240.png +0 -0
  184. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  185. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/jquery-ui-1.8.11.custom.css +0 -573
  186. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/js/jquery-1.5.1.min.js +0 -16
  187. data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/js/jquery-ui-1.8.11.custom.min.js +0 -783
  188. data/vendor/assets/javascripts/alchemy/rails.js +0 -331
  189. data/vendor/assets/javascripts/alchemy/underscore-1.3.1.js +0 -999
@@ -1,1003 +0,0 @@
1
- // Chosen, a Select Box Enhancer for jQuery and Protoype
2
- // by Patrick Filler for Harvest, http://getharvest.com
3
- //
4
- // Version 0.9.8
5
- // Full source at https://github.com/harvesthq/chosen
6
- // Copyright (c) 2011 Harvest http://getharvest.com
7
-
8
- // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
- // This file is generated by `cake build`, do not edit it by hand.
10
- (function() {
11
- var SelectParser;
12
-
13
- SelectParser = (function() {
14
-
15
- function SelectParser() {
16
- this.options_index = 0;
17
- this.parsed = [];
18
- }
19
-
20
- SelectParser.prototype.add_node = function(child) {
21
- if (child.nodeName === "OPTGROUP") {
22
- return this.add_group(child);
23
- } else {
24
- return this.add_option(child);
25
- }
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: group.label,
35
- children: 0,
36
- disabled: group.disabled
37
- });
38
- _ref = group.childNodes;
39
- _results = [];
40
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
41
- option = _ref[_i];
42
- _results.push(this.add_option(option, group_position, group.disabled));
43
- }
44
- return _results;
45
- };
46
-
47
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
48
- if (option.nodeName === "OPTION") {
49
- if (option.text !== "") {
50
- if (group_position != null) this.parsed[group_position].children += 1;
51
- this.parsed.push({
52
- array_index: this.parsed.length,
53
- options_index: this.options_index,
54
- value: option.value,
55
- text: option.text,
56
- html: option.innerHTML,
57
- selected: option.selected,
58
- disabled: group_disabled === true ? group_disabled : option.disabled,
59
- group_array_index: group_position,
60
- classes: option.className,
61
- style: option.style.cssText
62
- });
63
- } else {
64
- this.parsed.push({
65
- array_index: this.parsed.length,
66
- options_index: this.options_index,
67
- empty: true
68
- });
69
- }
70
- return this.options_index += 1;
71
- }
72
- };
73
-
74
- return SelectParser;
75
-
76
- })();
77
-
78
- SelectParser.select_to_array = function(select) {
79
- var child, parser, _i, _len, _ref;
80
- parser = new SelectParser();
81
- _ref = select.childNodes;
82
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
83
- child = _ref[_i];
84
- parser.add_node(child);
85
- }
86
- return parser.parsed;
87
- };
88
-
89
- this.SelectParser = SelectParser;
90
-
91
- }).call(this);
92
-
93
- /*
94
- Chosen source: generate output using 'cake build'
95
- Copyright (c) 2011 by Harvest
96
- */
97
-
98
- (function() {
99
- var AbstractChosen, root;
100
-
101
- root = this;
102
-
103
- AbstractChosen = (function() {
104
-
105
- function AbstractChosen(form_field, options) {
106
- this.form_field = form_field;
107
- this.options = options != null ? options : {};
108
- this.set_default_values();
109
- this.is_multiple = this.form_field.multiple;
110
- this.set_default_text();
111
- this.setup();
112
- this.set_up_html();
113
- this.register_observers();
114
- this.finish_setup();
115
- }
116
-
117
- AbstractChosen.prototype.set_default_values = function() {
118
- var _this = this;
119
- this.click_test_action = function(evt) {
120
- return _this.test_active_click(evt);
121
- };
122
- this.activate_action = function(evt) {
123
- return _this.activate_field(evt);
124
- };
125
- this.active_field = false;
126
- this.mouse_on_container = false;
127
- this.results_showing = false;
128
- this.result_highlighted = null;
129
- this.result_single_selected = null;
130
- 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;
131
- this.disable_search_threshold = this.options.disable_search_threshold || 0;
132
- this.search_contains = this.options.search_contains || false;
133
- this.choices = 0;
134
- this.single_backstroke_delete = this.options.single_backstroke_delete || false;
135
- return this.max_selected_options = this.options.max_selected_options || Infinity;
136
- };
137
-
138
- AbstractChosen.prototype.set_default_text = function() {
139
- if (this.form_field.getAttribute("data-placeholder")) {
140
- this.default_text = this.form_field.getAttribute("data-placeholder");
141
- } else if (this.is_multiple) {
142
- this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options";
143
- } else {
144
- this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option";
145
- }
146
- return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match";
147
- };
148
-
149
- AbstractChosen.prototype.mouse_enter = function() {
150
- return this.mouse_on_container = true;
151
- };
152
-
153
- AbstractChosen.prototype.mouse_leave = function() {
154
- return this.mouse_on_container = false;
155
- };
156
-
157
- AbstractChosen.prototype.input_focus = function(evt) {
158
- var _this = this;
159
- if (!this.active_field) {
160
- return setTimeout((function() {
161
- return _this.container_mousedown();
162
- }), 50);
163
- }
164
- };
165
-
166
- AbstractChosen.prototype.input_blur = function(evt) {
167
- var _this = this;
168
- if (!this.mouse_on_container) {
169
- this.active_field = false;
170
- return setTimeout((function() {
171
- return _this.blur_test();
172
- }), 100);
173
- }
174
- };
175
-
176
- AbstractChosen.prototype.result_add_option = function(option) {
177
- var classes, style;
178
- if (!option.disabled) {
179
- option.dom_id = this.container_id + "_o_" + option.array_index;
180
- classes = option.selected && this.is_multiple ? [] : ["active-result"];
181
- if (option.selected) classes.push("result-selected");
182
- if (option.group_array_index != null) classes.push("group-option");
183
- if (option.classes !== "") classes.push(option.classes);
184
- style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
185
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
186
- } else {
187
- return "";
188
- }
189
- };
190
-
191
- AbstractChosen.prototype.results_update_field = function() {
192
- if (!this.is_multiple) this.results_reset_cleanup();
193
- this.result_clear_highlight();
194
- this.result_single_selected = null;
195
- return this.results_build();
196
- };
197
-
198
- AbstractChosen.prototype.results_toggle = function() {
199
- if (this.results_showing) {
200
- return this.results_hide();
201
- } else {
202
- return this.results_show();
203
- }
204
- };
205
-
206
- AbstractChosen.prototype.results_search = function(evt) {
207
- if (this.results_showing) {
208
- return this.winnow_results();
209
- } else {
210
- return this.results_show();
211
- }
212
- };
213
-
214
- AbstractChosen.prototype.keyup_checker = function(evt) {
215
- var stroke, _ref;
216
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
217
- this.search_field_scale();
218
- switch (stroke) {
219
- case 8:
220
- if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
221
- return this.keydown_backstroke();
222
- } else if (!this.pending_backstroke) {
223
- this.result_clear_highlight();
224
- return this.results_search();
225
- }
226
- break;
227
- case 13:
228
- evt.preventDefault();
229
- if (this.results_showing) return this.result_select(evt);
230
- break;
231
- case 27:
232
- if (this.results_showing) this.results_hide();
233
- return true;
234
- case 9:
235
- case 38:
236
- case 40:
237
- case 16:
238
- case 91:
239
- case 17:
240
- break;
241
- default:
242
- return this.results_search();
243
- }
244
- };
245
-
246
- AbstractChosen.prototype.generate_field_id = function() {
247
- var new_id;
248
- new_id = this.generate_random_id();
249
- this.form_field.id = new_id;
250
- return new_id;
251
- };
252
-
253
- AbstractChosen.prototype.generate_random_char = function() {
254
- var chars, newchar, rand;
255
- chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
256
- rand = Math.floor(Math.random() * chars.length);
257
- return newchar = chars.substring(rand, rand + 1);
258
- };
259
-
260
- return AbstractChosen;
261
-
262
- })();
263
-
264
- root.AbstractChosen = AbstractChosen;
265
-
266
- }).call(this);
267
-
268
- /*
269
- Chosen source: generate output using 'cake build'
270
- Copyright (c) 2011 by Harvest
271
- */
272
-
273
- (function() {
274
- var $, Chosen, get_side_border_padding, root,
275
- __hasProp = Object.prototype.hasOwnProperty,
276
- __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; };
277
-
278
- root = this;
279
-
280
- $ = jQuery;
281
-
282
- $.fn.extend({
283
- chosen: function(options) {
284
- if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
285
- return this;
286
- }
287
- return this.each(function(input_field) {
288
- var $this;
289
- $this = $(this);
290
- if (!$this.hasClass("chzn-done")) {
291
- return $this.data('chosen', new Chosen(this, options));
292
- }
293
- });
294
- }
295
- });
296
-
297
- Chosen = (function(_super) {
298
-
299
- __extends(Chosen, _super);
300
-
301
- function Chosen() {
302
- Chosen.__super__.constructor.apply(this, arguments);
303
- }
304
-
305
- Chosen.prototype.setup = function() {
306
- this.form_field_jq = $(this.form_field);
307
- this.current_value = this.form_field_jq.val();
308
- return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
309
- };
310
-
311
- Chosen.prototype.finish_setup = function() {
312
- return this.form_field_jq.addClass("chzn-done");
313
- };
314
-
315
- Chosen.prototype.set_up_html = function() {
316
- var container_div, dd_top, dd_width, sf_width;
317
- this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
318
- this.container_id += "_chzn";
319
- this.f_width = this.form_field_jq.outerWidth();
320
- container_div = $("<div />", {
321
- id: this.container_id,
322
- "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
323
- style: 'width: ' + this.f_width + 'px;'
324
- });
325
- if (this.is_multiple) {
326
- container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
327
- } else {
328
- container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
329
- }
330
- this.form_field_jq.hide().after(container_div);
331
- this.container = $('#' + this.container_id);
332
- this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
333
- this.dropdown = this.container.find('div.chzn-drop').first();
334
- dd_top = this.container.height();
335
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
336
- this.dropdown.css({
337
- "width": dd_width + "px",
338
- "top": dd_top + "px"
339
- });
340
- this.search_field = this.container.find('input').first();
341
- this.search_results = this.container.find('ul.chzn-results').first();
342
- this.search_field_scale();
343
- this.search_no_results = this.container.find('li.no-results').first();
344
- if (this.is_multiple) {
345
- this.search_choices = this.container.find('ul.chzn-choices').first();
346
- this.search_container = this.container.find('li.search-field').first();
347
- } else {
348
- this.search_container = this.container.find('div.chzn-search').first();
349
- this.selected_item = this.container.find('.chzn-single').first();
350
- sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
351
- this.search_field.css({
352
- "width": sf_width + "px"
353
- });
354
- }
355
- this.results_build();
356
- this.set_tab_index();
357
- return this.form_field_jq.trigger("liszt:ready", {
358
- chosen: this
359
- });
360
- };
361
-
362
- Chosen.prototype.register_observers = function() {
363
- var _this = this;
364
- this.container.mousedown(function(evt) {
365
- return _this.container_mousedown(evt);
366
- });
367
- this.container.mouseup(function(evt) {
368
- return _this.container_mouseup(evt);
369
- });
370
- this.container.mouseenter(function(evt) {
371
- return _this.mouse_enter(evt);
372
- });
373
- this.container.mouseleave(function(evt) {
374
- return _this.mouse_leave(evt);
375
- });
376
- this.search_results.mouseup(function(evt) {
377
- return _this.search_results_mouseup(evt);
378
- });
379
- this.search_results.mouseover(function(evt) {
380
- return _this.search_results_mouseover(evt);
381
- });
382
- this.search_results.mouseout(function(evt) {
383
- return _this.search_results_mouseout(evt);
384
- });
385
- this.form_field_jq.bind("liszt:updated", function(evt) {
386
- return _this.results_update_field(evt);
387
- });
388
- this.search_field.blur(function(evt) {
389
- return _this.input_blur(evt);
390
- });
391
- this.search_field.keyup(function(evt) {
392
- return _this.keyup_checker(evt);
393
- });
394
- this.search_field.keydown(function(evt) {
395
- return _this.keydown_checker(evt);
396
- });
397
- if (this.is_multiple) {
398
- this.search_choices.click(function(evt) {
399
- return _this.choices_click(evt);
400
- });
401
- return this.search_field.focus(function(evt) {
402
- return _this.input_focus(evt);
403
- });
404
- } else {
405
- return this.container.click(function(evt) {
406
- return evt.preventDefault();
407
- });
408
- }
409
- };
410
-
411
- Chosen.prototype.search_field_disabled = function() {
412
- this.is_disabled = this.form_field_jq[0].disabled;
413
- if (this.is_disabled) {
414
- this.container.addClass('chzn-disabled');
415
- this.search_field[0].disabled = true;
416
- if (!this.is_multiple) {
417
- this.selected_item.unbind("focus", this.activate_action);
418
- }
419
- return this.close_field();
420
- } else {
421
- this.container.removeClass('chzn-disabled');
422
- this.search_field[0].disabled = false;
423
- if (!this.is_multiple) {
424
- return this.selected_item.bind("focus", this.activate_action);
425
- }
426
- }
427
- };
428
-
429
- Chosen.prototype.container_mousedown = function(evt) {
430
- var target_closelink;
431
- if (!this.is_disabled) {
432
- target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
433
- if (evt && evt.type === "mousedown" && !this.results_showing) {
434
- evt.stopPropagation();
435
- }
436
- if (!this.pending_destroy_click && !target_closelink) {
437
- if (!this.active_field) {
438
- if (this.is_multiple) this.search_field.val("");
439
- $(document).click(this.click_test_action);
440
- this.results_show();
441
- } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
442
- evt.preventDefault();
443
- this.results_toggle();
444
- }
445
- return this.activate_field();
446
- } else {
447
- return this.pending_destroy_click = false;
448
- }
449
- }
450
- };
451
-
452
- Chosen.prototype.container_mouseup = function(evt) {
453
- if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
454
- return this.results_reset(evt);
455
- }
456
- };
457
-
458
- Chosen.prototype.blur_test = function(evt) {
459
- if (!this.active_field && this.container.hasClass("chzn-container-active")) {
460
- return this.close_field();
461
- }
462
- };
463
-
464
- Chosen.prototype.close_field = function() {
465
- $(document).unbind("click", this.click_test_action);
466
- if (!this.is_multiple) {
467
- this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
468
- this.search_field.attr("tabindex", -1);
469
- }
470
- this.active_field = false;
471
- this.results_hide();
472
- this.container.removeClass("chzn-container-active");
473
- this.winnow_results_clear();
474
- this.clear_backstroke();
475
- this.show_search_field_default();
476
- return this.search_field_scale();
477
- };
478
-
479
- Chosen.prototype.activate_field = function() {
480
- if (!this.is_multiple && !this.active_field) {
481
- this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
482
- this.selected_item.attr("tabindex", -1);
483
- }
484
- this.container.addClass("chzn-container-active");
485
- this.active_field = true;
486
- this.search_field.val(this.search_field.val());
487
- return this.search_field.focus();
488
- };
489
-
490
- Chosen.prototype.test_active_click = function(evt) {
491
- if ($(evt.target).parents('#' + this.container_id).length) {
492
- return this.active_field = true;
493
- } else {
494
- return this.close_field();
495
- }
496
- };
497
-
498
- Chosen.prototype.results_build = function() {
499
- var content, data, _i, _len, _ref;
500
- this.parsing = true;
501
- this.results_data = root.SelectParser.select_to_array(this.form_field);
502
- if (this.is_multiple && this.choices > 0) {
503
- this.search_choices.find("li.search-choice").remove();
504
- this.choices = 0;
505
- } else if (!this.is_multiple) {
506
- this.selected_item.addClass("chzn-default").find("span").text(this.default_text);
507
- if (this.form_field.options.length <= this.disable_search_threshold) {
508
- this.container.addClass("chzn-container-single-nosearch");
509
- } else {
510
- this.container.removeClass("chzn-container-single-nosearch");
511
- }
512
- }
513
- content = '';
514
- _ref = this.results_data;
515
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
516
- data = _ref[_i];
517
- if (data.group) {
518
- content += this.result_add_group(data);
519
- } else if (!data.empty) {
520
- content += this.result_add_option(data);
521
- if (data.selected && this.is_multiple) {
522
- this.choice_build(data);
523
- } else if (data.selected && !this.is_multiple) {
524
- this.selected_item.removeClass("chzn-default").find("span").text(data.text);
525
- if (this.allow_single_deselect) this.single_deselect_control_build();
526
- }
527
- }
528
- }
529
- this.search_field_disabled();
530
- this.show_search_field_default();
531
- this.search_field_scale();
532
- this.search_results.html(content);
533
- return this.parsing = false;
534
- };
535
-
536
- Chosen.prototype.result_add_group = function(group) {
537
- if (!group.disabled) {
538
- group.dom_id = this.container_id + "_g_" + group.array_index;
539
- return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
540
- } else {
541
- return "";
542
- }
543
- };
544
-
545
- Chosen.prototype.result_do_highlight = function(el) {
546
- var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
547
- if (el.length) {
548
- this.result_clear_highlight();
549
- this.result_highlight = el;
550
- this.result_highlight.addClass("highlighted");
551
- maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
552
- visible_top = this.search_results.scrollTop();
553
- visible_bottom = maxHeight + visible_top;
554
- high_top = this.result_highlight.position().top + this.search_results.scrollTop();
555
- high_bottom = high_top + this.result_highlight.outerHeight();
556
- if (high_bottom >= visible_bottom) {
557
- return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
558
- } else if (high_top < visible_top) {
559
- return this.search_results.scrollTop(high_top);
560
- }
561
- }
562
- };
563
-
564
- Chosen.prototype.result_clear_highlight = function() {
565
- if (this.result_highlight) this.result_highlight.removeClass("highlighted");
566
- return this.result_highlight = null;
567
- };
568
-
569
- Chosen.prototype.results_show = function() {
570
- var dd_top;
571
- if (!this.is_multiple) {
572
- this.selected_item.addClass("chzn-single-with-drop");
573
- if (this.result_single_selected) {
574
- this.result_do_highlight(this.result_single_selected);
575
- }
576
- } else if (this.max_selected_options <= this.choices) {
577
- this.form_field_jq.trigger("liszt:maxselected", {
578
- chosen: this
579
- });
580
- return false;
581
- }
582
- dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
583
- this.form_field_jq.trigger("liszt:showing_dropdown", {
584
- chosen: this
585
- });
586
- this.dropdown.css({
587
- "top": dd_top + "px",
588
- "left": 0
589
- });
590
- this.results_showing = true;
591
- this.search_field.focus();
592
- this.search_field.val(this.search_field.val());
593
- return this.winnow_results();
594
- };
595
-
596
- Chosen.prototype.results_hide = function() {
597
- if (!this.is_multiple) {
598
- this.selected_item.removeClass("chzn-single-with-drop");
599
- }
600
- this.result_clear_highlight();
601
- this.form_field_jq.trigger("liszt:hiding_dropdown", {
602
- chosen: this
603
- });
604
- this.dropdown.css({
605
- "left": "-9000px"
606
- });
607
- return this.results_showing = false;
608
- };
609
-
610
- Chosen.prototype.set_tab_index = function(el) {
611
- var ti;
612
- if (this.form_field_jq.attr("tabindex")) {
613
- ti = this.form_field_jq.attr("tabindex");
614
- this.form_field_jq.attr("tabindex", -1);
615
- if (this.is_multiple) {
616
- return this.search_field.attr("tabindex", ti);
617
- } else {
618
- this.selected_item.attr("tabindex", ti);
619
- return this.search_field.attr("tabindex", -1);
620
- }
621
- }
622
- };
623
-
624
- Chosen.prototype.show_search_field_default = function() {
625
- if (this.is_multiple && this.choices < 1 && !this.active_field) {
626
- this.search_field.val(this.default_text);
627
- return this.search_field.addClass("default");
628
- } else {
629
- this.search_field.val("");
630
- return this.search_field.removeClass("default");
631
- }
632
- };
633
-
634
- Chosen.prototype.search_results_mouseup = function(evt) {
635
- var target;
636
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
637
- if (target.length) {
638
- this.result_highlight = target;
639
- return this.result_select(evt);
640
- }
641
- };
642
-
643
- Chosen.prototype.search_results_mouseover = function(evt) {
644
- var target;
645
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
646
- if (target) return this.result_do_highlight(target);
647
- };
648
-
649
- Chosen.prototype.search_results_mouseout = function(evt) {
650
- if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
651
- return this.result_clear_highlight();
652
- }
653
- };
654
-
655
- Chosen.prototype.choices_click = function(evt) {
656
- evt.preventDefault();
657
- if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
658
- return this.results_show();
659
- }
660
- };
661
-
662
- Chosen.prototype.choice_build = function(item) {
663
- var choice_id, link,
664
- _this = this;
665
- if (this.is_multiple && this.max_selected_options <= this.choices) {
666
- this.form_field_jq.trigger("liszt:maxselected", {
667
- chosen: this
668
- });
669
- return false;
670
- }
671
- choice_id = this.container_id + "_c_" + item.array_index;
672
- this.choices += 1;
673
- this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
674
- link = $('#' + choice_id).find("a").first();
675
- return link.click(function(evt) {
676
- return _this.choice_destroy_link_click(evt);
677
- });
678
- };
679
-
680
- Chosen.prototype.choice_destroy_link_click = function(evt) {
681
- evt.preventDefault();
682
- if (!this.is_disabled) {
683
- this.pending_destroy_click = true;
684
- return this.choice_destroy($(evt.target));
685
- } else {
686
- return evt.stopPropagation;
687
- }
688
- };
689
-
690
- Chosen.prototype.choice_destroy = function(link) {
691
- this.choices -= 1;
692
- this.show_search_field_default();
693
- if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
694
- this.results_hide();
695
- }
696
- this.result_deselect(link.attr("rel"));
697
- return link.parents('li').first().remove();
698
- };
699
-
700
- Chosen.prototype.results_reset = function() {
701
- this.form_field.options[0].selected = true;
702
- this.selected_item.find("span").text(this.default_text);
703
- if (!this.is_multiple) this.selected_item.addClass("chzn-default");
704
- this.show_search_field_default();
705
- this.results_reset_cleanup();
706
- this.form_field_jq.trigger("change");
707
- if (this.active_field) return this.results_hide();
708
- };
709
-
710
- Chosen.prototype.results_reset_cleanup = function() {
711
- return this.selected_item.find("abbr").remove();
712
- };
713
-
714
- Chosen.prototype.result_select = function(evt) {
715
- var high, high_id, item, position;
716
- if (this.result_highlight) {
717
- high = this.result_highlight;
718
- high_id = high.attr("id");
719
- this.result_clear_highlight();
720
- if (this.is_multiple) {
721
- this.result_deactivate(high);
722
- } else {
723
- this.search_results.find(".result-selected").removeClass("result-selected");
724
- this.result_single_selected = high;
725
- this.selected_item.removeClass("chzn-default");
726
- }
727
- high.addClass("result-selected");
728
- position = high_id.substr(high_id.lastIndexOf("_") + 1);
729
- item = this.results_data[position];
730
- item.selected = true;
731
- this.form_field.options[item.options_index].selected = true;
732
- if (this.is_multiple) {
733
- this.choice_build(item);
734
- } else {
735
- this.selected_item.find("span").first().text(item.text);
736
- if (this.allow_single_deselect) this.single_deselect_control_build();
737
- }
738
- if (!(evt.metaKey && this.is_multiple)) this.results_hide();
739
- this.search_field.val("");
740
- if (this.is_multiple || this.form_field_jq.val() !== this.current_value) {
741
- this.form_field_jq.trigger("change", {
742
- 'selected': this.form_field.options[item.options_index].value
743
- });
744
- }
745
- this.current_value = this.form_field_jq.val();
746
- return this.search_field_scale();
747
- }
748
- };
749
-
750
- Chosen.prototype.result_activate = function(el) {
751
- return el.addClass("active-result");
752
- };
753
-
754
- Chosen.prototype.result_deactivate = function(el) {
755
- return el.removeClass("active-result");
756
- };
757
-
758
- Chosen.prototype.result_deselect = function(pos) {
759
- var result, result_data;
760
- result_data = this.results_data[pos];
761
- result_data.selected = false;
762
- this.form_field.options[result_data.options_index].selected = false;
763
- result = $("#" + this.container_id + "_o_" + pos);
764
- result.removeClass("result-selected").addClass("active-result").show();
765
- this.result_clear_highlight();
766
- this.winnow_results();
767
- this.form_field_jq.trigger("change", {
768
- deselected: this.form_field.options[result_data.options_index].value
769
- });
770
- return this.search_field_scale();
771
- };
772
-
773
- Chosen.prototype.single_deselect_control_build = function() {
774
- if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
775
- return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
776
- }
777
- };
778
-
779
- Chosen.prototype.winnow_results = function() {
780
- var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
781
- this.no_results_clear();
782
- results = 0;
783
- searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
784
- regexAnchor = this.search_contains ? "" : "^";
785
- regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
786
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
787
- _ref = this.results_data;
788
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
789
- option = _ref[_i];
790
- if (!option.disabled && !option.empty) {
791
- if (option.group) {
792
- $('#' + option.dom_id).css('display', 'none');
793
- } else if (!(this.is_multiple && option.selected)) {
794
- found = false;
795
- result_id = option.dom_id;
796
- result = $("#" + result_id);
797
- if (regex.test(option.html)) {
798
- found = true;
799
- results += 1;
800
- } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
801
- parts = option.html.replace(/\[|\]/g, "").split(" ");
802
- if (parts.length) {
803
- for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
804
- part = parts[_j];
805
- if (regex.test(part)) {
806
- found = true;
807
- results += 1;
808
- }
809
- }
810
- }
811
- }
812
- if (found) {
813
- if (searchText.length) {
814
- startpos = option.html.search(zregex);
815
- text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
816
- text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
817
- } else {
818
- text = option.html;
819
- }
820
- result.html(text);
821
- this.result_activate(result);
822
- if (option.group_array_index != null) {
823
- $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
824
- }
825
- } else {
826
- if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
827
- this.result_clear_highlight();
828
- }
829
- this.result_deactivate(result);
830
- }
831
- }
832
- }
833
- }
834
- if (results < 1 && searchText.length) {
835
- return this.no_results(searchText);
836
- } else {
837
- return this.winnow_results_set_highlight();
838
- }
839
- };
840
-
841
- Chosen.prototype.winnow_results_clear = function() {
842
- var li, lis, _i, _len, _results;
843
- this.search_field.val("");
844
- lis = this.search_results.find("li");
845
- _results = [];
846
- for (_i = 0, _len = lis.length; _i < _len; _i++) {
847
- li = lis[_i];
848
- li = $(li);
849
- if (li.hasClass("group-result")) {
850
- _results.push(li.css('display', 'auto'));
851
- } else if (!this.is_multiple || !li.hasClass("result-selected")) {
852
- _results.push(this.result_activate(li));
853
- } else {
854
- _results.push(void 0);
855
- }
856
- }
857
- return _results;
858
- };
859
-
860
- Chosen.prototype.winnow_results_set_highlight = function() {
861
- var do_high, selected_results;
862
- if (!this.result_highlight) {
863
- selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
864
- do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
865
- if (do_high != null) return this.result_do_highlight(do_high);
866
- }
867
- };
868
-
869
- Chosen.prototype.no_results = function(terms) {
870
- var no_results_html;
871
- no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
872
- no_results_html.find("span").first().html(terms);
873
- return this.search_results.append(no_results_html);
874
- };
875
-
876
- Chosen.prototype.no_results_clear = function() {
877
- return this.search_results.find(".no-results").remove();
878
- };
879
-
880
- Chosen.prototype.keydown_arrow = function() {
881
- var first_active, next_sib;
882
- if (!this.result_highlight) {
883
- first_active = this.search_results.find("li.active-result").first();
884
- if (first_active) this.result_do_highlight($(first_active));
885
- } else if (this.results_showing) {
886
- next_sib = this.result_highlight.nextAll("li.active-result").first();
887
- if (next_sib) this.result_do_highlight(next_sib);
888
- }
889
- if (!this.results_showing) return this.results_show();
890
- };
891
-
892
- Chosen.prototype.keyup_arrow = function() {
893
- var prev_sibs;
894
- if (!this.results_showing && !this.is_multiple) {
895
- return this.results_show();
896
- } else if (this.result_highlight) {
897
- prev_sibs = this.result_highlight.prevAll("li.active-result");
898
- if (prev_sibs.length) {
899
- return this.result_do_highlight(prev_sibs.first());
900
- } else {
901
- if (this.choices > 0) this.results_hide();
902
- return this.result_clear_highlight();
903
- }
904
- }
905
- };
906
-
907
- Chosen.prototype.keydown_backstroke = function() {
908
- if (this.pending_backstroke) {
909
- this.choice_destroy(this.pending_backstroke.find("a").first());
910
- return this.clear_backstroke();
911
- } else {
912
- this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
913
- if (this.single_backstroke_delete) {
914
- return this.keydown_backstroke();
915
- } else {
916
- return this.pending_backstroke.addClass("search-choice-focus");
917
- }
918
- }
919
- };
920
-
921
- Chosen.prototype.clear_backstroke = function() {
922
- if (this.pending_backstroke) {
923
- this.pending_backstroke.removeClass("search-choice-focus");
924
- }
925
- return this.pending_backstroke = null;
926
- };
927
-
928
- Chosen.prototype.keydown_checker = function(evt) {
929
- var stroke, _ref;
930
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
931
- this.search_field_scale();
932
- if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
933
- switch (stroke) {
934
- case 8:
935
- this.backstroke_length = this.search_field.val().length;
936
- break;
937
- case 9:
938
- if (this.results_showing && !this.is_multiple) this.result_select(evt);
939
- this.mouse_on_container = false;
940
- break;
941
- case 13:
942
- evt.preventDefault();
943
- break;
944
- case 38:
945
- evt.preventDefault();
946
- this.keyup_arrow();
947
- break;
948
- case 40:
949
- this.keydown_arrow();
950
- break;
951
- }
952
- };
953
-
954
- Chosen.prototype.search_field_scale = function() {
955
- var dd_top, div, h, style, style_block, styles, w, _i, _len;
956
- if (this.is_multiple) {
957
- h = 0;
958
- w = 0;
959
- style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
960
- styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
961
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
962
- style = styles[_i];
963
- style_block += style + ":" + this.search_field.css(style) + ";";
964
- }
965
- div = $('<div />', {
966
- 'style': style_block
967
- });
968
- div.text(this.search_field.val());
969
- $('body').append(div);
970
- w = div.width() + 25;
971
- div.remove();
972
- if (w > this.f_width - 10) w = this.f_width - 10;
973
- this.search_field.css({
974
- 'width': w + 'px'
975
- });
976
- dd_top = this.container.height();
977
- return this.dropdown.css({
978
- "top": dd_top + "px"
979
- });
980
- }
981
- };
982
-
983
- Chosen.prototype.generate_random_id = function() {
984
- var string;
985
- string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
986
- while ($("#" + string).length > 0) {
987
- string += this.generate_random_char();
988
- }
989
- return string;
990
- };
991
-
992
- return Chosen;
993
-
994
- })(AbstractChosen);
995
-
996
- get_side_border_padding = function(elmt) {
997
- var side_border_padding;
998
- return side_border_padding = elmt.outerWidth() - elmt.width();
999
- };
1000
-
1001
- root.get_side_border_padding = get_side_border_padding;
1002
-
1003
- }).call(this);