georgia 0.7.8 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +60 -16
  4. data/Rakefile +17 -10
  5. data/app/assets/images/georgia/arrow.png +0 -0
  6. data/app/assets/images/georgia/close.png +0 -0
  7. data/app/assets/javascripts/georgia/application.js +3 -6
  8. data/app/assets/javascripts/georgia/bootstrap-vendor.js.coffee +1 -1
  9. data/app/assets/javascripts/georgia/ckeditor/config.js +1 -1
  10. data/app/assets/javascripts/georgia/components/flash.js.coffee +1 -1
  11. data/app/assets/javascripts/georgia/components/media-library.js.coffee +1 -1
  12. data/app/assets/javascripts/georgia/components/tables.js.coffee +30 -0
  13. data/app/assets/javascripts/georgia/components/tables/{checkbox.js.coffee → checkboxable.js.coffee} +10 -39
  14. data/app/assets/javascripts/georgia/components/tables/media.js.coffee +17 -29
  15. data/app/assets/javascripts/georgia/components/tables/pages.js.coffee +26 -44
  16. data/app/assets/javascripts/georgia/components/tags.js.coffee +13 -24
  17. data/app/assets/javascripts/georgia/vendor/ekko-lightbox.min.js +7 -0
  18. data/app/assets/javascripts/georgia/vendor/textext.core.js +1618 -0
  19. data/app/assets/javascripts/georgia/vendor/textext.plugin.ajax.js +354 -0
  20. data/app/assets/javascripts/georgia/vendor/textext.plugin.arrow.js +106 -0
  21. data/app/assets/javascripts/georgia/vendor/textext.plugin.autocomplete.js +1110 -0
  22. data/app/assets/javascripts/georgia/vendor/textext.plugin.clear.js +116 -0
  23. data/app/assets/javascripts/georgia/vendor/textext.plugin.filter.js +242 -0
  24. data/app/assets/javascripts/georgia/vendor/textext.plugin.focus.js +174 -0
  25. data/app/assets/javascripts/georgia/vendor/textext.plugin.prompt.js +309 -0
  26. data/app/assets/javascripts/georgia/vendor/textext.plugin.suggestions.js +175 -0
  27. data/app/assets/javascripts/georgia/vendor/textext.plugin.tags.js +698 -0
  28. data/app/assets/stylesheets/georgia/application.css.scss +71 -12
  29. data/app/assets/stylesheets/georgia/components/_button.scss +3 -20
  30. data/app/assets/stylesheets/georgia/components/_label.scss +36 -1
  31. data/app/assets/stylesheets/georgia/components/_portlet.scss +4 -1
  32. data/app/assets/stylesheets/georgia/components/_status.scss +9 -0
  33. data/app/assets/stylesheets/georgia/components/_table.scss +7 -0
  34. data/app/assets/stylesheets/georgia/layout/_base.scss +22 -5
  35. data/app/assets/stylesheets/georgia/layout/_print.scss +8 -0
  36. data/app/assets/stylesheets/georgia/modules/_activities.scss +3 -0
  37. data/app/assets/stylesheets/georgia/modules/_footer.scss +3 -1
  38. data/app/assets/stylesheets/georgia/modules/_form_with_helpers.scss +2 -2
  39. data/app/assets/stylesheets/georgia/modules/_header.scss +4 -13
  40. data/app/assets/stylesheets/georgia/modules/_link.scss +6 -1
  41. data/app/assets/stylesheets/georgia/modules/_login.scss +7 -0
  42. data/app/assets/stylesheets/georgia/modules/_media.scss +10 -0
  43. data/app/assets/stylesheets/georgia/modules/_navigation.scss +5 -0
  44. data/app/assets/stylesheets/georgia/modules/_pages.scss +3 -0
  45. data/app/assets/stylesheets/georgia/modules/_results.scss +11 -4
  46. data/app/assets/stylesheets/georgia/modules/_sidebar.scss +6 -21
  47. data/app/assets/stylesheets/georgia/modules/_users.scss +3 -0
  48. data/app/assets/stylesheets/georgia/overrides/_flatly.scss +16 -0
  49. data/app/assets/stylesheets/georgia/overrides/_textext.scss +54 -0
  50. data/app/assets/stylesheets/georgia/settings/_base.scss +1 -1
  51. data/app/assets/stylesheets/georgia/settings/_colors.scss +31 -1
  52. data/app/assets/stylesheets/georgia/settings/_z-index.scss +2 -2
  53. data/app/assets/stylesheets/georgia/vendor/_bootswatch-flatly-theme.scss +7 -0
  54. data/app/assets/stylesheets/georgia/vendor/_ekko-lightbox.min.scss +6 -0
  55. data/app/assets/stylesheets/georgia/vendor/_select2_bootstrap.scss +497 -0
  56. data/app/assets/stylesheets/georgia/vendor/_textext.core.scss +29 -0
  57. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.arrow.scss +13 -0
  58. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.autocomplete.scss +35 -0
  59. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.clear.scss +13 -0
  60. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.focus.scss +12 -0
  61. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.prompt.scss +16 -0
  62. data/app/assets/stylesheets/georgia/vendor/_textext.plugin.tags.scss +49 -0
  63. data/app/controllers/georgia/api/media_controller.rb +4 -2
  64. data/app/controllers/georgia/api/tags_controller.rb +10 -7
  65. data/app/controllers/georgia/application_controller.rb +17 -2
  66. data/app/controllers/georgia/concerns/frontendable.rb +2 -3
  67. data/app/controllers/georgia/dashboard_controller.rb +5 -7
  68. data/app/controllers/georgia/links_controller.rb +1 -0
  69. data/app/controllers/georgia/media_controller.rb +50 -41
  70. data/app/controllers/georgia/menus_controller.rb +16 -6
  71. data/app/controllers/georgia/pages_controller.rb +98 -58
  72. data/app/controllers/georgia/revisions_controller.rb +120 -24
  73. data/app/controllers/georgia/ui_associations_controller.rb +1 -0
  74. data/app/controllers/georgia/users_controller.rb +31 -11
  75. data/app/controllers/georgia/widgets_controller.rb +13 -4
  76. data/app/helpers/georgia/application_helper.rb +4 -0
  77. data/app/helpers/georgia/forms_helper.rb +2 -2
  78. data/app/helpers/georgia/ui_helper.rb +78 -12
  79. data/app/helpers/georgia/users_helper.rb +21 -0
  80. data/app/mailers/georgia/notifier.rb +4 -4
  81. data/app/models/ckeditor/asset.rb +16 -4
  82. data/app/models/ckeditor/asset_search.rb +15 -0
  83. data/app/models/ckeditor/attachment_file.rb +7 -0
  84. data/app/models/ckeditor/picture.rb +10 -0
  85. data/app/models/georgia/clone.rb +3 -1
  86. data/app/models/georgia/concerns/contentable.rb +2 -3
  87. data/app/models/georgia/concerns/searchable.rb +32 -0
  88. data/app/models/georgia/concerns/taggable.rb +2 -2
  89. data/app/models/georgia/concerns/treeable.rb +0 -1
  90. data/app/models/georgia/content.rb +1 -3
  91. data/app/models/georgia/dashboard.rb +7 -0
  92. data/app/models/georgia/link.rb +10 -3
  93. data/app/models/georgia/menu.rb +4 -4
  94. data/app/models/georgia/page.rb +75 -10
  95. data/app/models/georgia/revision.rb +10 -5
  96. data/app/models/georgia/role.rb +5 -5
  97. data/app/models/georgia/role_assignment.rb +8 -0
  98. data/app/models/georgia/slide.rb +4 -4
  99. data/app/models/georgia/status.rb +3 -5
  100. data/app/models/georgia/ui_association.rb +3 -5
  101. data/app/models/georgia/ui_section.rb +1 -1
  102. data/app/models/georgia/user.rb +5 -14
  103. data/app/models/georgia/widget.rb +3 -3
  104. data/app/policies/georgia/api_policy.rb +13 -0
  105. data/app/policies/georgia/application_policy.rb +30 -0
  106. data/app/policies/georgia/concerns/content_policy.rb +56 -0
  107. data/app/policies/georgia/concerns/publishing_policy.rb +52 -0
  108. data/app/policies/georgia/dashboard_policy.rb +19 -0
  109. data/app/policies/georgia/media_policy.rb +56 -0
  110. data/app/policies/georgia/navigation_policy.rb +42 -0
  111. data/app/policies/georgia/page_policy.rb +26 -0
  112. data/app/policies/georgia/revision_policy.rb +7 -44
  113. data/app/policies/georgia/ui_association_policy.rb +4 -0
  114. data/app/policies/georgia/user_policy.rb +46 -0
  115. data/app/policies/georgia/widget_policy.rb +42 -0
  116. data/app/presenters/georgia/active_facet_presenter.rb +2 -1
  117. data/app/presenters/georgia/link_portlet.rb +2 -2
  118. data/app/presenters/georgia/pagination_presenter.rb +45 -7
  119. data/app/presenters/georgia/permission_table_presenter.rb +80 -0
  120. data/app/presenters/georgia/revision_status_message.rb +73 -0
  121. data/app/presenters/georgia/sidebar_link_presenter.rb +1 -1
  122. data/app/presenters/georgia/slide_portlet.rb +5 -1
  123. data/app/routes/georgia/pageable_route_concern.rb +35 -0
  124. data/app/searches/georgia/media_search.rb +39 -0
  125. data/app/searches/georgia/page_search.rb +47 -0
  126. data/app/searches/georgia/search_definition.rb +72 -0
  127. data/app/searches/georgia/tag_search.rb +32 -0
  128. data/app/services/georgia/clone_revision.rb +71 -0
  129. data/app/services/georgia/compress_files.rb +49 -0
  130. data/app/services/georgia/copy_page.rb +100 -0
  131. data/app/services/georgia/create_activity.rb +16 -0
  132. data/app/services/georgia/create_media_asset.rb +53 -0
  133. data/app/services/georgia/parse_json_tags.rb +21 -0
  134. data/app/services/georgia/update_revision.rb +52 -0
  135. data/app/views/georgia/api/media/pictures.html.erb +1 -1
  136. data/app/views/georgia/ckeditor/assets/_asset.html.erb +2 -4
  137. data/app/views/georgia/ckeditor/pictures/_picture.html.erb +1 -6
  138. data/app/views/georgia/dashboard/panels/_messages.html.erb +26 -28
  139. data/app/views/georgia/dashboard/panels/_reviews.html.erb +23 -22
  140. data/app/views/georgia/dashboard/show.html.erb +9 -3
  141. data/app/views/georgia/header/_media.html.erb +2 -2
  142. data/app/views/georgia/header/_navigation.html.erb +3 -3
  143. data/app/views/georgia/header/_pages.html.erb +3 -3
  144. data/app/views/georgia/header/_users.html.erb +2 -2
  145. data/app/views/georgia/header/_widgets.html.erb +1 -1
  146. data/app/views/georgia/media/_header.html.erb +4 -2
  147. data/app/views/georgia/media/create.js.erb +1 -0
  148. data/app/views/georgia/media/destroy.js.erb +3 -0
  149. data/app/views/georgia/media/edit.html.erb +35 -30
  150. data/app/views/georgia/media/search.html.erb +2 -2
  151. data/app/views/georgia/menus/index.html.erb +1 -1
  152. data/app/views/georgia/pages/_header.html.erb +4 -4
  153. data/app/views/georgia/pages/_page.html.erb +1 -1
  154. data/app/views/georgia/pages/search.html.erb +4 -5
  155. data/app/views/georgia/pages/settings.html.erb +72 -61
  156. data/app/views/georgia/revisions/_revision.html.erb +12 -7
  157. data/app/views/georgia/revisions/edit.html.erb +17 -11
  158. data/app/views/georgia/revisions/fields/_content.html.erb +1 -2
  159. data/app/views/georgia/revisions/fields/_message.html.erb +11 -0
  160. data/app/views/georgia/revisions/fields/_ui_section.html.erb +1 -1
  161. data/app/views/georgia/revisions/fields/_widgets.html.erb +1 -1
  162. data/app/views/georgia/revisions/index.html.erb +2 -2
  163. data/app/views/georgia/revisions/messages/_awaiting_review.html.erb +15 -0
  164. data/app/views/georgia/revisions/messages/_continue_draft.html.erb +8 -0
  165. data/app/views/georgia/revisions/messages/_edit_current_revision.html.erb +12 -0
  166. data/app/views/georgia/revisions/messages/_insufficient_rights.html.erb +6 -0
  167. data/app/views/georgia/revisions/messages/_request_review.html.erb +7 -0
  168. data/app/views/georgia/revisions/messages/_review.html.erb +7 -0
  169. data/app/views/georgia/revisions/messages/_start_draft.html.erb +4 -0
  170. data/app/views/georgia/revisions/panels/_actions.html.erb +7 -0
  171. data/app/views/georgia/revisions/panels/_activities.html.erb +6 -0
  172. data/app/views/georgia/revisions/panels/_drafts.html.erb +28 -0
  173. data/app/views/georgia/revisions/panels/_info.html.erb +39 -0
  174. data/app/views/georgia/shared/modals/_media_library.html.erb +3 -1
  175. data/app/views/georgia/shared/search/_messages.html.erb +1 -1
  176. data/app/views/georgia/users/_form.html.erb +17 -2
  177. data/app/views/georgia/users/_user.html.erb +1 -1
  178. data/app/views/georgia/users/edit.html.erb +0 -1
  179. data/app/views/georgia/users/index.html.erb +1 -1
  180. data/app/views/georgia/users/permissions.html.erb +15 -0
  181. data/app/views/georgia/users/sessions/new.html.erb +3 -3
  182. data/app/views/layouts/georgia/_footer.html.erb +1 -3
  183. data/app/views/layouts/georgia/_head.html.erb +3 -4
  184. data/app/views/layouts/georgia/_header.html.erb +8 -10
  185. data/app/views/public_activity/_default.html.erb +15 -0
  186. data/app/views/public_activity/georgia_page/_copy.html.erb +15 -0
  187. data/app/views/public_activity/georgia_page/_create.html.erb +15 -0
  188. data/app/views/public_activity/georgia_page/_decline.html.erb +15 -0
  189. data/app/views/public_activity/georgia_page/_publish.html.erb +15 -0
  190. data/app/views/public_activity/georgia_page/_unpublish.html.erb +15 -0
  191. data/app/views/public_activity/georgia_page/_update.html.erb +15 -0
  192. data/app/views/public_activity/georgia_revision/_approve.html.erb +15 -0
  193. data/app/views/public_activity/georgia_revision/_decline.html.erb +15 -0
  194. data/app/views/public_activity/georgia_revision/_draft.html.erb +15 -0
  195. data/app/views/public_activity/georgia_revision/_restore.html.erb +15 -0
  196. data/app/views/public_activity/georgia_revision/_review.html.erb +15 -0
  197. data/app/views/public_activity/georgia_revision/_update.html.erb +15 -0
  198. data/config/initializers/acts_as_taggable_on.rb +13 -12
  199. data/config/initializers/ckeditor.rb +36 -16
  200. data/config/initializers/devise.rb +17 -15
  201. data/config/initializers/elasticsearch.rb +44 -0
  202. data/config/initializers/inflections.rb +1 -1
  203. data/config/routes.rb +13 -36
  204. data/db/migrate/001_create_ckeditor_assets.rb +6 -5
  205. data/db/migrate/002_create_georgia_contents.rb +2 -4
  206. data/db/migrate/008_create_georgia_roles.rb +0 -2
  207. data/db/migrate/015_add_receives_notifications_to_users.rb +7 -0
  208. data/db/migrate/016_add_role_id_to_users.rb +7 -0
  209. data/db/migrate/017_add_status_to_revisions.rb +7 -0
  210. data/db/migrate/018_create_georgia_role_assignments.rb +11 -0
  211. data/db/migrate/019_create_activities.rb +23 -0
  212. data/db/migrate/020_remove_georgia_revisions_state.rb +11 -0
  213. data/db/migrate/021_add_revised_by_id_to_georgia_revisions.rb +13 -0
  214. data/lib/generators/georgia/install/install_generator.rb +3 -29
  215. data/lib/generators/georgia/install/templates/app/controllers/pages_controller.rb +1 -1
  216. data/lib/generators/georgia/install/templates/config/initializers/georgia.rb +3 -7
  217. data/lib/generators/georgia/setup/setup_generator.rb +29 -0
  218. data/lib/georgia.rb +26 -9
  219. data/lib/georgia/engine.rb +6 -25
  220. data/lib/georgia/permissions.rb +57 -0
  221. data/lib/georgia/uploader/adapter.rb +4 -1
  222. data/lib/georgia/uploader/storage/file.rb +23 -0
  223. data/lib/georgia/version.rb +1 -1
  224. data/lib/tasks/georgia_tasks.rake +99 -0
  225. metadata +463 -461
  226. data/app/assets/fonts/georgia/signika-bold-webfont.eot +0 -0
  227. data/app/assets/fonts/georgia/signika-bold-webfont.svg +0 -1711
  228. data/app/assets/fonts/georgia/signika-bold-webfont.ttf +0 -0
  229. data/app/assets/fonts/georgia/signika-bold-webfont.woff +0 -0
  230. data/app/assets/fonts/georgia/signika-light-webfont.eot +0 -0
  231. data/app/assets/fonts/georgia/signika-light-webfont.svg +0 -1680
  232. data/app/assets/fonts/georgia/signika-light-webfont.ttf +0 -0
  233. data/app/assets/fonts/georgia/signika-light-webfont.woff +0 -0
  234. data/app/assets/fonts/georgia/signika-regular-webfont.eot +0 -0
  235. data/app/assets/fonts/georgia/signika-regular-webfont.svg +0 -1746
  236. data/app/assets/fonts/georgia/signika-regular-webfont.ttf +0 -0
  237. data/app/assets/fonts/georgia/signika-regular-webfont.woff +0 -0
  238. data/app/assets/images/georgia/bg-body-bar.jpg +0 -0
  239. data/app/assets/images/georgia/content-types/avi.jpg +0 -0
  240. data/app/assets/images/georgia/content-types/css.jpg +0 -0
  241. data/app/assets/images/georgia/content-types/csv.jpg +0 -0
  242. data/app/assets/images/georgia/content-types/doc.jpg +0 -0
  243. data/app/assets/images/georgia/content-types/docx.jpg +0 -0
  244. data/app/assets/images/georgia/content-types/eps.jpg +0 -0
  245. data/app/assets/images/georgia/content-types/gif.jpg +0 -0
  246. data/app/assets/images/georgia/content-types/gz.jpg +0 -0
  247. data/app/assets/images/georgia/content-types/html.jpg +0 -0
  248. data/app/assets/images/georgia/content-types/jpeg.jpg +0 -0
  249. data/app/assets/images/georgia/content-types/jpg.jpg +0 -0
  250. data/app/assets/images/georgia/content-types/mp3.jpg +0 -0
  251. data/app/assets/images/georgia/content-types/ods.jpg +0 -0
  252. data/app/assets/images/georgia/content-types/odt.jpg +0 -0
  253. data/app/assets/images/georgia/content-types/pdf.jpg +0 -0
  254. data/app/assets/images/georgia/content-types/png.jpg +0 -0
  255. data/app/assets/images/georgia/content-types/ppt.jpg +0 -0
  256. data/app/assets/images/georgia/content-types/pptx.jpg +0 -0
  257. data/app/assets/images/georgia/content-types/rar.jpg +0 -0
  258. data/app/assets/images/georgia/content-types/tar.jpg +0 -0
  259. data/app/assets/images/georgia/content-types/txt.jpg +0 -0
  260. data/app/assets/images/georgia/content-types/wav.jpg +0 -0
  261. data/app/assets/images/georgia/content-types/xls.jpg +0 -0
  262. data/app/assets/images/georgia/content-types/zip.jpg +0 -0
  263. data/app/assets/images/georgia/down_arrow.gif +0 -0
  264. data/app/assets/images/georgia/grippy_large.png +0 -0
  265. data/app/assets/images/georgia/logo.png +0 -0
  266. data/app/assets/images/georgia/up_arrow.gif +0 -0
  267. data/app/assets/javascripts/georgia/keybindings.js.coffee +0 -42
  268. data/app/assets/stylesheets/georgia/components/_state.scss +0 -17
  269. data/app/assets/stylesheets/georgia/settings/_fonts.scss +0 -3
  270. data/app/decorators/georgia/link_decorator.rb +0 -9
  271. data/app/decorators/georgia/links_decorator.rb +0 -4
  272. data/app/helpers/georgia/internationalization_helper.rb +0 -45
  273. data/app/helpers/georgia/menus_helper.rb +0 -20
  274. data/app/helpers/georgia/meta_tags_helper.rb +0 -22
  275. data/app/helpers/georgia/pages_helper.rb +0 -30
  276. data/app/helpers/georgia/routes_helper.rb +0 -25
  277. data/app/helpers/georgia/twitter_helper.rb +0 -24
  278. data/app/models/ability.rb +0 -19
  279. data/app/models/acts_as_taggable_on/tag.rb +0 -5
  280. data/app/models/georgia/concerns/cacheable.rb +0 -18
  281. data/app/models/georgia/concerns/orderable.rb +0 -21
  282. data/app/models/georgia/concerns/publishable.rb +0 -35
  283. data/app/models/georgia/concerns/revisionable.rb +0 -38
  284. data/app/models/georgia/concerns/slugable.rb +0 -48
  285. data/app/models/georgia/concerns/statable.rb +0 -64
  286. data/app/models/georgia/concerns/templatable.rb +0 -20
  287. data/app/policies/georgia/policy.rb +0 -17
  288. data/app/presenters/georgia/page_actions_presenter.rb +0 -92
  289. data/app/presenters/georgia/warning_message.rb +0 -55
  290. data/app/services/create_media_asset.rb +0 -51
  291. data/app/sweepers/navigation_sweeper.rb +0 -12
  292. data/app/views/georgia/media/sidebar/_facets.html.erb +0 -12
  293. data/app/views/menus/_dropdown_group.html.erb +0 -10
  294. data/app/views/menus/_dropdown_link.html.erb +0 -3
  295. data/app/views/menus/_dropdown_menu.html.erb +0 -11
  296. data/app/views/menus/_link.html.erb +0 -1
  297. data/app/views/menus/_menu.html.erb +0 -7
  298. data/config/initializers/simple_form.rb +0 -79
  299. data/config/locales/georgia.en.yml +0 -4
  300. data/lib/georgia/indexer.rb +0 -33
  301. data/lib/georgia/indexer/adapter.rb +0 -44
  302. data/lib/georgia/indexer/extensions/solr_adapter/acts_as_taggable_on/tag.rb +0 -30
  303. data/lib/georgia/indexer/extensions/solr_adapter/ckeditor/asset.rb +0 -46
  304. data/lib/georgia/indexer/extensions/solr_adapter/georgia/page.rb +0 -75
  305. data/lib/georgia/indexer/extensions/tire_adapter/acts_as_taggable_on/tag.rb +0 -34
  306. data/lib/georgia/indexer/extensions/tire_adapter/ckeditor/asset.rb +0 -57
  307. data/lib/georgia/indexer/extensions/tire_adapter/georgia/page.rb +0 -55
  308. data/lib/georgia/indexer/solr_adapter.rb +0 -20
  309. data/lib/georgia/indexer/tire_adapter.rb +0 -18
  310. data/lib/tasks/assets.rake +0 -20
  311. data/lib/tasks/georgia.rake +0 -65
  312. data/lib/tasks/sidekiq.rake +0 -8
  313. data/lib/tasks/solr.rake +0 -21
  314. data/lib/tasks/upgrade.rake +0 -39
  315. data/lib/templates/erb/scaffold/_form.html.erb +0 -13
