brainsome_typus 4.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +488 -0
  3. data/Gemfile +60 -0
  4. data/Gemfile.lock +205 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +94 -0
  7. data/Rakefile +33 -0
  8. data/TODO.md +32 -0
  9. data/app/assets/javascripts/typus/application.js +11 -0
  10. data/app/assets/javascripts/typus/custom.js +2 -0
  11. data/app/assets/javascripts/typus/jquery-1.8.3-min.js +2 -0
  12. data/app/assets/javascripts/typus/jquery.application.js +33 -0
  13. data/app/assets/stylesheets/typus/application.css +5 -0
  14. data/app/assets/stylesheets/typus/custom.css +4 -0
  15. data/app/assets/stylesheets/typus/overrides.css.scss +46 -0
  16. data/app/controllers/admin/account_controller.rb +47 -0
  17. data/app/controllers/admin/base_controller.rb +44 -0
  18. data/app/controllers/admin/dashboard_controller.rb +5 -0
  19. data/app/controllers/admin/resource_controller.rb +7 -0
  20. data/app/controllers/admin/resources_controller.rb +256 -0
  21. data/app/controllers/admin/session_controller.rb +42 -0
  22. data/app/controllers/concerns/admin/actions.rb +88 -0
  23. data/app/controllers/concerns/admin/acts_as_list.rb +26 -0
  24. data/app/controllers/concerns/admin/ancestry.rb +26 -0
  25. data/app/controllers/concerns/admin/autocomplete.rb +11 -0
  26. data/app/controllers/concerns/admin/bulk.rb +76 -0
  27. data/app/controllers/concerns/admin/featured_image.rb +22 -0
  28. data/app/controllers/concerns/admin/filters.rb +57 -0
  29. data/app/controllers/concerns/admin/format.rb +48 -0
  30. data/app/controllers/concerns/admin/headless.rb +23 -0
  31. data/app/controllers/concerns/admin/hooks.rb +4 -0
  32. data/app/controllers/concerns/admin/multisite.rb +10 -0
  33. data/app/controllers/concerns/admin/navigation.rb +26 -0
  34. data/app/controllers/concerns/admin/trash.rb +65 -0
  35. data/app/helpers/admin/base_helper.rb +59 -0
  36. data/app/helpers/admin/resources/data_types/belongs_to_helper.rb +91 -0
  37. data/app/helpers/admin/resources/data_types/boolean_helper.rb +28 -0
  38. data/app/helpers/admin/resources/data_types/date_helper.rb +16 -0
  39. data/app/helpers/admin/resources/data_types/datetime_helper.rb +19 -0
  40. data/app/helpers/admin/resources/data_types/dragonfly_helper.rb +56 -0
  41. data/app/helpers/admin/resources/data_types/float_helper.rb +2 -0
  42. data/app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb +53 -0
  43. data/app/helpers/admin/resources/data_types/has_many_helper.rb +66 -0
  44. data/app/helpers/admin/resources/data_types/has_one_helper.rb +36 -0
  45. data/app/helpers/admin/resources/data_types/integer_helper.rb +10 -0
  46. data/app/helpers/admin/resources/data_types/paperclip_helper.rb +36 -0
  47. data/app/helpers/admin/resources/data_types/position_helper.rb +20 -0
  48. data/app/helpers/admin/resources/data_types/selector_helper.rb +11 -0
  49. data/app/helpers/admin/resources/data_types/string_helper.rb +32 -0
  50. data/app/helpers/admin/resources/data_types/text_helper.rb +7 -0
  51. data/app/helpers/admin/resources/data_types/transversal_helper.rb +8 -0
  52. data/app/helpers/admin/resources/data_types/tree_helper.rb +26 -0
  53. data/app/helpers/admin/resources/display_helper.rb +27 -0
  54. data/app/helpers/admin/resources/filters_helper.rb +28 -0
  55. data/app/helpers/admin/resources/form_helper.rb +84 -0
  56. data/app/helpers/admin/resources/list_helper.rb +31 -0
  57. data/app/helpers/admin/resources/pagination_helper.rb +28 -0
  58. data/app/helpers/admin/resources/relationships_helper.rb +34 -0
  59. data/app/helpers/admin/resources/sidebar_helper.rb +40 -0
  60. data/app/helpers/admin/resources/table_helper.rb +66 -0
  61. data/app/helpers/admin/resources_helper.rb +25 -0
  62. data/app/mailers/admin/mailer.rb +20 -0
  63. data/app/views/admin/account/_form.html.erb +11 -0
  64. data/app/views/admin/account/forgot_password.html.erb +19 -0
  65. data/app/views/admin/account/new.html.erb +13 -0
  66. data/app/views/admin/dashboard/_sidebar.html.erb +14 -0
  67. data/app/views/admin/dashboard/index.html.erb +6 -0
  68. data/app/views/admin/dashboard/styles.html.erb +153 -0
  69. data/app/views/admin/dashboard/widgets/_applications.html.erb +44 -0
  70. data/app/views/admin/dashboard/widgets/_default.html.erb +46 -0
  71. data/app/views/admin/dashboard/widgets/_models.html.erb +23 -0
  72. data/app/views/admin/dashboard/widgets/_models_extended.html.erb +25 -0
  73. data/app/views/admin/dashboard/widgets/_resources.html.erb +23 -0
  74. data/app/views/admin/dashboard/widgets/_users.html.erb +23 -0
  75. data/app/views/admin/mailer/reset_password_instructions.html.erb +7 -0
  76. data/app/views/admin/mailer/reset_password_instructions.text.erb +7 -0
  77. data/app/views/admin/resources/_actions.html.erb +23 -0
  78. data/app/views/admin/resources/_edit.html.erb +0 -0
  79. data/app/views/admin/resources/_form.html.erb +41 -0
  80. data/app/views/admin/resources/_form_javascripts.html.erb +0 -0
  81. data/app/views/admin/resources/_form_modal.html.erb +13 -0
  82. data/app/views/admin/resources/_index.html.erb +0 -0
  83. data/app/views/admin/resources/_new.html.erb +0 -0
  84. data/app/views/admin/resources/_pagination.html.erb +15 -0
  85. data/app/views/admin/resources/_show.html.erb +0 -0
  86. data/app/views/admin/resources/edit/_actions.html.erb +7 -0
  87. data/app/views/admin/resources/edit/_recently_edited.html.erb +8 -0
  88. data/app/views/admin/resources/edit.html.erb +22 -0
  89. data/app/views/admin/resources/index.html.erb +81 -0
  90. data/app/views/admin/resources/new.html.erb +21 -0
  91. data/app/views/admin/resources/show.html.erb +27 -0
  92. data/app/views/admin/session/new.html.erb +21 -0
  93. data/app/views/admin/shared/_head.html.erb +15 -0
  94. data/app/views/admin/shared/_modals.html.erb +3 -0
  95. data/app/views/admin/shared/_sidebar_placeholder.html.erb +0 -0
  96. data/app/views/admin/templates/README.md +5 -0
  97. data/app/views/admin/templates/_belongs_to.html.erb +13 -0
  98. data/app/views/admin/templates/_boolean.html.erb +6 -0
  99. data/app/views/admin/templates/_date.html.erb +6 -0
  100. data/app/views/admin/templates/_datetime.html.erb +7 -0
  101. data/app/views/admin/templates/_dragonfly.html.erb +8 -0
  102. data/app/views/admin/templates/_dragonfly_form_preview.html.erb +23 -0
  103. data/app/views/admin/templates/_dragonfly_preview.html.erb +12 -0
  104. data/app/views/admin/templates/_has_and_belongs_to_many.html.erb +21 -0
  105. data/app/views/admin/templates/_has_many.html.erb +20 -0
  106. data/app/views/admin/templates/_has_one.html.erb +14 -0
  107. data/app/views/admin/templates/_paperclip.html.erb +7 -0
  108. data/app/views/admin/templates/_paperclip_preview.html.erb +3 -0
  109. data/app/views/admin/templates/_password.html.erb +6 -0
  110. data/app/views/admin/templates/_position.html.erb +6 -0
  111. data/app/views/admin/templates/_profile_sidebar.html.erb +4 -0
  112. data/app/views/admin/templates/_selector.html.erb +6 -0
  113. data/app/views/admin/templates/_string.html.erb +6 -0
  114. data/app/views/admin/templates/_string_with_preview.html.erb +11 -0
  115. data/app/views/admin/templates/_text.html.erb +11 -0
  116. data/app/views/admin/templates/_text_with_ckeditor.html.erb +24 -0
  117. data/app/views/admin/templates/_text_with_ckeditor_and_assets.html.erb +38 -0
  118. data/app/views/admin/templates/_time.html.erb +9 -0
  119. data/app/views/admin/templates/_tree.html.erb +6 -0
  120. data/app/views/admin/templates/modals/_belongs_to.html.erb +56 -0
  121. data/app/views/admin/templates/modals/_dragonfly.html.erb +9 -0
  122. data/app/views/admin/templates/modals/_has_and_belongs_to_many.html.erb +19 -0
  123. data/app/views/admin/templates/modals/_has_many.html.erb +53 -0
  124. data/app/views/helpers/admin/base/_apps.html.erb +38 -0
  125. data/app/views/helpers/admin/base/_breadcrumbs.html.erb +6 -0
  126. data/app/views/helpers/admin/base/_flash_message.html.erb +3 -0
  127. data/app/views/helpers/admin/base/_login_info.html.erb +37 -0
  128. data/app/views/helpers/admin/dashboard/_resources.html.erb +19 -0
  129. data/app/views/helpers/admin/resources/_actions.html.erb +18 -0
  130. data/app/views/helpers/admin/resources/_errors.html.erb +12 -0
  131. data/app/views/helpers/admin/resources/_filters.html.erb +14 -0
  132. data/app/views/helpers/admin/resources/_search.html.erb +14 -0
  133. data/app/views/helpers/admin/resources/_sidebar.html.erb +17 -0
  134. data/app/views/helpers/admin/resources/_table.html.erb +47 -0
  135. data/app/views/layouts/admin/base.html.erb +40 -0
  136. data/app/views/layouts/admin/headless.html.erb +1 -0
  137. data/app/views/layouts/admin/session.html.erb +44 -0
  138. data/config/locales/typus.ca.models.yml +17 -0
  139. data/config/locales/typus.ca.yml +78 -0
  140. data/config/locales/typus.de.models.yml +17 -0
  141. data/config/locales/typus.de.yml +98 -0
  142. data/config/locales/typus.el.models.yml +17 -0
  143. data/config/locales/typus.el.yml +79 -0
  144. data/config/locales/typus.es.models.yml +18 -0
  145. data/config/locales/typus.es.yml +91 -0
  146. data/config/locales/typus.fr.models.yml +18 -0
  147. data/config/locales/typus.fr.yml +83 -0
  148. data/config/locales/typus.hu.models.yml +17 -0
  149. data/config/locales/typus.hu.yml +77 -0
  150. data/config/locales/typus.it.models.yml +18 -0
  151. data/config/locales/typus.it.yml +86 -0
  152. data/config/locales/typus.locale.models.yml.template +17 -0
  153. data/config/locales/typus.locale.yml.template +78 -0
  154. data/config/locales/typus.pt-BR.models.yml +17 -0
  155. data/config/locales/typus.pt-BR.yml +77 -0
  156. data/config/locales/typus.pt-PT.models.yml +17 -0
  157. data/config/locales/typus.pt-PT.yml +85 -0
  158. data/config/locales/typus.ru.models.yml +17 -0
  159. data/config/locales/typus.ru.yml +77 -0
  160. data/config/locales/typus.zh-CN.models.yml +17 -0
  161. data/config/locales/typus.zh-CN.yml +76 -0
  162. data/config/routes.rb +46 -0
  163. data/lib/generators/templates/config/initializers/typus.rb +35 -0
  164. data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
  165. data/lib/generators/templates/config/initializers/typus_resources.rb +24 -0
  166. data/lib/generators/templates/config/typus/README +58 -0
  167. data/lib/generators/templates/config/typus/application.yml +3 -0
  168. data/lib/generators/templates/config/typus/application_roles.yml +4 -0
  169. data/lib/generators/templates/config/typus/typus.yml +15 -0
  170. data/lib/generators/templates/config/typus/typus_roles.yml +4 -0
  171. data/lib/generators/templates/controller.erb +2 -0
  172. data/lib/generators/templates/migration.erb +22 -0
  173. data/lib/generators/templates/view.html.erb +13 -0
  174. data/lib/generators/typus/config_generator.rb +67 -0
  175. data/lib/generators/typus/controller_generator.rb +25 -0
  176. data/lib/generators/typus/initializers_generator.rb +20 -0
  177. data/lib/generators/typus/migration_generator.rb +94 -0
  178. data/lib/generators/typus/typus_generator.rb +52 -0
  179. data/lib/generators/typus/views_generator.rb +19 -0
  180. data/lib/support/active_record.rb +42 -0
  181. data/lib/support/fake_user.rb +47 -0
  182. data/lib/support/hash.rb +12 -0
  183. data/lib/support/object.rb +9 -0
  184. data/lib/support/string.rb +40 -0
  185. data/lib/tasks/typus.rake +11 -0
  186. data/lib/typus/authentication/base.rb +24 -0
  187. data/lib/typus/authentication/devise.rb +19 -0
  188. data/lib/typus/authentication/http_basic.rb +18 -0
  189. data/lib/typus/authentication/none.rb +15 -0
  190. data/lib/typus/authentication/none_with_role.rb +15 -0
  191. data/lib/typus/authentication/session.rb +123 -0
  192. data/lib/typus/configuration.rb +41 -0
  193. data/lib/typus/engine.rb +17 -0
  194. data/lib/typus/i18n.rb +48 -0
  195. data/lib/typus/orm/active_record/admin_user.rb +84 -0
  196. data/lib/typus/orm/active_record/class_methods.rb +104 -0
  197. data/lib/typus/orm/active_record/instance_methods.rb +76 -0
  198. data/lib/typus/orm/active_record/search.rb +44 -0
  199. data/lib/typus/orm/active_record.rb +10 -0
  200. data/lib/typus/orm/base/class_methods.rb +184 -0
  201. data/lib/typus/orm/base/search.rb +70 -0
  202. data/lib/typus/regex.rb +11 -0
  203. data/lib/typus/resources.rb +55 -0
  204. data/lib/typus/version.rb +10 -0
  205. data/lib/typus.rb +212 -0
  206. data/typus.gemspec +32 -0
  207. data/vendor/assets/adapt/css/1200.css +357 -0
  208. data/vendor/assets/adapt/css/1200.min.css +1 -0
  209. data/vendor/assets/adapt/css/1560.css +357 -0
  210. data/vendor/assets/adapt/css/1560.min.css +1 -0
  211. data/vendor/assets/adapt/css/720.css +357 -0
  212. data/vendor/assets/adapt/css/720.min.css +1 -0
  213. data/vendor/assets/adapt/css/960.css +357 -0
  214. data/vendor/assets/adapt/css/960.min.css +1 -0
  215. data/vendor/assets/adapt/css/fluid.css +345 -0
  216. data/vendor/assets/adapt/css/fluid.min.css +1 -0
  217. data/vendor/assets/adapt/css/master.css +120 -0
  218. data/vendor/assets/adapt/css/mobile.css +20 -0
  219. data/vendor/assets/adapt/css/mobile.min.css +1 -0
  220. data/vendor/assets/adapt/css/reset.css +202 -0
  221. data/vendor/assets/adapt/css/text.css +81 -0
  222. data/vendor/assets/adapt/images/h1.png +0 -0
  223. data/vendor/assets/adapt/js/adapt.js +135 -0
  224. data/vendor/assets/adapt/js/adapt.min.js +1 -0
  225. data/vendor/assets/bootstrap-2.3.2/css/bootstrap-responsive.css +1109 -0
  226. data/vendor/assets/bootstrap-2.3.2/css/bootstrap-responsive.min.css +9 -0
  227. data/vendor/assets/bootstrap-2.3.2/css/bootstrap.css +6167 -0
  228. data/vendor/assets/bootstrap-2.3.2/css/bootstrap.min.css +9 -0
  229. data/vendor/assets/bootstrap-2.3.2/img/glyphicons-halflings-white.png +0 -0
  230. data/vendor/assets/bootstrap-2.3.2/img/glyphicons-halflings.png +0 -0
  231. data/vendor/assets/bootstrap-2.3.2/js/bootstrap.js +2280 -0
  232. data/vendor/assets/bootstrap-2.3.2/js/bootstrap.min.js +6 -0
  233. data/vendor/assets/chosen/LICENSE.md +24 -0
  234. data/vendor/assets/chosen/chosen-sprite.png +0 -0
  235. data/vendor/assets/chosen/chosen.css +390 -0
  236. data/vendor/assets/chosen/chosen.jquery.js +902 -0
  237. data/vendor/assets/formalize/css/formalize.css +395 -0
  238. data/vendor/assets/formalize/images/button.png +0 -0
  239. data/vendor/assets/formalize/images/select_arrow.gif +0 -0
  240. data/vendor/assets/formalize/js/jquery.formalize.min.js +1 -0
  241. metadata +329 -0
