carnival 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (346) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +34 -0
  4. data/app/assets/images/carnival/avatar.png +0 -0
  5. data/app/assets/images/carnival/bg_button.png +0 -0
  6. data/app/assets/images/carnival/cal.png +0 -0
  7. data/app/assets/images/carnival/chosen-sprite.png +0 -0
  8. data/app/assets/images/carnival/chosen-sprite@2x.png +0 -0
  9. data/app/assets/images/carnival/datatables-loading.gif +0 -0
  10. data/app/assets/images/carnival/fonts/opensans-regular-webfont.eot +0 -0
  11. data/app/assets/images/carnival/fonts/opensans-regular-webfont.svg +252 -0
  12. data/app/assets/images/carnival/fonts/opensans-regular-webfont.ttf +0 -0
  13. data/app/assets/images/carnival/fonts/opensans-regular-webfont.woff +0 -0
  14. data/app/assets/images/carnival/fonts/opensans-semibold-webfont.eot +0 -0
  15. data/app/assets/images/carnival/fonts/opensans-semibold-webfont.svg +251 -0
  16. data/app/assets/images/carnival/fonts/opensans-semibold-webfont.ttf +0 -0
  17. data/app/assets/images/carnival/fonts/opensans-semibold-webfont.woff +0 -0
  18. data/app/assets/images/carnival/fonts/up-not.png +0 -0
  19. data/app/assets/images/carnival/header-bg.png +0 -0
  20. data/app/assets/images/carnival/novo.png +0 -0
  21. data/app/assets/images/carnival/overlay.png +0 -0
  22. data/app/assets/images/carnival/search-button.png +0 -0
  23. data/app/assets/images/carnival/search.png +0 -0
  24. data/app/assets/images/carnival/sort_asc.png +0 -0
  25. data/app/assets/images/carnival/sort_asc_disabled.png +0 -0
  26. data/app/assets/images/carnival/sort_both.png +0 -0
  27. data/app/assets/images/carnival/sort_desc.png +0 -0
  28. data/app/assets/images/carnival/sort_desc_disabled.png +0 -0
  29. data/app/assets/images/carnival/sprite.png +0 -0
  30. data/app/assets/images/carnival/sprites-active.png +0 -0
  31. data/app/assets/images/carnival/sprites.png +0 -0
  32. data/app/assets/images/carnival/up-not.png +0 -0
  33. data/app/assets/images/carnival/voltar.png +0 -0
  34. data/app/assets/javascripts/carnival/admin.js +10 -0
  35. data/app/assets/javascripts/carnival/advanced_search.js +40 -0
  36. data/app/assets/javascripts/carnival/data_tables_functions.js +75 -0
  37. data/app/assets/javascripts/carnival/external/chosen.jquery.js +1239 -0
  38. data/app/assets/javascripts/carnival/external/jquery-ui-1.9.1.custom.min.js +6 -0
  39. data/app/assets/javascripts/carnival/external/jquery.colorbox-min.js +7 -0
  40. data/app/assets/javascripts/carnival/external/jquery.dataTables.min.js +156 -0
  41. data/app/assets/javascripts/carnival/external/jquery.maskedinput.js +7 -0
  42. data/app/assets/javascripts/carnival/external/jquery.noty.js +560 -0
  43. data/app/assets/javascripts/carnival/external/jquery.noty.layout.bottom.js +34 -0
  44. data/app/assets/javascripts/carnival/external/jquery.noty.theme.default.js +156 -0
  45. data/app/assets/javascripts/carnival/external/perfect-scrollbar-0.4.6.min.js +4 -0
  46. data/app/assets/javascripts/carnival/external/perfect-scrollbar-0.4.6.with-mousewheel.min.js +4 -0
  47. data/app/assets/javascripts/carnival/vizir_admin.js +137 -0
  48. data/app/assets/stylesheets/carnival/admin.css +13 -0
  49. data/app/assets/stylesheets/carnival/admin_users.css +4 -0
  50. data/app/assets/stylesheets/carnival/chosen.css +435 -0
  51. data/app/assets/stylesheets/carnival/colorbox.css +69 -0
  52. data/app/assets/stylesheets/carnival/datatable.css +131 -0
  53. data/app/assets/stylesheets/carnival/formframe.css +407 -0
  54. data/app/assets/stylesheets/carnival/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  55. data/app/assets/stylesheets/carnival/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  56. data/app/assets/stylesheets/carnival/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  57. data/app/assets/stylesheets/carnival/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  58. data/app/assets/stylesheets/carnival/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  59. data/app/assets/stylesheets/carnival/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  60. data/app/assets/stylesheets/carnival/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  61. data/app/assets/stylesheets/carnival/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  62. data/app/assets/stylesheets/carnival/images/ui-icons_222222_256x240.png +0 -0
  63. data/app/assets/stylesheets/carnival/images/ui-icons_2e83ff_256x240.png +0 -0
  64. data/app/assets/stylesheets/carnival/images/ui-icons_454545_256x240.png +0 -0
  65. data/app/assets/stylesheets/carnival/images/ui-icons_888888_256x240.png +0 -0
  66. data/app/assets/stylesheets/carnival/images/ui-icons_cd0a0a_256x240.png +0 -0
  67. data/app/assets/stylesheets/carnival/jquery-ui-1.8.11.custom.css +573 -0
  68. data/app/assets/stylesheets/carnival/jquery.noty.css +104 -0
  69. data/app/assets/stylesheets/carnival/main.css +2223 -0
  70. data/app/assets/stylesheets/carnival/noty_theme_default.css +185 -0
  71. data/app/assets/stylesheets/carnival/perfect-scrollbar-0.4.6.min.css +5 -0
  72. data/app/assets/stylesheets/carnival/vizir-grid.css +663 -0
  73. data/app/controllers/carnival/admin_user_notifications_controller.rb +19 -0
  74. data/app/controllers/carnival/admin_users_controller.rb +10 -0
  75. data/app/controllers/carnival/base_admin_controller.rb +103 -0
  76. data/app/controllers/carnival/omniauth_callbacks_controller.rb +26 -0
  77. data/app/controllers/carnival/sessions_controller.rb +23 -0
  78. data/app/datatable/carnival/generic_datatable.rb +179 -0
  79. data/app/helpers/carnival/admin_users_helper.rb +4 -0
  80. data/app/helpers/carnival/base_admin_helper.rb +75 -0
  81. data/app/inputs/admin_base_input.rb +8 -0
  82. data/app/inputs/admin_currency_input.rb +12 -0
  83. data/app/inputs/admin_date_input.rb +11 -0
  84. data/app/inputs/admin_enum_input.rb +13 -0
  85. data/app/inputs/admin_relationship_select_input.rb +13 -0
  86. data/app/inputs/admin_text_input.rb +7 -0
  87. data/app/models/carnival/action.rb +51 -0
  88. data/app/models/carnival/admin_user.rb +40 -0
  89. data/app/models/carnival/admin_user_notification.rb +20 -0
  90. data/app/models/carnival/field.rb +102 -0
  91. data/app/models/carnival/form.rb +83 -0
  92. data/app/models/carnival/notification.rb +5 -0
  93. data/app/models/carnival/scope.rb +16 -0
  94. data/app/presenters/carnival/admin_user_notification_presenter.rb +61 -0
  95. data/app/presenters/carnival/admin_user_presenter.rb +53 -0
  96. data/app/presenters/carnival/base_admin_presenter.rb +336 -0
  97. data/app/views/carnival/admin_users/_form.html.haml +21 -0
  98. data/app/views/carnival/admin_users/edit.html.haml +3 -0
  99. data/app/views/carnival/admin_users/new.html.haml +4 -0
  100. data/app/views/carnival/admin_users/show.html.haml +14 -0
  101. data/app/views/carnival/index.html.haml +93 -0
  102. data/app/views/carnival/index.pdf.haml +5 -0
  103. data/app/views/carnival/login.html.haml +20 -0
  104. data/app/views/carnival/shared/_action_default.html.haml +1 -0
  105. data/app/views/carnival/shared/_action_delete.html.haml +1 -0
  106. data/app/views/carnival/shared/_add_button.html.haml +2 -0
  107. data/app/views/carnival/shared/_advanced_search.html.haml +26 -0
  108. data/app/views/carnival/shared/_advanced_search_field.html.haml +10 -0
  109. data/app/views/carnival/shared/_application_popup_partial.html.haml +12 -0
  110. data/app/views/carnival/shared/_batch_operation_checkbox.html.haml +4 -0
  111. data/app/views/carnival/shared/_delete.html.haml +1 -0
  112. data/app/views/carnival/shared/_edit_delete.html.haml +6 -0
  113. data/app/views/carnival/shared/_extra.html.haml +3 -0
  114. data/app/views/carnival/shared/_extra_item.html.haml +21 -0
  115. data/app/views/carnival/shared/_filter_bar.html.haml +3 -0
  116. data/app/views/carnival/shared/_header.pdf.haml +13 -0
  117. data/app/views/carnival/shared/_item_buttons.html.haml +3 -0
  118. data/app/views/carnival/shared/_link_fields.html.haml +6 -0
  119. data/app/views/carnival/shared/_list_cel.html.haml +9 -0
  120. data/app/views/carnival/shared/_list_cel.pdf.haml +9 -0
  121. data/app/views/carnival/shared/_period_filter.html.haml +54 -0
  122. data/app/views/carnival/shared/_report.pdf.haml +21 -0
  123. data/app/views/carnival/shared/_scope.html.haml +75 -0
  124. data/app/views/carnival/shared/_special_scope.html.haml +1 -0
  125. data/app/views/carnival/shared/form/_edit.html.haml +1 -0
  126. data/app/views/carnival/shared/form/_field.html.haml +8 -0
  127. data/app/views/carnival/shared/form/_form.html.haml +13 -0
  128. data/app/views/carnival/shared/form/edit.html.haml +6 -0
  129. data/app/views/carnival/shared/form/new.html.haml +7 -0
  130. data/app/views/carnival/shared/form/show.html.haml +16 -0
  131. data/app/views/carnival/shared/render_popup.js.erb +2 -0
  132. data/app/views/devise/confirmations/new.html.erb +12 -0
  133. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  134. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  135. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  136. data/app/views/devise/passwords/edit.html.erb +16 -0
  137. data/app/views/devise/passwords/new.html.erb +12 -0
  138. data/app/views/devise/registrations/edit.html.erb +29 -0
  139. data/app/views/devise/registrations/new.html.erb +18 -0
  140. data/app/views/devise/sessions/new.html.erb +19 -0
  141. data/app/views/devise/shared/_links.erb +25 -0
  142. data/app/views/devise/unlocks/new.html.erb +12 -0
  143. data/app/views/layouts/carnival/_menu.html.haml +30 -0
  144. data/app/views/layouts/carnival/_notifications_list.html.haml +27 -0
  145. data/app/views/layouts/carnival/admin.html.haml +51 -0
  146. data/config/initializers/carnival_initializer.rb +41 -0
  147. data/config/initializers/devise.rb +258 -0
  148. data/config/initializers/simple_form.rb +3 -0
  149. data/config/locales/carnival.en.yml +1 -0
  150. data/config/locales/carnival.pt.yml +228 -0
  151. data/config/locales/devise.en.yml +59 -0
  152. data/config/locales/devise.pt.yml +59 -0
  153. data/config/routes.rb +8 -0
  154. data/db/migrate/20140129211859_devise_create_admin_users.rb +43 -0
  155. data/db/migrate/20140129213216_create_notifications.rb +10 -0
  156. data/db/migrate/20140129223355_create_admin_user_notifications.rb +10 -0
  157. data/db/migrate/20140206144730_add_columns_to_admin_users.rb +7 -0
  158. data/lib/carnival.rb +13 -0
  159. data/lib/carnival/config.rb +10 -0
  160. data/lib/carnival/engine.rb +5 -0
  161. data/lib/carnival/routes.rb +13 -0
  162. data/lib/carnival/version.rb +3 -0
  163. data/lib/generators/carnival/install_generator.rb +18 -0
  164. data/lib/generators/carnival/templates/carnival_initializer.rb +41 -0
  165. data/lib/tasks/carnival_tasks.rake +4 -0
  166. data/test/carnival_test.rb +7 -0
  167. data/test/dummy/README.rdoc +28 -0
  168. data/test/dummy/Rakefile +6 -0
  169. data/test/dummy/app/assets/javascripts/application.js +13 -0
  170. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  171. data/test/dummy/app/controllers/admin/cities_controller.rb +9 -0
  172. data/test/dummy/app/controllers/admin/countries_controller.rb +9 -0
  173. data/test/dummy/app/controllers/admin/people_controller.rb +9 -0
  174. data/test/dummy/app/controllers/admin/states_controller.rb +9 -0
  175. data/test/dummy/app/controllers/admin/testes_controller.rb +9 -0
  176. data/test/dummy/app/controllers/application_controller.rb +5 -0
  177. data/test/dummy/app/helpers/application_helper.rb +2 -0
  178. data/test/dummy/app/models/admin.rb +5 -0
  179. data/test/dummy/app/models/admin/association_common.rb +23 -0
  180. data/test/dummy/app/models/admin/city.rb +11 -0
  181. data/test/dummy/app/models/admin/company.rb +14 -0
  182. data/test/dummy/app/models/admin/country.rb +9 -0
  183. data/test/dummy/app/models/admin/job.rb +10 -0
  184. data/test/dummy/app/models/admin/person.rb +17 -0
  185. data/test/dummy/app/models/admin/professional_experience.rb +14 -0
  186. data/test/dummy/app/models/admin/state.rb +12 -0
  187. data/test/dummy/app/models/job.rb +8 -0
  188. data/test/dummy/app/presenters/admin/city_presenter.rb +42 -0
  189. data/test/dummy/app/presenters/admin/country_presenter.rb +28 -0
  190. data/test/dummy/app/presenters/admin/person_presenter.rb +60 -0
  191. data/test/dummy/app/presenters/admin/state_presenter.rb +35 -0
  192. data/test/dummy/app/views/admin/testes/_form.html.haml +17 -0
  193. data/test/dummy/app/views/admin/testes/edit.html.haml +3 -0
  194. data/test/dummy/app/views/admin/testes/new.html.haml +4 -0
  195. data/test/dummy/app/views/admin/testes/show.html.haml +14 -0
  196. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  197. data/test/dummy/bin/bundle +3 -0
  198. data/test/dummy/bin/rails +4 -0
  199. data/test/dummy/bin/rake +4 -0
  200. data/test/dummy/config.ru +4 -0
  201. data/test/dummy/config/application.rb +22 -0
  202. data/test/dummy/config/boot.rb +5 -0
  203. data/test/dummy/config/database.yml +25 -0
  204. data/test/dummy/config/environment.rb +5 -0
  205. data/test/dummy/config/environments/development.rb +47 -0
  206. data/test/dummy/config/environments/production.rb +80 -0
  207. data/test/dummy/config/environments/test.rb +36 -0
  208. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  209. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  210. data/test/dummy/config/initializers/inflections.rb +16 -0
  211. data/test/dummy/config/initializers/mime_types.rb +5 -0
  212. data/test/dummy/config/initializers/secret_token.rb +12 -0
  213. data/test/dummy/config/initializers/session_store.rb +3 -0
  214. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  215. data/test/dummy/config/locales/en.yml +23 -0
  216. data/test/dummy/config/routes.rb +15 -0
  217. data/test/dummy/db/development.sqlite3 +0 -0
  218. data/test/dummy/db/migrate/20140206211804_create_admin_companies.rb +16 -0
  219. data/test/dummy/db/migrate/20140206211829_create_admin_countries.rb +10 -0
  220. data/test/dummy/db/migrate/20140206211850_create_admin_states.rb +12 -0
  221. data/test/dummy/db/migrate/20140206211923_create_admin_cities.rb +11 -0
  222. data/test/dummy/db/migrate/20140206212128_create_admin_people.rb +19 -0
  223. data/test/dummy/db/migrate/20140309013000_create_jobs.rb +9 -0
  224. data/test/dummy/db/migrate/20140309013019_create_professional_experiences.rb +14 -0
  225. data/test/dummy/db/migrate/20140323020642_devise_create_admin_users.carnival_engine.rb +44 -0
  226. data/test/dummy/db/migrate/20140323020643_create_notifications.carnival_engine.rb +11 -0
  227. data/test/dummy/db/migrate/20140323020644_create_admin_user_notifications.carnival_engine.rb +11 -0
  228. data/test/dummy/db/migrate/20140323020645_add_columns_to_admin_users.carnival_engine.rb +8 -0
  229. data/test/dummy/db/schema.rb +143 -0
  230. data/test/dummy/db/test.sqlite3 +0 -0
  231. data/test/dummy/log/bullet.log +0 -0
  232. data/test/dummy/log/development.log +6933 -0
  233. data/test/dummy/public/404.html +58 -0
  234. data/test/dummy/public/422.html +58 -0
  235. data/test/dummy/public/500.html +57 -0
  236. data/test/dummy/public/favicon.ico +0 -0
  237. data/test/dummy/tmp/cache/assets/development/sprockets/01c1d1cbb942f60130f0aa01d50c98d2 +0 -0
  238. data/test/dummy/tmp/cache/assets/development/sprockets/049c6f2079e2e93f96fd228df8c265ba +0 -0
  239. data/test/dummy/tmp/cache/assets/development/sprockets/0d9971c4a3b5017a7d2122508b66bb12 +0 -0
  240. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  241. data/test/dummy/tmp/cache/assets/development/sprockets/147e4215ac96fd8b8d373567ae00ed47 +0 -0
  242. data/test/dummy/tmp/cache/assets/development/sprockets/1634e1287a9914e738e710919b7cd6e4 +0 -0
  243. data/test/dummy/tmp/cache/assets/development/sprockets/16c6027bc506317d8266573d0ae1b510 +0 -0
  244. data/test/dummy/tmp/cache/assets/development/sprockets/16e4094498947b5f36bfbb490b94d025 +0 -0
  245. data/test/dummy/tmp/cache/assets/development/sprockets/197f549b9c46ec6679bddac8e4065948 +0 -0
  246. data/test/dummy/tmp/cache/assets/development/sprockets/2109e2acf993625dc0a3f05e7e0af523 +0 -0
  247. data/test/dummy/tmp/cache/assets/development/sprockets/22e50c67b95bf23b653e7a6768d38749 +0 -0
  248. data/test/dummy/tmp/cache/assets/development/sprockets/2684dad966b304ec2aee0149dc77c657 +0 -0
  249. data/test/dummy/tmp/cache/assets/development/sprockets/2908a36318747c72030e94441a2579c4 +0 -0
  250. data/test/dummy/tmp/cache/assets/development/sprockets/2a4d4d7ea99972ea41453ec4e6bad058 +0 -0
  251. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  252. data/test/dummy/tmp/cache/assets/development/sprockets/30c8c2e6ca355103a267133f6b45b0ce +0 -0
  253. data/test/dummy/tmp/cache/assets/development/sprockets/31177aaa32db75be241353c5819450b4 +0 -0
  254. data/test/dummy/tmp/cache/assets/development/sprockets/31a6581dfe5a788b2b450403959a97c5 +0 -0
  255. data/test/dummy/tmp/cache/assets/development/sprockets/32daf8a3bfd9da8ab261f5002f66389f +0 -0
  256. data/test/dummy/tmp/cache/assets/development/sprockets/33dfbc7bdde795abfd1031ceaa315dc8 +0 -0
  257. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  258. data/test/dummy/tmp/cache/assets/development/sprockets/3636240cbc1f10d05a7e27f44c330bf9 +0 -0
  259. data/test/dummy/tmp/cache/assets/development/sprockets/39d34c0caaa6f36d684fac1898a7f88f +0 -0
  260. data/test/dummy/tmp/cache/assets/development/sprockets/3ac0f4fad0d3e6d3d13d4ed2189dcabe +0 -0
  261. data/test/dummy/tmp/cache/assets/development/sprockets/3d8100b6e405407290dcf994ef05e0b7 +0 -0
  262. data/test/dummy/tmp/cache/assets/development/sprockets/3fd8a2a00bb4ebd69a3ecac257dbe536 +0 -0
  263. data/test/dummy/tmp/cache/assets/development/sprockets/3fdb709b3417757576eff80c0ec26b75 +0 -0
  264. data/test/dummy/tmp/cache/assets/development/sprockets/4423cb4765f66f187ffcb3be911c3600 +0 -0
  265. data/test/dummy/tmp/cache/assets/development/sprockets/45b86c586ed942b09cec2190b3c45c5a +0 -0
  266. data/test/dummy/tmp/cache/assets/development/sprockets/47ce692a80d5b075614c2489d7e3a142 +0 -0
  267. data/test/dummy/tmp/cache/assets/development/sprockets/4a7a4dcd9fea9bd2e287771c51f96631 +0 -0
  268. data/test/dummy/tmp/cache/assets/development/sprockets/4bd7e9214a07840040d269fdbf523e97 +0 -0
  269. data/test/dummy/tmp/cache/assets/development/sprockets/4c36f4196d9df171251bea6f3b587fe3 +0 -0
  270. data/test/dummy/tmp/cache/assets/development/sprockets/4e4b1f24c5e69f2f305f6d6483a1605c +0 -0
  271. data/test/dummy/tmp/cache/assets/development/sprockets/5090d7ea741c7f63994eb7b62e757f8f +0 -0
  272. data/test/dummy/tmp/cache/assets/development/sprockets/565023fdd3960225e817ec043b2d9474 +0 -0
  273. data/test/dummy/tmp/cache/assets/development/sprockets/5a4d2d875f1d8ab987ab653f896d1c39 +0 -0
  274. data/test/dummy/tmp/cache/assets/development/sprockets/5c8a4c90b3525681a2173b93b9d55293 +0 -0
  275. data/test/dummy/tmp/cache/assets/development/sprockets/5e7998a2046d512312e432aef40d3e22 +0 -0
  276. data/test/dummy/tmp/cache/assets/development/sprockets/5eacf8d05b2a79f57d54ee047a51e223 +0 -0
  277. data/test/dummy/tmp/cache/assets/development/sprockets/662125e0a3b8f685abafe02e03c6f442 +0 -0
  278. data/test/dummy/tmp/cache/assets/development/sprockets/6808736d34ec24fb10203097ff009a4d +0 -0
  279. data/test/dummy/tmp/cache/assets/development/sprockets/6c257cb7126b2e5bda4c42d414e39786 +0 -0
  280. data/test/dummy/tmp/cache/assets/development/sprockets/6ce5945ed85a31ec875a9973b5a3d3bc +0 -0
  281. data/test/dummy/tmp/cache/assets/development/sprockets/6d806eaa317f200bbf2832a0abf1c1cc +0 -0
  282. data/test/dummy/tmp/cache/assets/development/sprockets/6f6ec88ead28d25410be2a6f62ec79b1 +0 -0
  283. data/test/dummy/tmp/cache/assets/development/sprockets/706dcf8ec253808fea35ae06a4b408b1 +0 -0
  284. data/test/dummy/tmp/cache/assets/development/sprockets/7cfe3fa955d677396ed9e22193559a64 +0 -0
  285. data/test/dummy/tmp/cache/assets/development/sprockets/7e154ca951644e8aa1a2c6221f08db4f +0 -0
  286. data/test/dummy/tmp/cache/assets/development/sprockets/822d6436044fe88b0b3fbc6f3458ff88 +0 -0
  287. data/test/dummy/tmp/cache/assets/development/sprockets/84e6a879569ca7546a93558488a6ff70 +0 -0
  288. data/test/dummy/tmp/cache/assets/development/sprockets/8576d7c22dbd8222ab27a6c47f56a65c +0 -0
  289. data/test/dummy/tmp/cache/assets/development/sprockets/88144c375f9e329812d0302be96e0eab +0 -0
  290. data/test/dummy/tmp/cache/assets/development/sprockets/8a4b32386b5d8554473df478badd6ef9 +0 -0
  291. data/test/dummy/tmp/cache/assets/development/sprockets/8bc60f31f479cd0263d897aa45b88750 +0 -0
  292. data/test/dummy/tmp/cache/assets/development/sprockets/8e22d55d0b7b958a3904e7428269df65 +0 -0
  293. data/test/dummy/tmp/cache/assets/development/sprockets/918ab452d9c4634682ff94ffbd89e16f +0 -0
  294. data/test/dummy/tmp/cache/assets/development/sprockets/9455de99a5c68705427bbec9e50865ce +0 -0
  295. data/test/dummy/tmp/cache/assets/development/sprockets/958dd41e5252627471b2b65116401512 +0 -0
  296. data/test/dummy/tmp/cache/assets/development/sprockets/996ac001c901711cabb64b7e1940c54a +0 -0
  297. data/test/dummy/tmp/cache/assets/development/sprockets/9aec27b5fa2afdfa28068452ece0e6f0 +0 -0
  298. data/test/dummy/tmp/cache/assets/development/sprockets/9db7e75f3fa621ef08ade7ffda96e39f +0 -0
  299. data/test/dummy/tmp/cache/assets/development/sprockets/9dc853d92b5d774afadacc451965059c +0 -0
  300. data/test/dummy/tmp/cache/assets/development/sprockets/a125dd8e84a82fc90705bd3710fb93c2 +0 -0
  301. data/test/dummy/tmp/cache/assets/development/sprockets/a1c5386d742fb4d01bea977ed28f4a96 +0 -0
  302. data/test/dummy/tmp/cache/assets/development/sprockets/a30288f737d428b0feb2a78b3aab9c69 +0 -0
  303. data/test/dummy/tmp/cache/assets/development/sprockets/a40d723f9a6ad5b541009b8f05ce6533 +0 -0
  304. data/test/dummy/tmp/cache/assets/development/sprockets/a908448dd851cae431aa2b4bde9b5a98 +0 -0
  305. data/test/dummy/tmp/cache/assets/development/sprockets/aa5708f6fbe7528d49c127a7f89a2511 +0 -0
  306. data/test/dummy/tmp/cache/assets/development/sprockets/aaf9dac7bb02577a8005e39ca9225482 +0 -0
  307. data/test/dummy/tmp/cache/assets/development/sprockets/ad7b50123ad008ac0730bbbdf76a6bfe +0 -0
  308. data/test/dummy/tmp/cache/assets/development/sprockets/b271e3537645a42480b3ba7bca2342f4 +0 -0
  309. data/test/dummy/tmp/cache/assets/development/sprockets/ba891185d4fda83f4c16e6bb8139359b +0 -0
  310. data/test/dummy/tmp/cache/assets/development/sprockets/c72101732682999b6ca050f007fc6467 +0 -0
  311. data/test/dummy/tmp/cache/assets/development/sprockets/c8927e934e7960fc7907b6fc02ea7f08 +0 -0
  312. data/test/dummy/tmp/cache/assets/development/sprockets/c980544b5828a643ecaa8e784897c2c2 +0 -0
  313. data/test/dummy/tmp/cache/assets/development/sprockets/ca0e1997bc6c40f955a42ee777299750 +0 -0
  314. data/test/dummy/tmp/cache/assets/development/sprockets/cc2c3f8b87c5b787305412a3076058db +0 -0
  315. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  316. data/test/dummy/tmp/cache/assets/development/sprockets/d16461dfcae4b782f721ebd81e4f8740 +0 -0
  317. data/test/dummy/tmp/cache/assets/development/sprockets/d3b5d5784361e5eb827fbcdb0332258f +0 -0
  318. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  319. data/test/dummy/tmp/cache/assets/development/sprockets/d81122f6f2520c8f0785425936756e20 +0 -0
  320. data/test/dummy/tmp/cache/assets/development/sprockets/dbf160a6439a8d0b792ff46cf0a612f6 +0 -0
  321. data/test/dummy/tmp/cache/assets/development/sprockets/dc829340258cc36c0df423725df54649 +0 -0
  322. data/test/dummy/tmp/cache/assets/development/sprockets/dd326f3f4fd1c7fd075b58d6cb623a25 +0 -0
  323. data/test/dummy/tmp/cache/assets/development/sprockets/de060f82711b4b5c465f17b140eb2a61 +0 -0
  324. data/test/dummy/tmp/cache/assets/development/sprockets/e0352d0f97751491adbe6a94832772af +0 -0
  325. data/test/dummy/tmp/cache/assets/development/sprockets/e1d6efce94e71965434d2dde64fd8410 +0 -0
  326. data/test/dummy/tmp/cache/assets/development/sprockets/e4298973f799acdce289752c24bfddf2 +0 -0
  327. data/test/dummy/tmp/cache/assets/development/sprockets/e9c81ca91323dab8977ffd8a459cab06 +0 -0
  328. data/test/dummy/tmp/cache/assets/development/sprockets/eccab0d41d08e156ccd2f36f85949356 +0 -0
  329. data/test/dummy/tmp/cache/assets/development/sprockets/eed84a44f4e3915a39ea98ce25dc2570 +0 -0
  330. data/test/dummy/tmp/cache/assets/development/sprockets/f1e75c209067b23f5c0c7bf2006c43d0 +0 -0
  331. data/test/dummy/tmp/cache/assets/development/sprockets/f31e05a23db2e9dfc9207658cda7b799 +0 -0
  332. data/test/dummy/tmp/cache/assets/development/sprockets/f5c9348795319821f3309d4e03bb9fdb +0 -0
  333. data/test/dummy/tmp/cache/assets/development/sprockets/f631443b06d6b36e666344dbaf0b64f0 +0 -0
  334. data/test/dummy/tmp/cache/assets/development/sprockets/f7ab949c8c6b7ef3f2b743ebd98f9f59 +0 -0
  335. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  336. data/test/dummy/tmp/cache/assets/development/sprockets/fc4b3bb94f52c27dfb87395841a7cb62 +0 -0
  337. data/test/dummy/tmp/cache/assets/development/sprockets/fc79e1609ba401a4408c71182ef89b3e +0 -0
  338. data/test/dummy/tmp/cache/assets/development/sprockets/fd1e0a44b82fc47f26c7adec9d918911 +0 -0
  339. data/test/dummy/tmp/cache/assets/development/sprockets/fe9a0ccc2a407c74780c85e66882e888 +0 -0
  340. data/test/dummy/tmp/cache/assets/development/sprockets/ff3b0a569330823bd5599af14ee70cc8 +0 -0
  341. data/test/dummy/tmp/pids/server.pid +1 -0
  342. data/test/fixtures/notifications.yml +11 -0
  343. data/test/integration/navigation_test.rb +10 -0
  344. data/test/models/notification_test.rb +7 -0
  345. data/test/test_helper.rb +15 -0
  346. metadata +739 -0