@@ -0,0 +1,354 @@
1
+ /**
2
+ * jQuery TextExt Plugin
3
+ * http://textextjs.com
4
+ *
5
+ * @version 1.3.1
6
+ * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
+ * @license MIT License
8
+ */
9
+ (function($)
10
+ {
11
+ /**
12
+ * AJAX plugin is very useful if you want to load list of items from a data point and pass it
13
+ * to the Autocomplete or Filter plugins.
14
+ *
15
+ * Because it meant to be as a helper method for either Autocomplete or Filter plugin, without
16
+ * either of these two present AJAX plugin won't do anything.
17
+ *
18
+ * @author agorbatchev
19
+ * @date 2011/08/16
20
+ * @id TextExtAjax
21
+ */
22
+ function TextExtAjax() {};
23
+
24
+ $.fn.textext.TextExtAjax = TextExtAjax;
25
+ $.fn.textext.addPlugin('ajax', TextExtAjax);
26
+
27
+ var p = TextExtAjax.prototype,
28
+
29
+ /**
30
+ * AJAX plugin options are grouped under `ajax` when passed to the `$().textext()` function. Be
31
+ * mindful that the whole `ajax` object is also passed to jQuery `$.ajax` call which means that
32
+ * you can change all jQuery options as well. Please refer to the jQuery documentation on how
33
+ * to set url and all other parameters. For example:
34
+ *
35
+ * $('textarea').textext({
36
+ * plugins: 'ajax',
37
+ * ajax: {
38
+ * url: 'http://...'
39
+ * }
40
+ * })
41
+ *
42
+ * **Important**: Because it's necessary to pass options to `jQuery.ajax()` in a single object,
43
+ * all jQuery related AJAX options like `url`, `dataType`, etc **must** be within the `ajax` object.
44
+ * This is the exception to general rule that TextExt options can be specified in dot or camel case
45
+ * notation.
46
+ *
47
+ * @author agorbatchev
48
+ * @date 2011/08/16
49
+ * @id TextExtAjax.options
50
+ */
51
+
52
+ /**
53
+ * By default, when user starts typing into the text input, AJAX plugin will start making requests
54
+ * to the `url` that you have specified and will pass whatever user has typed so far as a parameter
55
+ * named `q`, eg `?q=foo`.
56
+ *
57
+ * If you wish to change this behaviour, you can pass a function as a value for this option which
58
+ * takes one argument (the user input) and should return a key/value object that will be converted
59
+ * to the request parameters. For example:
60
+ *
61
+ * 'dataCallback' : function(query)
62
+ * {
63
+ * return { 'search' : query };
64
+ * }
65
+ *
66
+ * @name ajax.data.callback
67
+ * @default null
68
+ * @author agorbatchev
69
+ * @date 2011/08/16
70
+ * @id TextExtAjax.options.data.callback
71
+ */
72
+ OPT_DATA_CALLBACK = 'ajax.data.callback',
73
+
74
+ /**
75
+ * By default, the server end point is constantly being reloaded whenever user changes the value
76
+ * in the text input. If you'd rather have the client do result filtering, you can return all
77
+ * possible results from the server and cache them on the client by setting this option to `true`.
78
+ *
79
+ * In such a case, only one call to the server will be made and filtering will be performed on
80
+ * the client side using `ItemManager` attached to the core.
81
+ *
82
+ * @name ajax.data.results
83
+ * @default false
84
+ * @author agorbatchev
85
+ * @date 2011/08/16
86
+ * @id TextExtAjax.options.cache.results
87
+ */
88
+ OPT_CACHE_RESULTS = 'ajax.cache.results',
89
+
90
+ /**
91
+ * The loading message delay is set in seconds and will specify how long it would take before
92
+ * user sees the message. If you don't want user to ever see this message, set the option value
93
+ * to `Number.MAX_VALUE`.
94
+ *
95
+ * @name ajax.loading.delay
96
+ * @default 0.5
97
+ * @author agorbatchev
98
+ * @date 2011/08/16
99
+ * @id TextExtAjax.options.loading.delay
100
+ */
101
+ OPT_LOADING_DELAY = 'ajax.loading.delay',
102
+
103
+ /**
104
+ * Whenever an AJAX request is made and the server takes more than the number of seconds specified
105
+ * in `ajax.loading.delay` to respond, the message specified in this option will appear in the drop
106
+ * down.
107
+ *
108
+ * @name ajax.loading.message
109
+ * @default "Loading..."
110
+ * @author agorbatchev
111
+ * @date 2011/08/17
112
+ * @id TextExtAjax.options.loading.message
113
+ */
114
+ OPT_LOADING_MESSAGE = 'ajax.loading.message',
115
+
116
+ /**
117
+ * When user is typing in or otherwise changing the value of the text input, it's undesirable to make
118
+ * an AJAX request for every keystroke. Instead it's more conservative to send a request every number
119
+ * of seconds while user is typing the value. This number of seconds is specified by the `ajax.type.delay`
120
+ * option.
121
+ *
122
+ * @name ajax.type.delay
123
+ * @default 0.5
124
+ * @author agorbatchev
125
+ * @date 2011/08/17
126
+ * @id TextExtAjax.options.type.delay
127
+ */
128
+ OPT_TYPE_DELAY = 'ajax.type.delay',
129
+
130
+ /**
131
+ * AJAX plugin dispatches or reacts to the following events.
132
+ *
133
+ * @author agorbatchev
134
+ * @date 2011/08/17
135
+ * @id TextExtAjax.events
136
+ */
137
+
138
+ /**
139
+ * AJAX plugin reacts to the `getSuggestions` event dispatched by the Autocomplete plugin.
140
+ *
141
+ * @name getSuggestions
142
+ * @author agorbatchev
143
+ * @date 2011/08/17
144
+ * @id TextExtAjax.events.getSuggestions
145
+ */
146
+
147
+ /**
148
+ * In the event of successful AJAX request, the AJAX coponent dispatches the `setSuggestions`
149
+ * event meant to be recieved by the Autocomplete plugin.
150
+ *
151
+ * @name setSuggestions
152
+ * @author agorbatchev
153
+ * @date 2011/08/17
154
+ * @id TextExtAjax.events.setSuggestions
155
+ */
156
+ EVENT_SET_SUGGESTION = 'setSuggestions',
157
+
158
+ /**
159
+ * AJAX plugin dispatches the `showDropdown` event which Autocomplete plugin is expecting.
160
+ * This is used to temporarily show the loading message if the AJAX request is taking longer
161
+ * than expected.
162
+ *
163
+ * @name showDropdown
164
+ * @author agorbatchev
165
+ * @date 2011/08/17
166
+ * @id TextExtAjax.events.showDropdown
167
+ */
168
+ EVENT_SHOW_DROPDOWN = 'showDropdown',
169
+
170
+ TIMER_LOADING = 'loading',
171
+
172
+ DEFAULT_OPTS = {
173
+ ajax : {
174
+ typeDelay : 0.5,
175
+ loadingMessage : 'Loading...',
176
+ loadingDelay : 0.5,
177
+ cacheResults : false,
178
+ dataCallback : null
179
+ }
180
+ }
181
+ ;
182
+
183
+ /**
184
+ * Initialization method called by the core during plugin instantiation.
185
+ *
186
+ * @signature TextExtAjax.init(core)
187
+ *
188
+ * @param core {TextExt} Instance of the TextExt core class.
189
+ *
190
+ * @author agorbatchev
191
+ * @date 2011/08/17
192
+ * @id TextExtAjax.init
193
+ */
194
+ p.init = function(core)
195
+ {
196
+ var self = this;
197
+
198
+ self.baseInit(core, DEFAULT_OPTS);
199
+
200
+ self.on({
201
+ getSuggestions : self.onGetSuggestions
202
+ });
203
+
204
+ self._suggestions = null;
205
+ };
206
+
207
+ /**
208
+ * Performas an async AJAX with specified options.
209
+ *
210
+ * @signature TextExtAjax.load(query)
211
+ *
212
+ * @param query {String} Value that user has typed into the text area which is
213
+ * presumably the query.
214
+ *
215
+ * @author agorbatchev
216
+ * @date 2011/08/14
217
+ * @id TextExtAjax.load
218
+ */
219
+ p.load = function(query)
220
+ {
221
+ var self = this,
222
+ dataCallback = self.opts(OPT_DATA_CALLBACK) || function(query) { return { q : query } },
223
+ opts
224
+ ;
225
+
226
+ opts = $.extend(true,
227
+ {
228
+ data : dataCallback(query),
229
+ success : function(data) { self.onComplete(data, query) },
230
+ error : function(jqXHR, message) { console.error(message, query) }
231
+ },
232
+ self.opts('ajax')
233
+ );
234
+
235
+ $.ajax(opts);
236
+ };
237
+
238
+ /**
239
+ * Successful call AJAX handler. Takes the data that came back from AJAX and the
240
+ * original query that was used to make the call.
241
+ *
242
+ * @signature TextExtAjax.onComplete(data, query)
243
+ *
244
+ * @param data {Object} Data loaded from the server, should be an Array of strings
245
+ * by default or whatever data structure your custom `ItemManager` implements.
246
+ *
247
+ * @param query {String} Query string, ie whatever user has typed in.
248
+ *
249
+ * @author agorbatchev
250
+ * @date 2011/08/14
251
+ * @id TextExtAjax.onComplete
252
+ */
253
+ p.onComplete = function(data, query)
254
+ {
255
+ var self = this,
256
+ result = data
257
+ ;
258
+
259
+ self.dontShowLoading();
260
+
261
+ // If results are expected to be cached, then we store the original
262
+ // data set and return the filtered one based on the original query.
263
+ // That means we do filtering on the client side, instead of the
264
+ // server side.
265
+ if(self.opts(OPT_CACHE_RESULTS) == true)
266
+ {
267
+ self._suggestions = data;
268
+ result = self.itemManager().filter(data, query);
269
+ }
270
+
271
+ self.trigger(EVENT_SET_SUGGESTION, { result : result });
272
+ };
273
+
274
+ /**
275
+ * If show loading message timer was started, calling this function disables it,
276
+ * otherwise nothing else happens.
277
+ *
278
+ * @signature TextExtAjax.dontShowLoading()
279
+ *
280
+ * @author agorbatchev
281
+ * @date 2011/08/16
282
+ * @id TextExtAjax.dontShowLoading
283
+ */
284
+ p.dontShowLoading = function()
285
+ {
286
+ this.stopTimer(TIMER_LOADING);
287
+ };
288
+
289
+ /**
290
+ * Shows message specified in `ajax.loading.message` if loading data takes more than
291
+ * number of seconds specified in `ajax.loading.delay`.
292
+ *
293
+ * @signature TextExtAjax.showLoading()
294
+ *
295
+ * @author agorbatchev
296
+ * @date 2011/08/15
297
+ * @id TextExtAjax.showLoading
298
+ */
299
+ p.showLoading = function()
300
+ {
301
+ var self = this;
302
+
303
+ self.dontShowLoading();
304
+ self.startTimer(
305
+ TIMER_LOADING,
306
+ self.opts(OPT_LOADING_DELAY),
307
+ function()
308
+ {
309
+ self.trigger(EVENT_SHOW_DROPDOWN, function(autocomplete)
310
+ {
311
+ autocomplete.clearItems();
312
+ var node = autocomplete.addDropdownItem(self.opts(OPT_LOADING_MESSAGE));
313
+ node.addClass('text-loading');
314
+ });
315
+ }
316
+ );
317
+ };
318
+
319
+ /**
320
+ * Reacts to the `getSuggestions` event and begin loading suggestions. If
321
+ * `ajax.cache.results` is specified, all calls after the first one will use
322
+ * cached data and filter it with the `core.itemManager.filter()`.
323
+ *
324
+ * @signature TextExtAjax.onGetSuggestions(e, data)
325
+ *
326
+ * @param e {Object} jQuery event.
327
+ * @param data {Object} Data structure passed with the `getSuggestions` event
328
+ * which contains the user query, eg `{ query : "..." }`.
329
+ *
330
+ * @author agorbatchev
331
+ * @date 2011/08/15
332
+ * @id TextExtAjax.onGetSuggestions
333
+ */
334
+ p.onGetSuggestions = function(e, data)
335
+ {
336
+ var self = this,
337
+ suggestions = self._suggestions,
338
+ query = (data || {}).query || ''
339
+ ;
340
+
341
+ if(suggestions && self.opts(OPT_CACHE_RESULTS) === true)
342
+ return self.onComplete(suggestions, query);
343
+
344
+ self.startTimer(
345
+ 'ajax',
346
+ self.opts(OPT_TYPE_DELAY),
347
+ function()
348
+ {
349
+ self.showLoading();
350
+ self.load(query);
351
+ }
352
+ );
353
+ };
354
+ })(jQuery);
@@ -0,0 +1,106 @@
1
+ /**
2
+ * jQuery TextExt Plugin
3
+ * http://textextjs.com
4
+ *
5
+ * @version 1.3.1
6
+ * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
+ * @license MIT License
8
+ */
9
+ (function($)
10
+ {
11
+ /**
12
+ * Displays a dropdown style arrow button. The `TextExtArrow` works together with the
13
+ * `TextExtAutocomplete` plugin and whenever clicked tells the autocomplete plugin to
14
+ * display its suggestions.
15
+ *
16
+ * @author agorbatchev
17
+ * @date 2011/12/27
18
+ * @id TextExtArrow
19
+ */
20
+ function TextExtArrow() {};
21
+
22
+ $.fn.textext.TextExtArrow = TextExtArrow;
23
+ $.fn.textext.addPlugin('arrow', TextExtArrow);
24
+
25
+ var p = TextExtArrow.prototype,
26
+ /**
27
+ * Arrow plugin only has one option and that is its HTML template. It could be
28
+ * changed when passed to the `$().textext()` function. For example:
29
+ *
30
+ * $('textarea').textext({
31
+ * plugins: 'arrow',
32
+ * html: {
33
+ * arrow: "<span/>"
34
+ * }
35
+ * })
36
+ *
37
+ * @author agorbatchev
38
+ * @date 2011/12/27
39
+ * @id TextExtArrow.options
40
+ */
41
+
42
+ /**
43
+ * HTML source that is used to generate markup required for the arrow.
44
+ *
45
+ * @name html.arrow
46
+ * @default '<div class="text-arrow"/>'
47
+ * @author agorbatchev
48
+ * @date 2011/12/27
49
+ * @id TextExtArrow.options.html.arrow
50
+ */
51
+ OPT_HTML_ARROW = 'html.arrow',
52
+
53
+ DEFAULT_OPTS = {
54
+ html : {
55
+ arrow : '<div class="text-arrow"/>'
56
+ }
57
+ }
58
+ ;
59
+
60
+ /**
61
+ * Initialization method called by the core during plugin instantiation.
62
+ *
63
+ * @signature TextExtArrow.init(core)
64
+ *
65
+ * @param core {TextExt} Instance of the TextExt core class.
66
+ *
67
+ * @author agorbatchev
68
+ * @date 2011/12/27
69
+ * @id TextExtArrow.init
70
+ */
71
+ p.init = function(core)
72
+ {
73
+ var self = this,
74
+ arrow
75
+ ;
76
+
77
+ self.baseInit(core, DEFAULT_OPTS);
78
+
79
+ self._arrow = arrow = $(self.opts(OPT_HTML_ARROW));
80
+ self.core().wrapElement().append(arrow);
81
+ arrow.bind('click', function(e) { self.onArrowClick(e); });
82
+ };
83
+
84
+ //--------------------------------------------------------------------------------
85
+ // Event handlers
86
+
87
+ /**
88
+ * Reacts to the `click` event whenever user clicks the arrow.
89
+ *
90
+ * @signature TextExtArrow.onArrowClick(e)
91
+ *
92
+ * @param e {Object} jQuery event.
93
+ * @author agorbatchev
94
+ * @date 2011/12/27
95
+ * @id TextExtArrow.onArrowClick
96
+ */
97
+ p.onArrowClick = function(e)
98
+ {
99
+ this.trigger('toggleDropdown');
100
+ this.core().focusInput();
101
+ };
102
+
103
+ //--------------------------------------------------------------------------------
104
+ // Core functionality
105
+
106
+ })(jQuery);