@@ -0,0 +1,902 @@
1
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 0.9.6
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
+ SelectParser = (function() {
13
+ function SelectParser() {
14
+ this.options_index = 0;
15
+ this.parsed = [];
16
+ }
17
+ SelectParser.prototype.add_node = function(child) {
18
+ if (child.nodeName === "OPTGROUP") {
19
+ return this.add_group(child);
20
+ } else {
21
+ return this.add_option(child);
22
+ }
23
+ };
24
+ SelectParser.prototype.add_group = function(group) {
25
+ var group_position, option, _i, _len, _ref, _results;
26
+ group_position = this.parsed.length;
27
+ this.parsed.push({
28
+ array_index: group_position,
29
+ group: true,
30
+ label: group.label,
31
+ children: 0,
32
+ disabled: group.disabled
33
+ });
34
+ _ref = group.childNodes;
35
+ _results = [];
36
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
37
+ option = _ref[_i];
38
+ _results.push(this.add_option(option, group_position, group.disabled));
39
+ }
40
+ return _results;
41
+ };
42
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
43
+ if (option.nodeName === "OPTION") {
44
+ if (option.text !== "") {
45
+ if (group_position != null) {
46
+ this.parsed[group_position].children += 1;
47
+ }
48
+ this.parsed.push({
49
+ array_index: this.parsed.length,
50
+ options_index: this.options_index,
51
+ value: option.value,
52
+ text: option.text,
53
+ html: option.innerHTML,
54
+ selected: option.selected,
55
+ disabled: group_disabled === true ? group_disabled : option.disabled,
56
+ group_array_index: group_position,
57
+ classes: option.className,
58
+ style: option.style.cssText
59
+ });
60
+ } else {
61
+ this.parsed.push({
62
+ array_index: this.parsed.length,
63
+ options_index: this.options_index,
64
+ empty: true
65
+ });
66
+ }
67
+ return this.options_index += 1;
68
+ }
69
+ };
70
+ return SelectParser;
71
+ })();
72
+ SelectParser.select_to_array = function(select) {
73
+ var child, parser, _i, _len, _ref;
74
+ parser = new SelectParser();
75
+ _ref = select.childNodes;
76
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
77
+ child = _ref[_i];
78
+ parser.add_node(child);
79
+ }
80
+ return parser.parsed;
81
+ };
82
+ this.SelectParser = SelectParser;
83
+ }).call(this);
84
+ (function() {
85
+ /*
86
+ Chosen source: generate output using 'cake build'
87
+ Copyright (c) 2011 by Harvest
88
+ */
89
+ var AbstractChosen, root;
90
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
91
+ root = this;
92
+ AbstractChosen = (function() {
93
+ function AbstractChosen(form_field, options) {
94
+ this.form_field = form_field;
95
+ this.options = options != null ? options : {};
96
+ this.set_default_values();
97
+ this.is_multiple = this.form_field.multiple;
98
+ this.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option";
99
+ this.setup();
100
+ this.set_up_html();
101
+ this.register_observers();
102
+ this.finish_setup();
103
+ }
104
+ AbstractChosen.prototype.set_default_values = function() {
105
+ this.click_test_action = __bind(function(evt) {
106
+ return this.test_active_click(evt);
107
+ }, this);
108
+ this.activate_action = __bind(function(evt) {
109
+ return this.activate_field(evt);
110
+ }, this);
111
+ this.active_field = false;
112
+ this.mouse_on_container = false;
113
+ this.results_showing = false;
114
+ this.result_highlighted = null;
115
+ this.result_single_selected = null;
116
+ 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;
117
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
118
+ this.choices = 0;
119
+ return this.results_none_found = this.options.no_results_text || "No results match";
120
+ };
121
+ AbstractChosen.prototype.mouse_enter = function() {
122
+ return this.mouse_on_container = true;
123
+ };
124
+ AbstractChosen.prototype.mouse_leave = function() {
125
+ return this.mouse_on_container = false;
126
+ };
127
+ AbstractChosen.prototype.input_focus = function(evt) {
128
+ if (!this.active_field) {
129
+ return setTimeout((__bind(function() {
130
+ return this.container_mousedown();
131
+ }, this)), 50);
132
+ }
133
+ };
134
+ AbstractChosen.prototype.input_blur = function(evt) {
135
+ if (!this.mouse_on_container) {
136
+ this.active_field = false;
137
+ return setTimeout((__bind(function() {
138
+ return this.blur_test();
139
+ }, this)), 100);
140
+ }
141
+ };
142
+ AbstractChosen.prototype.result_add_option = function(option) {
143
+ var classes, style;
144
+ if (!option.disabled) {
145
+ option.dom_id = this.container_id + "_o_" + option.array_index;
146
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
147
+ if (option.selected) {
148
+ classes.push("result-selected");
149
+ }
150
+ if (option.group_array_index != null) {
151
+ classes.push("group-option");
152
+ }
153
+ if (option.classes !== "") {
154
+ classes.push(option.classes);
155
+ }
156
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
157
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
158
+ } else {
159
+ return "";
160
+ }
161
+ };
162
+ AbstractChosen.prototype.results_update_field = function() {
163
+ this.result_clear_highlight();
164
+ this.result_single_selected = null;
165
+ return this.results_build();
166
+ };
167
+ AbstractChosen.prototype.results_toggle = function() {
168
+ if (this.results_showing) {
169
+ return this.results_hide();
170
+ } else {
171
+ return this.results_show();
172
+ }
173
+ };
174
+ AbstractChosen.prototype.results_search = function(evt) {
175
+ if (this.results_showing) {
176
+ return this.winnow_results();
177
+ } else {
178
+ return this.results_show();
179
+ }
180
+ };
181
+ AbstractChosen.prototype.keyup_checker = function(evt) {
182
+ var stroke, _ref;
183
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
184
+ this.search_field_scale();
185
+ switch (stroke) {
186
+ case 8:
187
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
188
+ return this.keydown_backstroke();
189
+ } else if (!this.pending_backstroke) {
190
+ this.result_clear_highlight();
191
+ return this.results_search();
192
+ }
193
+ break;
194
+ case 13:
195
+ evt.preventDefault();
196
+ if (this.results_showing) {
197
+ return this.result_select(evt);
198
+ }
199
+ break;
200
+ case 27:
201
+ if (this.results_showing) {
202
+ this.results_hide();
203
+ }
204
+ return true;
205
+ case 9:
206
+ case 38:
207
+ case 40:
208
+ case 16:
209
+ case 91:
210
+ case 17:
211
+ break;
212
+ default:
213
+ return this.results_search();
214
+ }
215
+ };
216
+ AbstractChosen.prototype.generate_field_id = function() {
217
+ var new_id;
218
+ new_id = this.generate_random_id();
219
+ this.form_field.id = new_id;
220
+ return new_id;
221
+ };
222
+ AbstractChosen.prototype.generate_random_char = function() {
223
+ var chars, newchar, rand;
224
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
225
+ rand = Math.floor(Math.random() * chars.length);
226
+ return newchar = chars.substring(rand, rand + 1);
227
+ };
228
+ return AbstractChosen;
229
+ })();
230
+ root.AbstractChosen = AbstractChosen;
231
+ }).call(this);
232
+ (function() {
233
+ /*
234
+ Chosen source: generate output using 'cake build'
235
+ Copyright (c) 2011 by Harvest
236
+ */
237
+ var $, Chosen, get_side_border_padding, root;
238
+ var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
239
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
240
+ function ctor() { this.constructor = child; }
241
+ ctor.prototype = parent.prototype;
242
+ child.prototype = new ctor;
243
+ child.__super__ = parent.prototype;
244
+ return child;
245
+ }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
246
+ root = this;
247
+ $ = jQuery;
248
+ $.fn.extend({
249
+ chosen: function(options) {
250
+ if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
251
+ return this;
252
+ }
253
+ return $(this).each(function(input_field) {
254
+ if (!($(this)).hasClass("chzn-done")) {
255
+ return new Chosen(this, options);
256
+ }
257
+ });
258
+ }
259
+ });
260
+ Chosen = (function() {
261
+ __extends(Chosen, AbstractChosen);
262
+ function Chosen() {
263
+ Chosen.__super__.constructor.apply(this, arguments);
264
+ }
265
+ Chosen.prototype.setup = function() {
266
+ this.form_field_jq = $(this.form_field);
267
+ return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
268
+ };
269
+ Chosen.prototype.finish_setup = function() {
270
+ return this.form_field_jq.addClass("chzn-done");
271
+ };
272
+ Chosen.prototype.set_up_html = function() {
273
+ var container_div, dd_top, dd_width, sf_width;
274
+ this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
275
+ this.container_id += "_chzn";
276
+ this.f_width = this.form_field_jq.outerWidth();
277
+ this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
278
+ container_div = $("<div />", {
279
+ id: this.container_id,
280
+ "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
281
+ style: 'width: ' + this.f_width + 'px;'
282
+ });
283
+ if (this.is_multiple) {
284
+ 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>');
285
+ } else {
286
+ container_div.html('<a href="javascript:void(0)" class="chzn-single"><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>');
287
+ }
288
+ this.form_field_jq.hide().after(container_div);
289
+ this.container = $('#' + this.container_id);
290
+ this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
291
+ this.dropdown = this.container.find('div.chzn-drop').first();
292
+ dd_top = this.container.height();
293
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
294
+ this.dropdown.css({
295
+ "width": dd_width + "px",
296
+ "top": dd_top + "px"
297
+ });
298
+ this.search_field = this.container.find('input').first();
299
+ this.search_results = this.container.find('ul.chzn-results').first();
300
+ this.search_field_scale();
301
+ this.search_no_results = this.container.find('li.no-results').first();
302
+ if (this.is_multiple) {
303
+ this.search_choices = this.container.find('ul.chzn-choices').first();
304
+ this.search_container = this.container.find('li.search-field').first();
305
+ } else {
306
+ this.search_container = this.container.find('div.chzn-search').first();
307
+ this.selected_item = this.container.find('.chzn-single').first();
308
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
309
+ this.search_field.css({
310
+ "width": sf_width + "px"
311
+ });
312
+ }
313
+ this.results_build();
314
+ this.set_tab_index();
315
+ return this.form_field_jq.trigger("liszt:ready", {
316
+ chosen: this
317
+ });
318
+ };
319
+ Chosen.prototype.register_observers = function() {
320
+ this.container.mousedown(__bind(function(evt) {
321
+ return this.container_mousedown(evt);
322
+ }, this));
323
+ this.container.mouseup(__bind(function(evt) {
324
+ return this.container_mouseup(evt);
325
+ }, this));
326
+ this.container.mouseenter(__bind(function(evt) {
327
+ return this.mouse_enter(evt);
328
+ }, this));
329
+ this.container.mouseleave(__bind(function(evt) {
330
+ return this.mouse_leave(evt);
331
+ }, this));
332
+ this.search_results.mouseup(__bind(function(evt) {
333
+ return this.search_results_mouseup(evt);
334
+ }, this));
335
+ this.search_results.mouseover(__bind(function(evt) {
336
+ return this.search_results_mouseover(evt);
337
+ }, this));
338
+ this.search_results.mouseout(__bind(function(evt) {
339
+ return this.search_results_mouseout(evt);
340
+ }, this));
341
+ this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
342
+ return this.results_update_field(evt);
343
+ }, this));
344
+ this.search_field.blur(__bind(function(evt) {
345
+ return this.input_blur(evt);
346
+ }, this));
347
+ this.search_field.keyup(__bind(function(evt) {
348
+ return this.keyup_checker(evt);
349
+ }, this));
350
+ this.search_field.keydown(__bind(function(evt) {
351
+ return this.keydown_checker(evt);
352
+ }, this));
353
+ if (this.is_multiple) {
354
+ this.search_choices.click(__bind(function(evt) {
355
+ return this.choices_click(evt);
356
+ }, this));
357
+ return this.search_field.focus(__bind(function(evt) {
358
+ return this.input_focus(evt);
359
+ }, this));
360
+ } else {
361
+ return this.container.click(__bind(function(evt) {
362
+ return evt.preventDefault();
363
+ }, this));
364
+ }
365
+ };
366
+ Chosen.prototype.search_field_disabled = function() {
367
+ this.is_disabled = this.form_field_jq[0].disabled;
368
+ if (this.is_disabled) {
369
+ this.container.addClass('chzn-disabled');
370
+ this.search_field[0].disabled = true;
371
+ if (!this.is_multiple) {
372
+ this.selected_item.unbind("focus", this.activate_action);
373
+ }
374
+ return this.close_field();
375
+ } else {
376
+ this.container.removeClass('chzn-disabled');
377
+ this.search_field[0].disabled = false;
378
+ if (!this.is_multiple) {
379
+ return this.selected_item.bind("focus", this.activate_action);
380
+ }
381
+ }
382
+ };
383
+ Chosen.prototype.container_mousedown = function(evt) {
384
+ var target_closelink;
385
+ if (!this.is_disabled) {
386
+ target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
387
+ if (evt && evt.type === "mousedown") {
388
+ evt.stopPropagation();
389
+ }
390
+ if (!this.pending_destroy_click && !target_closelink) {
391
+ if (!this.active_field) {
392
+ if (this.is_multiple) {
393
+ this.search_field.val("");
394
+ }
395
+ $(document).click(this.click_test_action);
396
+ this.results_show();
397
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
398
+ evt.preventDefault();
399
+ this.results_toggle();
400
+ }
401
+ return this.activate_field();
402
+ } else {
403
+ return this.pending_destroy_click = false;
404
+ }
405
+ }
406
+ };
407
+ Chosen.prototype.container_mouseup = function(evt) {
408
+ if (evt.target.nodeName === "ABBR") {
409
+ return this.results_reset(evt);
410
+ }
411
+ };
412
+ Chosen.prototype.blur_test = function(evt) {
413
+ if (!this.active_field && this.container.hasClass("chzn-container-active")) {
414
+ return this.close_field();
415
+ }
416
+ };
417
+ Chosen.prototype.close_field = function() {
418
+ $(document).unbind("click", this.click_test_action);
419
+ if (!this.is_multiple) {
420
+ this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
421
+ this.search_field.attr("tabindex", -1);
422
+ }
423
+ this.active_field = false;
424
+ this.results_hide();
425
+ this.container.removeClass("chzn-container-active");
426
+ this.winnow_results_clear();
427
+ this.clear_backstroke();
428
+ this.show_search_field_default();
429
+ return this.search_field_scale();
430
+ };
431
+ Chosen.prototype.activate_field = function() {
432
+ if (!this.is_multiple && !this.active_field) {
433
+ this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
434
+ this.selected_item.attr("tabindex", -1);
435
+ }
436
+ this.container.addClass("chzn-container-active");
437
+ this.active_field = true;
438
+ this.search_field.val(this.search_field.val());
439
+ return this.search_field.focus();
440
+ };
441
+ Chosen.prototype.test_active_click = function(evt) {
442
+ if ($(evt.target).parents('#' + this.container_id).length) {
443
+ return this.active_field = true;
444
+ } else {
445
+ return this.close_field();
446
+ }
447
+ };
448
+ Chosen.prototype.results_build = function() {
449
+ var content, data, _i, _len, _ref;
450
+ this.parsing = true;
451
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
452
+ if (this.is_multiple && this.choices > 0) {
453
+ this.search_choices.find("li.search-choice").remove();
454
+ this.choices = 0;
455
+ } else if (!this.is_multiple) {
456
+ this.selected_item.find("span").text(this.default_text);
457
+ if (this.form_field.options.length <= this.disable_search_threshold) {
458
+ this.container.addClass("chzn-container-single-nosearch");
459
+ } else {
460
+ this.container.removeClass("chzn-container-single-nosearch");
461
+ }
462
+ }
463
+ content = '';
464
+ _ref = this.results_data;
465
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
466
+ data = _ref[_i];
467
+ if (data.group) {
468
+ content += this.result_add_group(data);
469
+ } else if (!data.empty) {
470
+ content += this.result_add_option(data);
471
+ if (data.selected && this.is_multiple) {
472
+ this.choice_build(data);
473
+ } else if (data.selected && !this.is_multiple) {
474
+ this.selected_item.find("span").text(data.text);
475
+ if (this.allow_single_deselect) {
476
+ this.single_deselect_control_build();
477
+ }
478
+ }
479
+ }
480
+ }
481
+ this.search_field_disabled();
482
+ this.show_search_field_default();
483
+ this.search_field_scale();
484
+ this.search_results.html(content);
485
+ return this.parsing = false;
486
+ };
487
+ Chosen.prototype.result_add_group = function(group) {
488
+ if (!group.disabled) {
489
+ group.dom_id = this.container_id + "_g_" + group.array_index;
490
+ return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
491
+ } else {
492
+ return "";
493
+ }
494
+ };
495
+ Chosen.prototype.result_do_highlight = function(el) {
496
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
497
+ if (el.length) {
498
+ this.result_clear_highlight();
499
+ this.result_highlight = el;
500
+ this.result_highlight.addClass("highlighted");
501
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
502
+ visible_top = this.search_results.scrollTop();
503
+ visible_bottom = maxHeight + visible_top;
504
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
505
+ high_bottom = high_top + this.result_highlight.outerHeight();
506
+ if (high_bottom >= visible_bottom) {
507
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
508
+ } else if (high_top < visible_top) {
509
+ return this.search_results.scrollTop(high_top);
510
+ }
511
+ }
512
+ };
513
+ Chosen.prototype.result_clear_highlight = function() {
514
+ if (this.result_highlight) {
515
+ this.result_highlight.removeClass("highlighted");
516
+ }
517
+ return this.result_highlight = null;
518
+ };
519
+ Chosen.prototype.results_show = function() {
520
+ var dd_top;
521
+ if (!this.is_multiple) {
522
+ this.selected_item.addClass("chzn-single-with-drop");
523
+ if (this.result_single_selected) {
524
+ this.result_do_highlight(this.result_single_selected);
525
+ }
526
+ }
527
+ dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
528
+ this.dropdown.css({
529
+ "top": dd_top + "px",
530
+ "left": 0
531
+ });
532
+ this.results_showing = true;
533
+ this.search_field.focus();
534
+ this.search_field.val(this.search_field.val());
535
+ return this.winnow_results();
536
+ };
537
+ Chosen.prototype.results_hide = function() {
538
+ if (!this.is_multiple) {
539
+ this.selected_item.removeClass("chzn-single-with-drop");
540
+ }
541
+ this.result_clear_highlight();
542
+ this.dropdown.css({
543
+ "left": "-9000px"
544
+ });
545
+ return this.results_showing = false;
546
+ };
547
+ Chosen.prototype.set_tab_index = function(el) {
548
+ var ti;
549
+ if (this.form_field_jq.attr("tabindex")) {
550
+ ti = this.form_field_jq.attr("tabindex");
551
+ this.form_field_jq.attr("tabindex", -1);
552
+ if (this.is_multiple) {
553
+ return this.search_field.attr("tabindex", ti);
554
+ } else {
555
+ this.selected_item.attr("tabindex", ti);
556
+ return this.search_field.attr("tabindex", -1);
557
+ }
558
+ }
559
+ };
560
+ Chosen.prototype.show_search_field_default = function() {
561
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
562
+ this.search_field.val(this.default_text);
563
+ return this.search_field.addClass("default");
564
+ } else {
565
+ this.search_field.val("");
566
+ return this.search_field.removeClass("default");
567
+ }
568
+ };
569
+ Chosen.prototype.search_results_mouseup = function(evt) {
570
+ var target;
571
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
572
+ if (target.length) {
573
+ this.result_highlight = target;
574
+ return this.result_select(evt);
575
+ }
576
+ };
577
+ Chosen.prototype.search_results_mouseover = function(evt) {
578
+ var target;
579
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
580
+ if (target) {
581
+ return this.result_do_highlight(target);
582
+ }
583
+ };
584
+ Chosen.prototype.search_results_mouseout = function(evt) {
585
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
586
+ return this.result_clear_highlight();
587
+ }
588
+ };
589
+ Chosen.prototype.choices_click = function(evt) {
590
+ evt.preventDefault();
591
+ if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
592
+ return this.results_show();
593
+ }
594
+ };
595
+ Chosen.prototype.choice_build = function(item) {
596
+ var choice_id, link;
597
+ choice_id = this.container_id + "_c_" + item.array_index;
598
+ this.choices += 1;
599
+ 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>');
600
+ link = $('#' + choice_id).find("a").first();
601
+ return link.click(__bind(function(evt) {
602
+ return this.choice_destroy_link_click(evt);
603
+ }, this));
604
+ };
605
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
606
+ evt.preventDefault();
607
+ if (!this.is_disabled) {
608
+ this.pending_destroy_click = true;
609
+ return this.choice_destroy($(evt.target));
610
+ } else {
611
+ return evt.stopPropagation;
612
+ }
613
+ };
614
+ Chosen.prototype.choice_destroy = function(link) {
615
+ this.choices -= 1;
616
+ this.show_search_field_default();
617
+ if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
618
+ this.results_hide();
619
+ }
620
+ this.result_deselect(link.attr("rel"));
621
+ return link.parents('li').first().remove();
622
+ };
623
+ Chosen.prototype.results_reset = function(evt) {
624
+ this.form_field.options[0].selected = true;
625
+ this.selected_item.find("span").text(this.default_text);
626
+ this.show_search_field_default();
627
+ $(evt.target).remove();
628
+ this.form_field_jq.trigger("change");
629
+ if (this.active_field) {
630
+ return this.results_hide();
631
+ }
632
+ };
633
+ Chosen.prototype.result_select = function(evt) {
634
+ var high, high_id, item, position;
635
+ if (this.result_highlight) {
636
+ high = this.result_highlight;
637
+ high_id = high.attr("id");
638
+ this.result_clear_highlight();
639
+ if (this.is_multiple) {
640
+ this.result_deactivate(high);
641
+ } else {
642
+ this.search_results.find(".result-selected").removeClass("result-selected");
643
+ this.result_single_selected = high;
644
+ }
645
+ high.addClass("result-selected");
646
+ position = high_id.substr(high_id.lastIndexOf("_") + 1);
647
+ item = this.results_data[position];
648
+ item.selected = true;
649
+ this.form_field.options[item.options_index].selected = true;
650
+ if (this.is_multiple) {
651
+ this.choice_build(item);
652
+ } else {
653
+ this.selected_item.find("span").first().text(item.text);
654
+ if (this.allow_single_deselect) {
655
+ this.single_deselect_control_build();
656
+ }
657
+ }
658
+ if (!(evt.metaKey && this.is_multiple)) {
659
+ this.results_hide();
660
+ }
661
+ this.search_field.val("");
662
+ this.form_field_jq.trigger("change");
663
+ return this.search_field_scale();
664
+ }
665
+ };
666
+ Chosen.prototype.result_activate = function(el) {
667
+ return el.addClass("active-result");
668
+ };
669
+ Chosen.prototype.result_deactivate = function(el) {
670
+ return el.removeClass("active-result");
671
+ };
672
+ Chosen.prototype.result_deselect = function(pos) {
673
+ var result, result_data;
674
+ result_data = this.results_data[pos];
675
+ result_data.selected = false;
676
+ this.form_field.options[result_data.options_index].selected = false;
677
+ result = $("#" + this.container_id + "_o_" + pos);
678
+ result.removeClass("result-selected").addClass("active-result").show();
679
+ this.result_clear_highlight();
680
+ this.winnow_results();
681
+ this.form_field_jq.trigger("change");
682
+ return this.search_field_scale();
683
+ };
684
+ Chosen.prototype.single_deselect_control_build = function() {
685
+ if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
686
+ return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
687
+ }
688
+ };
689
+ Chosen.prototype.winnow_results = function() {
690
+ var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
691
+ this.no_results_clear();
692
+ results = 0;
693
+ searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
694
+ regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
695
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
696
+ _ref = this.results_data;
697
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
698
+ option = _ref[_i];
699
+ if (!option.disabled && !option.empty) {
700
+ if (option.group) {
701
+ $('#' + option.dom_id).css('display', 'none');
702
+ } else if (!(this.is_multiple && option.selected)) {
703
+ found = false;
704
+ result_id = option.dom_id;
705
+ result = $("#" + result_id);
706
+ if (regex.test(option.html)) {
707
+ found = true;
708
+ results += 1;
709
+ } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
710
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
711
+ if (parts.length) {
712
+ for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
713
+ part = parts[_j];
714
+ if (regex.test(part)) {
715
+ found = true;
716
+ results += 1;
717
+ }
718
+ }
719
+ }
720
+ }
721
+ if (found) {
722
+ if (searchText.length) {
723
+ startpos = option.html.search(zregex);
724
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
725
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
726
+ } else {
727
+ text = option.html;
728
+ }
729
+ result.html(text);
730
+ this.result_activate(result);
731
+ if (option.group_array_index != null) {
732
+ $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
733
+ }
734
+ } else {
735
+ if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
736
+ this.result_clear_highlight();
737
+ }
738
+ this.result_deactivate(result);
739
+ }
740
+ }
741
+ }
742
+ }
743
+ if (results < 1 && searchText.length) {
744
+ return this.no_results(searchText);
745
+ } else {
746
+ return this.winnow_results_set_highlight();
747
+ }
748
+ };
749
+ Chosen.prototype.winnow_results_clear = function() {
750
+ var li, lis, _i, _len, _results;
751
+ this.search_field.val("");
752
+ lis = this.search_results.find("li");
753
+ _results = [];
754
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
755
+ li = lis[_i];
756
+ li = $(li);
757
+ _results.push(li.hasClass("group-result") ? li.css('display', 'auto') : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
758
+ }
759
+ return _results;
760
+ };
761
+ Chosen.prototype.winnow_results_set_highlight = function() {
762
+ var do_high, selected_results;
763
+ if (!this.result_highlight) {
764
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
765
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
766
+ if (do_high != null) {
767
+ return this.result_do_highlight(do_high);
768
+ }
769
+ }
770
+ };
771
+ Chosen.prototype.no_results = function(terms) {
772
+ var no_results_html;
773
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
774
+ no_results_html.find("span").first().html(terms);
775
+ return this.search_results.append(no_results_html);
776
+ };
777
+ Chosen.prototype.no_results_clear = function() {
778
+ return this.search_results.find(".no-results").remove();
779
+ };
780
+ Chosen.prototype.keydown_arrow = function() {
781
+ var first_active, next_sib;
782
+ if (!this.result_highlight) {
783
+ first_active = this.search_results.find("li.active-result").first();
784
+ if (first_active) {
785
+ this.result_do_highlight($(first_active));
786
+ }
787
+ } else if (this.results_showing) {
788
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
789
+ if (next_sib) {
790
+ this.result_do_highlight(next_sib);
791
+ }
792
+ }
793
+ if (!this.results_showing) {
794
+ return this.results_show();
795
+ }
796
+ };
797
+ Chosen.prototype.keyup_arrow = function() {
798
+ var prev_sibs;
799
+ if (!this.results_showing && !this.is_multiple) {
800
+ return this.results_show();
801
+ } else if (this.result_highlight) {
802
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
803
+ if (prev_sibs.length) {
804
+ return this.result_do_highlight(prev_sibs.first());
805
+ } else {
806
+ if (this.choices > 0) {
807
+ this.results_hide();
808
+ }
809
+ return this.result_clear_highlight();
810
+ }
811
+ }
812
+ };
813
+ Chosen.prototype.keydown_backstroke = function() {
814
+ if (this.pending_backstroke) {
815
+ this.choice_destroy(this.pending_backstroke.find("a").first());
816
+ return this.clear_backstroke();
817
+ } else {
818
+ this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
819
+ return this.pending_backstroke.addClass("search-choice-focus");
820
+ }
821
+ };
822
+ Chosen.prototype.clear_backstroke = function() {
823
+ if (this.pending_backstroke) {
824
+ this.pending_backstroke.removeClass("search-choice-focus");
825
+ }
826
+ return this.pending_backstroke = null;
827
+ };
828
+ Chosen.prototype.keydown_checker = function(evt) {
829
+ var stroke, _ref;
830
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
831
+ this.search_field_scale();
832
+ if (stroke !== 8 && this.pending_backstroke) {
833
+ this.clear_backstroke();
834
+ }
835
+ switch (stroke) {
836
+ case 8:
837
+ this.backstroke_length = this.search_field.val().length;
838
+ break;
839
+ case 9:
840
+ if (this.results_showing && !this.is_multiple) {
841
+ this.result_select(evt);
842
+ }
843
+ this.mouse_on_container = false;
844
+ break;
845
+ case 13:
846
+ evt.preventDefault();
847
+ break;
848
+ case 38:
849
+ evt.preventDefault();
850
+ this.keyup_arrow();
851
+ break;
852
+ case 40:
853
+ this.keydown_arrow();
854
+ break;
855
+ }
856
+ };
857
+ Chosen.prototype.search_field_scale = function() {
858
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
859
+ if (this.is_multiple) {
860
+ h = 0;
861
+ w = 0;
862
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
863
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
864
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
865
+ style = styles[_i];
866
+ style_block += style + ":" + this.search_field.css(style) + ";";
867
+ }
868
+ div = $('<div />', {
869
+ 'style': style_block
870
+ });
871
+ div.text(this.search_field.val());
872
+ $('body').append(div);
873
+ w = div.width() + 25;
874
+ div.remove();
875
+ if (w > this.f_width - 10) {
876
+ w = this.f_width - 10;
877
+ }
878
+ this.search_field.css({
879
+ 'width': w + 'px'
880
+ });
881
+ dd_top = this.container.height();
882
+ return this.dropdown.css({
883
+ "top": dd_top + "px"
884
+ });
885
+ }
886
+ };
887
+ Chosen.prototype.generate_random_id = function() {
888
+ var string;
889
+ string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
890
+ while ($("#" + string).length > 0) {
891
+ string += this.generate_random_char();
892
+ }
893
+ return string;
894
+ };
895
+ return Chosen;
896
+ })();
897
+ get_side_border_padding = function(elmt) {
898
+ var side_border_padding;
899
+ return side_border_padding = elmt.outerWidth() - elmt.width();
900
+ };
901
+ root.get_side_border_padding = get_side_border_padding;
902
+ }).call(this);