Binary file
@@ -0,0 +1,10 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require carnival/external/jquery.dataTables.min
4
+ //= require carnival/external/jquery.noty
5
+ //= require carnival/external/jquery.colorbox-min
6
+ //= require carnival/external/jquery-ui-1.9.1.custom.min
7
+ //= require carnival/external/chosen.jquery
8
+ //= require carnival/external/perfect-scrollbar-0.4.6.min
9
+ //= require carnival/external/perfect-scrollbar-0.4.6.with-mousewheel.min
10
+ //= require carnival/vizir_admin
@@ -0,0 +1,40 @@
1
+ $(document).ready(function(){
2
+ $("#advanced_search_toggler, ul#advanced_search_form").mouseover(function(e){
3
+ $("#advanced_search_form").show();
4
+ });
5
+
6
+ $("#advanced_search_toggler, ul#advanced_search_form").mouseout(function(e){
7
+ $("#advanced_search_form").hide();
8
+ });
9
+
10
+ $("#search_button").click(function(e){
11
+ e.preventDefault();
12
+ var queryParams = [];
13
+ $(".advanced_search input").each(function(){
14
+ if($(this).attr("type") == "checkbox")
15
+ queryParams.push(generateQueryParam($(this).attr("name"), $(this).data("type"), $(this).data("operator"), $(this).is(":checked")));
16
+ else if ($(this).attr("type") == "text" && $(this).val() != "")
17
+ queryParams.push(generateQueryParam($(this).attr("name"), $(this).data("type"), $(this).data("operator"), $(this).val()));
18
+ });
19
+ $(".advanced_search select").each(function(){
20
+ if($(this).val() != "-1")
21
+ queryParams.push(generateQueryParam($(this).attr("name"), $(this).data("type"), $(this).data("operator"), $(this).val()));
22
+ });
23
+ $(".table").first().data("advancedquery", "{" + queryParams.join(", ") + "}");
24
+ var dataTable = $(".table").dataTable();
25
+ dataTable.fnReloadAjax(generateDataSource($(".table")));
26
+ });
27
+
28
+ $("#clear_button").click(function(e){
29
+ e.preventDefault();
30
+ $($(this).parent().parent().parent()).trigger("reset")
31
+ $(".table").first().data("advancedquery", "");
32
+ $(".dataTables_filter input[type=text]").val("");
33
+ var dataTable = $(".table").dataTable();
34
+ dataTable.fnReloadAjax(generateDataSource($(".table")));
35
+ });
36
+ });
37
+
38
+ function generateQueryParam(field, association, operator, value){
39
+ return '"' + field + '":{"operator":"' + operator + '", "value":"' + value + '", "type":"' + association + '"}'
40
+ }
@@ -0,0 +1,75 @@
1
+ function datatable_list(table, ordered_columns, sorting, filter){
2
+ if (sorting == undefined){
3
+ var sorting = 0
4
+ }
5
+ if (filter == undefined){
6
+ var filter = true
7
+ }
8
+ if (length == undefined){
9
+ var length = 50
10
+ }
11
+ var asInitVals = new Array();
12
+ var remote = false
13
+
14
+ if ($(table).data('source') != null)
15
+ remote = true;
16
+
17
+ var search = false
18
+
19
+ if ($(table).data('search') != null)
20
+ search = true;
21
+
22
+ var notSortableColumns = []
23
+ var columnIndex = 0;
24
+ $(table).find("th").each(function(index, item){
25
+ if(!$(item).data("sortable"))
26
+ notSortableColumns.push(index);
27
+ });
28
+
29
+ var oTable = $(table).dataTable({
30
+ "aoColumnDefs": [
31
+ {
32
+ bSortable: false,
33
+ aTargets: notSortableColumns
34
+ }
35
+ ] ,
36
+ "bFilter": filter,
37
+ "bProcessing": remote,
38
+ "bServerSide": remote,
39
+ 'sAjaxSource': generateDataSource(table),
40
+ "sPaginationType": "full_numbers",
41
+ "iDisplayLength": length,
42
+ "bRetrieve": true,
43
+ "fnServerParams": function(){
44
+ $(".dataTables_processing").width($(".dataTable").width());
45
+ $(".dataTables_processing").height($(".dataTable").height() + 40);
46
+ $(".dataTables_processing").html("<div class='datatables-loading'>Processando</div>")
47
+ },
48
+ 'oLanguage': dataTablesTranslation
49
+ });
50
+
51
+ if(!search)
52
+ $(".dataTables_filter").hide();
53
+ }
54
+
55
+ function generateDataSource(table){
56
+ var url = $(table).data('source');
57
+ url = addUrlParam(url, "scope", table);
58
+ url = addUrlParam(url, "special_scope", table);
59
+ url = addUrlParam(url, "from", table);
60
+ url = addUrlParam(url, "to", table);
61
+ url = addUrlParam(url, "advancedquery", table);
62
+ return url;
63
+ }
64
+
65
+ function addUrlParam(url, param, table){
66
+ if($(table).data(param) != undefined && $(table).data(param) != ""){
67
+ if(url.indexOf("?") > 0)
68
+ url = url + "&";
69
+ else
70
+ url = url + "?";
71
+ return url + param + "=" + encodeURI($(table).data(param));
72
+ }
73
+ else
74
+ return url;
75
+ }
@@ -0,0 +1,1239 @@
1
+ // Chosen, a Select Box Enhancer for jQuery and Prototype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 1.0.0
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 `grunt build`, do not edit it by hand.
10
+ (function() {
11
+ var $, AbstractChosen, Chosen, SelectParser, _ref,
12
+ __hasProp = {}.hasOwnProperty,
13
+ __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; };
14
+
15
+ SelectParser = (function() {
16
+ function SelectParser() {
17
+ this.options_index = 0;
18
+ this.parsed = [];
19
+ }
20
+
21
+ SelectParser.prototype.add_node = function(child) {
22
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
23
+ return this.add_group(child);
24
+ } else {
25
+ return this.add_option(child);
26
+ }
27
+ };
28
+
29
+ SelectParser.prototype.add_group = function(group) {
30
+ var group_position, option, _i, _len, _ref, _results;
31
+ group_position = this.parsed.length;
32
+ this.parsed.push({
33
+ array_index: group_position,
34
+ group: true,
35
+ label: this.escapeExpression(group.label),
36
+ children: 0,
37
+ disabled: group.disabled
38
+ });
39
+ _ref = group.childNodes;
40
+ _results = [];
41
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
42
+ option = _ref[_i];
43
+ _results.push(this.add_option(option, group_position, group.disabled));
44
+ }
45
+ return _results;
46
+ };
47
+
48
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
49
+ if (option.nodeName.toUpperCase() === "OPTION") {
50
+ if (option.text !== "") {
51
+ if (group_position != null) {
52
+ this.parsed[group_position].children += 1;
53
+ }
54
+ this.parsed.push({
55
+ array_index: this.parsed.length,
56
+ options_index: this.options_index,
57
+ value: option.value,
58
+ text: option.text,
59
+ html: option.innerHTML,
60
+ selected: option.selected,
61
+ disabled: group_disabled === true ? group_disabled : option.disabled,
62
+ group_array_index: group_position,
63
+ classes: option.className,
64
+ style: option.style.cssText
65
+ });
66
+ } else {
67
+ this.parsed.push({
68
+ array_index: this.parsed.length,
69
+ options_index: this.options_index,
70
+ empty: true
71
+ });
72
+ }
73
+ return this.options_index += 1;
74
+ }
75
+ };
76
+
77
+ SelectParser.prototype.escapeExpression = function(text) {
78
+ var map, unsafe_chars;
79
+ if ((text == null) || text === false) {
80
+ return "";
81
+ }
82
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
83
+ return text;
84
+ }
85
+ map = {
86
+ "<": "&lt;",
87
+ ">": "&gt;",
88
+ '"': "&quot;",
89
+ "'": "&#x27;",
90
+ "`": "&#x60;"
91
+ };
92
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
93
+ return text.replace(unsafe_chars, function(chr) {
94
+ return map[chr] || "&amp;";
95
+ });
96
+ };
97
+
98
+ return SelectParser;
99
+
100
+ })();
101
+
102
+ SelectParser.select_to_array = function(select) {
103
+ var child, parser, _i, _len, _ref;
104
+ parser = new SelectParser();
105
+ _ref = select.childNodes;
106
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
107
+ child = _ref[_i];
108
+ parser.add_node(child);
109
+ }
110
+ return parser.parsed;
111
+ };
112
+
113
+ AbstractChosen = (function() {
114
+ function AbstractChosen(form_field, options) {
115
+ this.form_field = form_field;
116
+ this.options = options != null ? options : {};
117
+ if (!AbstractChosen.browser_is_supported()) {
118
+ return;
119
+ }
120
+ this.is_multiple = this.form_field.multiple;
121
+ this.set_default_text();
122
+ this.set_default_values();
123
+ this.setup();
124
+ this.set_up_html();
125
+ this.register_observers();
126
+ }
127
+
128
+ AbstractChosen.prototype.set_default_values = function() {
129
+ var _this = this;
130
+ this.click_test_action = function(evt) {
131
+ return _this.test_active_click(evt);
132
+ };
133
+ this.activate_action = function(evt) {
134
+ return _this.activate_field(evt);
135
+ };
136
+ this.active_field = false;
137
+ this.mouse_on_container = false;
138
+ this.results_showing = false;
139
+ this.result_highlighted = null;
140
+ 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;
141
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
142
+ this.disable_search = this.options.disable_search || false;
143
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
144
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
145
+ this.search_contains = this.options.search_contains || false;
146
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
147
+ this.max_selected_options = this.options.max_selected_options || Infinity;
148
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
149
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
150
+ this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
151
+ this.create_option = this.options.create_option || false;
152
+ this.persistent_create_option = this.options.persistent_create_option || false;
153
+ return this.skip_no_results = this.options.skip_no_results || false;
154
+ };
155
+
156
+ AbstractChosen.prototype.set_default_text = function() {
157
+ if (this.form_field.getAttribute("data-placeholder")) {
158
+ this.default_text = this.form_field.getAttribute("data-placeholder");
159
+ } else if (this.is_multiple) {
160
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
161
+ } else {
162
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
163
+ }
164
+ this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
165
+ return this.create_option_text = this.form_field.getAttribute("data-create_option_text") || this.options.create_option_text || AbstractChosen.default_create_option_text;
166
+ };
167
+
168
+ AbstractChosen.prototype.mouse_enter = function() {
169
+ return this.mouse_on_container = true;
170
+ };
171
+
172
+ AbstractChosen.prototype.mouse_leave = function() {
173
+ return this.mouse_on_container = false;
174
+ };
175
+
176
+ AbstractChosen.prototype.input_focus = function(evt) {
177
+ var _this = this;
178
+ if (this.is_multiple) {
179
+ if (!this.active_field) {
180
+ return setTimeout((function() {
181
+ return _this.container_mousedown();
182
+ }), 50);
183
+ }
184
+ } else {
185
+ if (!this.active_field) {
186
+ return this.activate_field();
187
+ }
188
+ }
189
+ };
190
+
191
+ AbstractChosen.prototype.input_blur = function(evt) {
192
+ var _this = this;
193
+ if (!this.mouse_on_container) {
194
+ this.active_field = false;
195
+ return setTimeout((function() {
196
+ return _this.blur_test();
197
+ }), 100);
198
+ }
199
+ };
200
+
201
+ AbstractChosen.prototype.results_option_build = function(options) {
202
+ var content, data, _i, _len, _ref;
203
+ content = '';
204
+ _ref = this.results_data;
205
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
206
+ data = _ref[_i];
207
+ if (data.group) {
208
+ content += this.result_add_group(data);
209
+ } else {
210
+ content += this.result_add_option(data);
211
+ }
212
+ if (options != null ? options.first : void 0) {
213
+ if (data.selected && this.is_multiple) {
214
+ this.choice_build(data);
215
+ } else if (data.selected && !this.is_multiple) {
216
+ this.single_set_selected_text(data.text);
217
+ }
218
+ }
219
+ }
220
+ return content;
221
+ };
222
+
223
+ AbstractChosen.prototype.result_add_option = function(option) {
224
+ var classes, option_el;
225
+ if (!option.search_match) {
226
+ return '';
227
+ }
228
+ if (!this.include_option_in_results(option)) {
229
+ return '';
230
+ }
231
+ classes = [];
232
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
233
+ classes.push("active-result");
234
+ }
235
+ if (option.disabled && !(option.selected && this.is_multiple)) {
236
+ classes.push("disabled-result");
237
+ }
238
+ if (option.selected) {
239
+ classes.push("result-selected");
240
+ }
241
+ if (option.group_array_index != null) {
242
+ classes.push("group-option");
243
+ }
244
+ if (option.classes !== "") {
245
+ classes.push(option.classes);
246
+ }
247
+ option_el = document.createElement("li");
248
+ option_el.className = classes.join(" ");
249
+ option_el.style.cssText = option.style;
250
+ option_el.setAttribute("data-option-array-index", option.array_index);
251
+ option_el.innerHTML = option.search_text;
252
+ return this.outerHTML(option_el);
253
+ };
254
+
255
+ AbstractChosen.prototype.result_add_group = function(group) {
256
+ var group_el;
257
+ if (!(group.search_match || group.group_match)) {
258
+ return '';
259
+ }
260
+ if (!(group.active_options > 0)) {
261
+ return '';
262
+ }
263
+ group_el = document.createElement("li");
264
+ group_el.className = "group-result";
265
+ group_el.innerHTML = group.search_text;
266
+ return this.outerHTML(group_el);
267
+ };
268
+
269
+ AbstractChosen.prototype.append_option = function(option) {
270
+ return this.select_append_option(option);
271
+ };
272
+
273
+ AbstractChosen.prototype.results_update_field = function() {
274
+ this.set_default_text();
275
+ if (!this.is_multiple) {
276
+ this.results_reset_cleanup();
277
+ }
278
+ this.result_clear_highlight();
279
+ this.results_build();
280
+ if (this.results_showing) {
281
+ return this.winnow_results();
282
+ }
283
+ };
284
+
285
+ AbstractChosen.prototype.reset_single_select_options = function() {
286
+ var result, _i, _len, _ref, _results;
287
+ _ref = this.results_data;
288
+ _results = [];
289
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
290
+ result = _ref[_i];
291
+ if (result.selected) {
292
+ _results.push(result.selected = false);
293
+ } else {
294
+ _results.push(void 0);
295
+ }
296
+ }
297
+ return _results;
298
+ };
299
+
300
+ AbstractChosen.prototype.results_toggle = function() {
301
+ if (this.results_showing) {
302
+ return this.results_hide();
303
+ } else {
304
+ return this.results_show();
305
+ }
306
+ };
307
+
308
+ AbstractChosen.prototype.results_search = function(evt) {
309
+ if (this.results_showing) {
310
+ return this.winnow_results();
311
+ } else {
312
+ return this.results_show();
313
+ }
314
+ };
315
+
316
+ AbstractChosen.prototype.winnow_results = function() {
317
+ var eregex, escapedSearchText, exact_result, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
318
+ this.no_results_clear();
319
+ results = 0;
320
+ exact_result = false;
321
+ searchText = this.get_search_text();
322
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
323
+ regexAnchor = this.search_contains ? "" : "^";
324
+ regex = new RegExp(regexAnchor + escapedSearchText, 'i');
325
+ zregex = new RegExp(escapedSearchText, 'i');
326
+ eregex = new RegExp('^' + escapedSearchText + '$', 'i');
327
+ _ref = this.results_data;
328
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
329
+ option = _ref[_i];
330
+ option.search_match = false;
331
+ results_group = null;
332
+ if (this.include_option_in_results(option)) {
333
+ if (option.group) {
334
+ option.group_match = false;
335
+ option.active_options = 0;
336
+ }
337
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
338
+ results_group = this.results_data[option.group_array_index];
339
+ if (results_group.active_options === 0 && results_group.search_match) {
340
+ results += 1;
341
+ }
342
+ results_group.active_options += 1;
343
+ }
344
+ if (!(option.group && !this.group_search)) {
345
+ option.search_text = option.group ? option.label : option.html;
346
+ option.search_match = this.search_string_match(option.search_text, regex);
347
+ if (option.search_match && !option.group) {
348
+ results += 1;
349
+ }
350
+ exact_result = eregex.test(option.html);
351
+ if (option.search_match) {
352
+ if (searchText.length) {
353
+ startpos = option.search_text.search(zregex);
354
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
355
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
356
+ }
357
+ if (results_group != null) {
358
+ results_group.group_match = true;
359
+ }
360
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
361
+ option.search_match = true;
362
+ }
363
+ }
364
+ }
365
+ }
366
+ this.result_clear_highlight();
367
+ if (results < 1 && searchText.length) {
368
+ this.update_results_content("");
369
+ if (!(this.create_option && this.skip_no_results)) {
370
+ this.no_results(searchText);
371
+ }
372
+ } else {
373
+ this.update_results_content(this.results_option_build());
374
+ this.winnow_results_set_highlight();
375
+ }
376
+ if (this.create_option && (results < 1 || (!exact_result && this.persistent_create_option)) && searchText.length) {
377
+ return this.show_create_option(searchText);
378
+ }
379
+ };
380
+
381
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
382
+ var part, parts, _i, _len;
383
+ if (regex.test(search_string)) {
384
+ return true;
385
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
386
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
387
+ if (parts.length) {
388
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
389
+ part = parts[_i];
390
+ if (regex.test(part)) {
391
+ return true;
392
+ }
393
+ }
394
+ }
395
+ }
396
+ };
397
+
398
+ AbstractChosen.prototype.choices_count = function() {
399
+ var option, _i, _len, _ref;
400
+ if (this.selected_option_count != null) {
401
+ return this.selected_option_count;
402
+ }
403
+ this.selected_option_count = 0;
404
+ _ref = this.form_field.options;
405
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
406
+ option = _ref[_i];
407
+ if (option.selected) {
408
+ this.selected_option_count += 1;
409
+ }
410
+ }
411
+ return this.selected_option_count;
412
+ };
413
+
414
+ AbstractChosen.prototype.choices_click = function(evt) {
415
+ evt.preventDefault();
416
+ if (!(this.results_showing || this.is_disabled)) {
417
+ return this.results_show();
418
+ }
419
+ };
420
+
421
+ AbstractChosen.prototype.keyup_checker = function(evt) {
422
+ var stroke, _ref;
423
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
424
+ this.search_field_scale();
425
+ switch (stroke) {
426
+ case 8:
427
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
428
+ return this.keydown_backstroke();
429
+ } else if (!this.pending_backstroke) {
430
+ this.result_clear_highlight();
431
+ return this.results_search();
432
+ }
433
+ break;
434
+ case 13:
435
+ evt.preventDefault();
436
+ if (this.results_showing) {
437
+ return this.result_select(evt);
438
+ }
439
+ break;
440
+ case 27:
441
+ if (this.results_showing) {
442
+ this.results_hide();
443
+ }
444
+ return true;
445
+ case 9:
446
+ case 38:
447
+ case 40:
448
+ case 16:
449
+ case 91:
450
+ case 17:
451
+ break;
452
+ default:
453
+ return this.results_search();
454
+ }
455
+ };
456
+
457
+ AbstractChosen.prototype.container_width = function() {
458
+ if (this.options.width != null) {
459
+ return this.options.width;
460
+ } else {
461
+ return "" + this.form_field.offsetWidth + "px";
462
+ }
463
+ };
464
+
465
+ AbstractChosen.prototype.include_option_in_results = function(option) {
466
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
467
+ return false;
468
+ }
469
+ if (!this.display_disabled_options && option.disabled) {
470
+ return false;
471
+ }
472
+ if (option.empty) {
473
+ return false;
474
+ }
475
+ return true;
476
+ };
477
+
478
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
479
+ this.touch_started = true;
480
+ return this.search_results_mouseover(evt);
481
+ };
482
+
483
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
484
+ this.touch_started = false;
485
+ return this.search_results_mouseout(evt);
486
+ };
487
+
488
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
489
+ if (this.touch_started) {
490
+ return this.search_results_mouseup(evt);
491
+ }
492
+ };
493
+
494
+ AbstractChosen.prototype.outerHTML = function(element) {
495
+ var tmp;
496
+ if (element.outerHTML) {
497
+ return element.outerHTML;
498
+ }
499
+ tmp = document.createElement("div");
500
+ tmp.appendChild(element);
501
+ return tmp.innerHTML;
502
+ };
503
+
504
+ AbstractChosen.browser_is_supported = function() {
505
+ if (window.navigator.appName === "Microsoft Internet Explorer") {
506
+ return document.documentMode >= 8;
507
+ }
508
+ if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
509
+ return false;
510
+ }
511
+ if (/Android/i.test(window.navigator.userAgent)) {
512
+ if (/Mobile/i.test(window.navigator.userAgent)) {
513
+ return false;
514
+ }
515
+ }
516
+ return true;
517
+ };
518
+
519
+ AbstractChosen.default_multiple_text = "Select Some Options";
520
+
521
+ AbstractChosen.default_single_text = "Select an Option";
522
+
523
+ AbstractChosen.default_no_result_text = "No results match";
524
+
525
+ AbstractChosen.default_create_option_text = "Add Option";
526
+
527
+ return AbstractChosen;
528
+
529
+ })();
530
+
531
+ $ = jQuery;
532
+
533
+ $.fn.extend({
534
+ chosen: function(options) {
535
+ if (!AbstractChosen.browser_is_supported()) {
536
+ return this;
537
+ }
538
+ return this.each(function(input_field) {
539
+ var $this, chosen;
540
+ $this = $(this);
541
+ chosen = $this.data('chosen');
542
+ if (options === 'destroy' && chosen) {
543
+ chosen.destroy();
544
+ } else if (!chosen) {
545
+ $this.data('chosen', new Chosen(this, options));
546
+ }
547
+ });
548
+ }
549
+ });
550
+
551
+ Chosen = (function(_super) {
552
+ __extends(Chosen, _super);
553
+
554
+ function Chosen() {
555
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
556
+ return _ref;
557
+ }
558
+
559
+ Chosen.prototype.setup = function() {
560
+ this.form_field_jq = $(this.form_field);
561
+ this.current_selectedIndex = this.form_field.selectedIndex;
562
+ return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
563
+ };
564
+
565
+ Chosen.prototype.set_up_html = function() {
566
+ var container_classes, container_props;
567
+ container_classes = ["chosen-container"];
568
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
569
+ if (this.inherit_select_classes && this.form_field.className) {
570
+ container_classes.push(this.form_field.className);
571
+ }
572
+ if (this.is_rtl) {
573
+ container_classes.push("chosen-rtl");
574
+ }
575
+ container_props = {
576
+ 'class': container_classes.join(' '),
577
+ 'style': "width: " + (this.container_width()) + ";",
578
+ 'title': this.form_field.title
579
+ };
580
+ if (this.form_field.id.length) {
581
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
582
+ }
583
+ this.container = $("<div />", container_props);
584
+ if (this.is_multiple) {
585
+ this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
586
+ } else {
587
+ this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
588
+ }
589
+ this.form_field_jq.hide().after(this.container);
590
+ this.dropdown = this.container.find('div.chosen-drop').first();
591
+ this.search_field = this.container.find('input').first();
592
+ this.search_results = this.container.find('ul.chosen-results').first();
593
+ this.search_field_scale();
594
+ this.search_no_results = this.container.find('li.no-results').first();
595
+ if (this.is_multiple) {
596
+ this.search_choices = this.container.find('ul.chosen-choices').first();
597
+ this.search_container = this.container.find('li.search-field').first();
598
+ } else {
599
+ this.search_container = this.container.find('div.chosen-search').first();
600
+ this.selected_item = this.container.find('.chosen-single').first();
601
+ }
602
+ this.results_build();
603
+ this.set_tab_index();
604
+ this.set_label_behavior();
605
+ return this.form_field_jq.trigger("chosen:ready", {
606
+ chosen: this
607
+ });
608
+ };
609
+
610
+ Chosen.prototype.register_observers = function() {
611
+ var _this = this;
612
+ this.container.bind('mousedown.chosen', function(evt) {
613
+ _this.container_mousedown(evt);
614
+ });
615
+ this.container.bind('mouseup.chosen', function(evt) {
616
+ _this.container_mouseup(evt);
617
+ });
618
+ this.container.bind('mouseenter.chosen', function(evt) {
619
+ _this.mouse_enter(evt);
620
+ });
621
+ this.container.bind('mouseleave.chosen', function(evt) {
622
+ _this.mouse_leave(evt);
623
+ });
624
+ this.search_results.bind('mouseup.chosen', function(evt) {
625
+ _this.search_results_mouseup(evt);
626
+ });
627
+ this.search_results.bind('mouseover.chosen', function(evt) {
628
+ _this.search_results_mouseover(evt);
629
+ });
630
+ this.search_results.bind('mouseout.chosen', function(evt) {
631
+ _this.search_results_mouseout(evt);
632
+ });
633
+ this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
634
+ _this.search_results_mousewheel(evt);
635
+ });
636
+ this.search_results.bind('touchstart.chosen', function(evt) {
637
+ _this.search_results_touchstart(evt);
638
+ });
639
+ this.search_results.bind('touchmove.chosen', function(evt) {
640
+ _this.search_results_touchmove(evt);
641
+ });
642
+ this.search_results.bind('touchend.chosen', function(evt) {
643
+ _this.search_results_touchend(evt);
644
+ });
645
+ this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
646
+ _this.results_update_field(evt);
647
+ });
648
+ this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
649
+ _this.activate_field(evt);
650
+ });
651
+ this.form_field_jq.bind("chosen:open.chosen", function(evt) {
652
+ _this.container_mousedown(evt);
653
+ });
654
+ this.search_field.bind('blur.chosen', function(evt) {
655
+ _this.input_blur(evt);
656
+ });
657
+ this.search_field.bind('keyup.chosen', function(evt) {
658
+ _this.keyup_checker(evt);
659
+ });
660
+ this.search_field.bind('keydown.chosen', function(evt) {
661
+ _this.keydown_checker(evt);
662
+ });
663
+ this.search_field.bind('focus.chosen', function(evt) {
664
+ _this.input_focus(evt);
665
+ });
666
+ if (this.is_multiple) {
667
+ return this.search_choices.bind('click.chosen', function(evt) {
668
+ _this.choices_click(evt);
669
+ });
670
+ } else {
671
+ return this.container.bind('click.chosen', function(evt) {
672
+ evt.preventDefault();
673
+ });
674
+ }
675
+ };
676
+
677
+ Chosen.prototype.destroy = function() {
678
+ $(document).unbind("click.chosen", this.click_test_action);
679
+ if (this.search_field[0].tabIndex) {
680
+ this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
681
+ }
682
+ this.container.remove();
683
+ this.form_field_jq.removeData('chosen');
684
+ return this.form_field_jq.show();
685
+ };
686
+
687
+ Chosen.prototype.search_field_disabled = function() {
688
+ this.is_disabled = this.form_field_jq[0].disabled;
689
+ if (this.is_disabled) {
690
+ this.container.addClass('chosen-disabled');
691
+ this.search_field[0].disabled = true;
692
+ if (!this.is_multiple) {
693
+ this.selected_item.unbind("focus.chosen", this.activate_action);
694
+ }
695
+ return this.close_field();
696
+ } else {
697
+ this.container.removeClass('chosen-disabled');
698
+ this.search_field[0].disabled = false;
699
+ if (!this.is_multiple) {
700
+ return this.selected_item.bind("focus.chosen", this.activate_action);
701
+ }
702
+ }
703
+ };
704
+
705
+ Chosen.prototype.container_mousedown = function(evt) {
706
+ if (!this.is_disabled) {
707
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
708
+ evt.preventDefault();
709
+ }
710
+ if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
711
+ if (!this.active_field) {
712
+ if (this.is_multiple) {
713
+ this.search_field.val("");
714
+ }
715
+ $(document).bind('click.chosen', this.click_test_action);
716
+ this.results_show();
717
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
718
+ evt.preventDefault();
719
+ this.results_toggle();
720
+ }
721
+ return this.activate_field();
722
+ }
723
+ }
724
+ };
725
+
726
+ Chosen.prototype.container_mouseup = function(evt) {
727
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
728
+ return this.results_reset(evt);
729
+ }
730
+ };
731
+
732
+ Chosen.prototype.search_results_mousewheel = function(evt) {
733
+ var delta, _ref1, _ref2;
734
+ delta = -((_ref1 = evt.originalEvent) != null ? _ref1.wheelDelta : void 0) || ((_ref2 = evt.originialEvent) != null ? _ref2.detail : void 0);
735
+ if (delta != null) {
736
+ evt.preventDefault();
737
+ if (evt.type === 'DOMMouseScroll') {
738
+ delta = delta * 40;
739
+ }
740
+ return this.search_results.scrollTop(delta + this.search_results.scrollTop());
741
+ }
742
+ };
743
+
744
+ Chosen.prototype.blur_test = function(evt) {
745
+ if (!this.active_field && this.container.hasClass("chosen-container-active")) {
746
+ return this.close_field();
747
+ }
748
+ };
749
+
750
+ Chosen.prototype.close_field = function() {
751
+ $(document).unbind("click.chosen", this.click_test_action);
752
+ this.active_field = false;
753
+ this.results_hide();
754
+ this.container.removeClass("chosen-container-active");
755
+ this.clear_backstroke();
756
+ this.show_search_field_default();
757
+ return this.search_field_scale();
758
+ };
759
+
760
+ Chosen.prototype.activate_field = function() {
761
+ this.container.addClass("chosen-container-active");
762
+ this.active_field = true;
763
+ this.search_field.val(this.search_field.val());
764
+ return this.search_field.focus();
765
+ };
766
+
767
+ Chosen.prototype.test_active_click = function(evt) {
768
+ if (this.container.is($(evt.target).closest('.chosen-container'))) {
769
+ return this.active_field = true;
770
+ } else {
771
+ return this.close_field();
772
+ }
773
+ };
774
+
775
+ Chosen.prototype.results_build = function() {
776
+ this.parsing = true;
777
+ this.selected_option_count = null;
778
+ this.results_data = SelectParser.select_to_array(this.form_field);
779
+ if (this.is_multiple) {
780
+ this.search_choices.find("li.search-choice").remove();
781
+ } else if (!this.is_multiple) {
782
+ this.single_set_selected_text();
783
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold && !this.create_option) {
784
+ this.search_field[0].readOnly = true;
785
+ this.container.addClass("chosen-container-single-nosearch");
786
+ } else {
787
+ this.search_field[0].readOnly = false;
788
+ this.container.removeClass("chosen-container-single-nosearch");
789
+ }
790
+ }
791
+ this.update_results_content(this.results_option_build({
792
+ first: true
793
+ }));
794
+ this.search_field_disabled();
795
+ this.show_search_field_default();
796
+ this.search_field_scale();
797
+ return this.parsing = false;
798
+ };
799
+
800
+ Chosen.prototype.result_do_highlight = function(el) {
801
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
802
+ if (el.length) {
803
+ this.result_clear_highlight();
804
+ this.result_highlight = el;
805
+ this.result_highlight.addClass("highlighted");
806
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
807
+ visible_top = this.search_results.scrollTop();
808
+ visible_bottom = maxHeight + visible_top;
809
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
810
+ high_bottom = high_top + this.result_highlight.outerHeight();
811
+ if (high_bottom >= visible_bottom) {
812
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
813
+ } else if (high_top < visible_top) {
814
+ return this.search_results.scrollTop(high_top);
815
+ }
816
+ }
817
+ };
818
+
819
+ Chosen.prototype.result_clear_highlight = function() {
820
+ if (this.result_highlight) {
821
+ this.result_highlight.removeClass("highlighted");
822
+ }
823
+ return this.result_highlight = null;
824
+ };
825
+
826
+ Chosen.prototype.results_show = function() {
827
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
828
+ this.form_field_jq.trigger("chosen:maxselected", {
829
+ chosen: this
830
+ });
831
+ return false;
832
+ }
833
+ this.container.addClass("chosen-with-drop");
834
+ this.form_field_jq.trigger("chosen:showing_dropdown", {
835
+ chosen: this
836
+ });
837
+ this.results_showing = true;
838
+ this.search_field.focus();
839
+ this.search_field.val(this.search_field.val());
840
+ return this.winnow_results();
841
+ };
842
+
843
+ Chosen.prototype.update_results_content = function(content) {
844
+ return this.search_results.html(content);
845
+ };
846
+
847
+ Chosen.prototype.results_hide = function() {
848
+ if (this.results_showing) {
849
+ this.result_clear_highlight();
850
+ this.container.removeClass("chosen-with-drop");
851
+ this.form_field_jq.trigger("chosen:hiding_dropdown", {
852
+ chosen: this
853
+ });
854
+ }
855
+ return this.results_showing = false;
856
+ };
857
+
858
+ Chosen.prototype.set_tab_index = function(el) {
859
+ var ti;
860
+ if (this.form_field.tabIndex) {
861
+ ti = this.form_field.tabIndex;
862
+ this.form_field.tabIndex = -1;
863
+ return this.search_field[0].tabIndex = ti;
864
+ }
865
+ };
866
+
867
+ Chosen.prototype.set_label_behavior = function() {
868
+ var _this = this;
869
+ this.form_field_label = this.form_field_jq.parents("label");
870
+ if (!this.form_field_label.length && this.form_field.id.length) {
871
+ this.form_field_label = $("label[for='" + this.form_field.id + "']");
872
+ }
873
+ if (this.form_field_label.length > 0) {
874
+ return this.form_field_label.bind('click.chosen', function(evt) {
875
+ if (_this.is_multiple) {
876
+ return _this.container_mousedown(evt);
877
+ } else {
878
+ return _this.activate_field();
879
+ }
880
+ });
881
+ }
882
+ };
883
+
884
+ Chosen.prototype.show_search_field_default = function() {
885
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
886
+ this.search_field.val(this.default_text);
887
+ return this.search_field.addClass("default");
888
+ } else {
889
+ this.search_field.val("");
890
+ return this.search_field.removeClass("default");
891
+ }
892
+ };
893
+
894
+ Chosen.prototype.search_results_mouseup = function(evt) {
895
+ var target;
896
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
897
+ if (target.length) {
898
+ this.result_highlight = target;
899
+ this.result_select(evt);
900
+ return this.search_field.focus();
901
+ }
902
+ };
903
+
904
+ Chosen.prototype.search_results_mouseover = function(evt) {
905
+ var target;
906
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
907
+ if (target) {
908
+ return this.result_do_highlight(target);
909
+ }
910
+ };
911
+
912
+ Chosen.prototype.search_results_mouseout = function(evt) {
913
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
914
+ return this.result_clear_highlight();
915
+ }
916
+ };
917
+
918
+ Chosen.prototype.choice_build = function(item) {
919
+ var choice, close_link,
920
+ _this = this;
921
+ choice = $('<li />', {
922
+ "class": "search-choice"
923
+ }).html("<span>" + item.html + "</span>");
924
+ if (item.disabled) {
925
+ choice.addClass('search-choice-disabled');
926
+ } else {
927
+ close_link = $('<a />', {
928
+ "class": 'search-choice-close',
929
+ 'data-option-array-index': item.array_index
930
+ });
931
+ close_link.bind('click.chosen', function(evt) {
932
+ return _this.choice_destroy_link_click(evt);
933
+ });
934
+ choice.append(close_link);
935
+ }
936
+ return this.search_container.before(choice);
937
+ };
938
+
939
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
940
+ evt.preventDefault();
941
+ evt.stopPropagation();
942
+ if (!this.is_disabled) {
943
+ return this.choice_destroy($(evt.target));
944
+ }
945
+ };
946
+
947
+ Chosen.prototype.choice_destroy = function(link) {
948
+ if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
949
+ this.show_search_field_default();
950
+ if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
951
+ this.results_hide();
952
+ }
953
+ link.parents('li').first().remove();
954
+ return this.search_field_scale();
955
+ }
956
+ };
957
+
958
+ Chosen.prototype.results_reset = function() {
959
+ this.reset_single_select_options();
960
+ this.form_field.options[0].selected = true;
961
+ this.single_set_selected_text();
962
+ this.show_search_field_default();
963
+ this.results_reset_cleanup();
964
+ this.form_field_jq.trigger("change");
965
+ if (this.active_field) {
966
+ return this.results_hide();
967
+ }
968
+ };
969
+
970
+ Chosen.prototype.results_reset_cleanup = function() {
971
+ this.current_selectedIndex = this.form_field.selectedIndex;
972
+ return this.selected_item.find("abbr").remove();
973
+ };
974
+
975
+ Chosen.prototype.result_select = function(evt) {
976
+ var high, item;
977
+ if (this.result_highlight) {
978
+ high = this.result_highlight;
979
+ if (high.hasClass("create-option")) {
980
+ this.select_create_option(this.search_field.val());
981
+ return this.results_hide();
982
+ }
983
+ this.result_clear_highlight();
984
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
985
+ this.form_field_jq.trigger("chosen:maxselected", {
986
+ chosen: this
987
+ });
988
+ return false;
989
+ }
990
+ if (this.is_multiple) {
991
+ high.removeClass("active-result");
992
+ } else {
993
+ this.reset_single_select_options();
994
+ }
995
+ item = this.results_data[high[0].getAttribute("data-option-array-index")];
996
+ item.selected = true;
997
+ this.form_field.options[item.options_index].selected = true;
998
+ this.selected_option_count = null;
999
+ if (this.is_multiple) {
1000
+ this.choice_build(item);
1001
+ } else {
1002
+ this.single_set_selected_text(item.text);
1003
+ }
1004
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1005
+ this.results_hide();
1006
+ }
1007
+ this.search_field.val("");
1008
+ if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1009
+ this.form_field_jq.trigger("change", {
1010
+ 'selected': this.form_field.options[item.options_index].value
1011
+ });
1012
+ }
1013
+ this.current_selectedIndex = this.form_field.selectedIndex;
1014
+ return this.search_field_scale();
1015
+ }
1016
+ };
1017
+
1018
+ Chosen.prototype.single_set_selected_text = function(text) {
1019
+ if (text == null) {
1020
+ text = this.default_text;
1021
+ }
1022
+ if (text === this.default_text) {
1023
+ this.selected_item.addClass("chosen-default");
1024
+ } else {
1025
+ this.single_deselect_control_build();
1026
+ this.selected_item.removeClass("chosen-default");
1027
+ }
1028
+ return this.selected_item.find("span").text(text);
1029
+ };
1030
+
1031
+ Chosen.prototype.result_deselect = function(pos) {
1032
+ var result_data;
1033
+ result_data = this.results_data[pos];
1034
+ if (!this.form_field.options[result_data.options_index].disabled) {
1035
+ result_data.selected = false;
1036
+ this.form_field.options[result_data.options_index].selected = false;
1037
+ this.selected_option_count = null;
1038
+ this.result_clear_highlight();
1039
+ if (this.results_showing) {
1040
+ this.winnow_results();
1041
+ }
1042
+ this.form_field_jq.trigger("change", {
1043
+ deselected: this.form_field.options[result_data.options_index].value
1044
+ });
1045
+ this.search_field_scale();
1046
+ return true;
1047
+ } else {
1048
+ return false;
1049
+ }
1050
+ };
1051
+
1052
+ Chosen.prototype.single_deselect_control_build = function() {
1053
+ if (!this.allow_single_deselect) {
1054
+ return;
1055
+ }
1056
+ if (!this.selected_item.find("abbr").length) {
1057
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1058
+ }
1059
+ return this.selected_item.addClass("chosen-single-with-deselect");
1060
+ };
1061
+
1062
+ Chosen.prototype.get_search_text = function() {
1063
+ if (this.search_field.val() === this.default_text) {
1064
+ return "";
1065
+ } else {
1066
+ return $('<div/>').text($.trim(this.search_field.val())).html();
1067
+ }
1068
+ };
1069
+
1070
+ Chosen.prototype.winnow_results_set_highlight = function() {
1071
+ var do_high, selected_results;
1072
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1073
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1074
+ if (do_high != null) {
1075
+ return this.result_do_highlight(do_high);
1076
+ }
1077
+ };
1078
+
1079
+ Chosen.prototype.no_results = function(terms) {
1080
+ var no_results_html;
1081
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1082
+ no_results_html.find("span").first().html(terms);
1083
+ return this.search_results.append(no_results_html);
1084
+ };
1085
+
1086
+ Chosen.prototype.show_create_option = function(terms) {
1087
+ var create_option_html;
1088
+ create_option_html = $('<li class="create-option active-result"><a href="javascript:void(0);">' + this.create_option_text + '</a>: "' + terms + '"</li>');
1089
+ return this.search_results.append(create_option_html);
1090
+ };
1091
+
1092
+ Chosen.prototype.create_option_clear = function() {
1093
+ return this.search_results.find(".create-option").remove();
1094
+ };
1095
+
1096
+ Chosen.prototype.select_create_option = function(terms) {
1097
+ if ($.isFunction(this.create_option)) {
1098
+ return this.create_option.call(this, terms);
1099
+ } else {
1100
+ return this.select_append_option({
1101
+ value: terms,
1102
+ text: terms
1103
+ });
1104
+ }
1105
+ };
1106
+
1107
+ Chosen.prototype.select_append_option = function(options) {
1108
+ var option;
1109
+ option = $('<option />', options).attr('selected', 'selected');
1110
+ this.form_field_jq.append(option);
1111
+ this.form_field_jq.trigger("chosen:updated");
1112
+ this.form_field_jq.trigger("change");
1113
+ return this.search_field.trigger("focus");
1114
+ };
1115
+
1116
+ Chosen.prototype.no_results_clear = function() {
1117
+ return this.search_results.find(".no-results").remove();
1118
+ };
1119
+
1120
+ Chosen.prototype.keydown_arrow = function() {
1121
+ var next_sib;
1122
+ if (this.results_showing && this.result_highlight) {
1123
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1124
+ if (next_sib) {
1125
+ return this.result_do_highlight(next_sib);
1126
+ }
1127
+ } else if (this.results_showing && this.create_option) {
1128
+ return this.result_do_highlight(this.search_results.find('.create-option'));
1129
+ } else {
1130
+ return this.results_show();
1131
+ }
1132
+ };
1133
+
1134
+ Chosen.prototype.keyup_arrow = function() {
1135
+ var prev_sibs;
1136
+ if (!this.results_showing && !this.is_multiple) {
1137
+ return this.results_show();
1138
+ } else if (this.result_highlight) {
1139
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1140
+ if (prev_sibs.length) {
1141
+ return this.result_do_highlight(prev_sibs.first());
1142
+ } else {
1143
+ if (this.choices_count() > 0) {
1144
+ this.results_hide();
1145
+ }
1146
+ return this.result_clear_highlight();
1147
+ }
1148
+ }
1149
+ };
1150
+
1151
+ Chosen.prototype.keydown_backstroke = function() {
1152
+ var next_available_destroy;
1153
+ if (this.pending_backstroke) {
1154
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1155
+ return this.clear_backstroke();
1156
+ } else {
1157
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1158
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1159
+ this.pending_backstroke = next_available_destroy;
1160
+ if (this.single_backstroke_delete) {
1161
+ return this.keydown_backstroke();
1162
+ } else {
1163
+ return this.pending_backstroke.addClass("search-choice-focus");
1164
+ }
1165
+ }
1166
+ }
1167
+ };
1168
+
1169
+ Chosen.prototype.clear_backstroke = function() {
1170
+ if (this.pending_backstroke) {
1171
+ this.pending_backstroke.removeClass("search-choice-focus");
1172
+ }
1173
+ return this.pending_backstroke = null;
1174
+ };
1175
+
1176
+ Chosen.prototype.keydown_checker = function(evt) {
1177
+ var stroke, _ref1;
1178
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1179
+ this.search_field_scale();
1180
+ if (stroke !== 8 && this.pending_backstroke) {
1181
+ this.clear_backstroke();
1182
+ }
1183
+ switch (stroke) {
1184
+ case 8:
1185
+ this.backstroke_length = this.search_field.val().length;
1186
+ break;
1187
+ case 9:
1188
+ if (this.results_showing && !this.is_multiple) {
1189
+ this.result_select(evt);
1190
+ }
1191
+ this.mouse_on_container = false;
1192
+ break;
1193
+ case 13:
1194
+ evt.preventDefault();
1195
+ break;
1196
+ case 38:
1197
+ evt.preventDefault();
1198
+ this.keyup_arrow();
1199
+ break;
1200
+ case 40:
1201
+ evt.preventDefault();
1202
+ this.keydown_arrow();
1203
+ break;
1204
+ }
1205
+ };
1206
+
1207
+ Chosen.prototype.search_field_scale = function() {
1208
+ var div, f_width, h, style, style_block, styles, w, _i, _len;
1209
+ if (this.is_multiple) {
1210
+ h = 0;
1211
+ w = 0;
1212
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1213
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1214
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1215
+ style = styles[_i];
1216
+ style_block += style + ":" + this.search_field.css(style) + ";";
1217
+ }
1218
+ div = $('<div />', {
1219
+ 'style': style_block
1220
+ });
1221
+ div.text(this.search_field.val());
1222
+ $('body').append(div);
1223
+ w = div.width() + 25;
1224
+ div.remove();
1225
+ f_width = this.container.outerWidth();
1226
+ if (w > f_width - 10) {
1227
+ w = f_width - 10;
1228
+ }
1229
+ return this.search_field.css({
1230
+ 'width': w + 'px'
1231
+ });
1232
+ }
1233
+ };
1234
+
1235
+ return Chosen;
1236
+
1237
+ })(AbstractChosen);
1238
+
1239
+ }).call(this);