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,309 @@
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
+ * Prompt plugin displays a visual user propmpt in the text input area. If user focuses
13
+ * on the input, the propt is hidden and only shown again when user focuses on another
14
+ * element and text input doesn't have a value.
15
+ *
16
+ * @author agorbatchev
17
+ * @date 2011/08/18
18
+ * @id TextExtPrompt
19
+ */
20
+ function TextExtPrompt() {};
21
+
22
+ $.fn.textext.TextExtPrompt = TextExtPrompt;
23
+ $.fn.textext.addPlugin('prompt', TextExtPrompt);
24
+
25
+ var p = TextExtPrompt.prototype,
26
+
27
+ CSS_HIDE_PROMPT = 'text-hide-prompt',
28
+
29
+ /**
30
+ * Prompt plugin has options to change the prompt label and its HTML template. The options
31
+ * could be changed when passed to the `$().textext()` function. For example:
32
+ *
33
+ * $('textarea').textext({
34
+ * plugins: 'prompt',
35
+ * prompt: 'Your email address'
36
+ * })
37
+ *
38
+ * @author agorbatchev
39
+ * @date 2011/08/18
40
+ * @id TextExtPrompt.options
41
+ */
42
+
43
+ /**
44
+ * Prompt message that is displayed to the user whenever there's no value in the input.
45
+ *
46
+ * @name prompt
47
+ * @default 'Awaiting input...'
48
+ * @author agorbatchev
49
+ * @date 2011/08/18
50
+ * @id TextExtPrompt.options.prompt
51
+ */
52
+ OPT_PROMPT = 'prompt',
53
+
54
+ /**
55
+ * HTML source that is used to generate markup required for the prompt effect.
56
+ *
57
+ * @name html.prompt
58
+ * @default '<div class="text-prompt"/>'
59
+ * @author agorbatchev
60
+ * @date 2011/08/18
61
+ * @id TextExtPrompt.options.html.prompt
62
+ */
63
+ OPT_HTML_PROMPT = 'html.prompt',
64
+
65
+ /**
66
+ * Prompt plugin dispatches or reacts to the following events.
67
+ * @id TextExtPrompt.events
68
+ */
69
+
70
+ /**
71
+ * Prompt plugin reacts to the `focus` event and hides the markup generated from
72
+ * the `html.prompt` option.
73
+ *
74
+ * @name focus
75
+ * @author agorbatchev
76
+ * @date 2011/08/18
77
+ * @id TextExtPrompt.events.focus
78
+ */
79
+
80
+ /**
81
+ * Prompt plugin reacts to the `blur` event and shows the prompt back if user
82
+ * hasn't entered any value.
83
+ *
84
+ * @name blur
85
+ * @author agorbatchev
86
+ * @date 2011/08/18
87
+ * @id TextExtPrompt.events.blur
88
+ */
89
+
90
+ DEFAULT_OPTS = {
91
+ prompt : 'Awaiting input...',
92
+
93
+ html : {
94
+ prompt : '<div class="text-prompt"/>'
95
+ }
96
+ }
97
+ ;
98
+
99
+ /**
100
+ * Initialization method called by the core during plugin instantiation.
101
+ *
102
+ * @signature TextExtPrompt.init(core)
103
+ *
104
+ * @param core {TextExt} Instance of the TextExt core class.
105
+ *
106
+ * @author agorbatchev
107
+ * @date 2011/08/18
108
+ * @id TextExtPrompt.init
109
+ */
110
+ p.init = function(core)
111
+ {
112
+ var self = this,
113
+ placeholderKey = 'placeholder',
114
+ container,
115
+ prompt
116
+ ;
117
+
118
+ self.baseInit(core, DEFAULT_OPTS);
119
+
120
+ container = $(self.opts(OPT_HTML_PROMPT));
121
+ $(self).data('container', container);
122
+
123
+ self.core().wrapElement().append(container);
124
+ self.setPrompt(self.opts(OPT_PROMPT));
125
+
126
+ prompt = core.input().attr(placeholderKey);
127
+
128
+ if(!prompt)
129
+ prompt = self.opts(OPT_PROMPT);
130
+
131
+ // clear placeholder attribute if set
132
+ core.input().attr(placeholderKey, '');
133
+
134
+ if(prompt)
135
+ self.setPrompt(prompt);
136
+
137
+ if($.trim(self.val()).length > 0)
138
+ self.hidePrompt();
139
+
140
+ self.on({
141
+ blur : self.onBlur,
142
+ focus : self.onFocus,
143
+ postInvalidate : self.onPostInvalidate,
144
+ postInit : self.onPostInit
145
+ });
146
+ };
147
+
148
+ //--------------------------------------------------------------------------------
149
+ // Event handlers
150
+
151
+ /**
152
+ * Reacts to the `postInit` and configures the plugin for initial display.
153
+ *
154
+ * @signature TextExtPrompt.onPostInit(e)
155
+ *
156
+ * @param e {Object} jQuery event.
157
+ *
158
+ * @author agorbatchev
159
+ * @date 2011/08/24
160
+ * @id TextExtPrompt.onPostInit
161
+ */
162
+ p.onPostInit = function(e)
163
+ {
164
+ this.invalidateBounds();
165
+ };
166
+
167
+ /**
168
+ * Reacts to the `postInvalidate` and insures that prompt display remains correct.
169
+ *
170
+ * @signature TextExtPrompt.onPostInvalidate(e)
171
+ *
172
+ * @param e {Object} jQuery event.
173
+ *
174
+ * @author agorbatchev
175
+ * @date 2011/08/24
176
+ * @id TextExtPrompt.onPostInvalidate
177
+ */
178
+ p.onPostInvalidate = function(e)
179
+ {
180
+ this.invalidateBounds();
181
+ };
182
+
183
+ /**
184
+ * Repositions the prompt to make sure it's always at the same place as in the text input carret.
185
+ *
186
+ * @signature TextExtPrompt.invalidateBounds()
187
+ *
188
+ * @author agorbatchev
189
+ * @date 2011/08/24
190
+ * @id TextExtPrompt.invalidateBounds
191
+ */
192
+ p.invalidateBounds = function()
193
+ {
194
+ var self = this,
195
+ input = self.input()
196
+ ;
197
+
198
+ self.containerElement().css({
199
+ paddingLeft : input.css('paddingLeft'),
200
+ paddingTop : input.css('paddingTop')
201
+ });
202
+ };
203
+
204
+ /**
205
+ * Reacts to the `blur` event and shows the prompt effect with a slight delay which
206
+ * allows quick refocusing without effect blinking in and out.
207
+ *
208
+ * The prompt is restored if the text box has no value.
209
+ *
210
+ * @signature TextExtPrompt.onBlur(e)
211
+ *
212
+ * @param e {Object} jQuery event.
213
+ *
214
+ * @author agorbatchev
215
+ * @date 2011/08/08
216
+ * @id TextExtPrompt.onBlur
217
+ */
218
+ p.onBlur = function(e)
219
+ {
220
+ var self = this;
221
+
222
+ self.startTimer('prompt', 0.1, function()
223
+ {
224
+ self.showPrompt();
225
+ });
226
+ };
227
+
228
+ /**
229
+ * Shows prompt HTML element.
230
+ *
231
+ * @signature TextExtPrompt.showPrompt()
232
+ *
233
+ * @author agorbatchev
234
+ * @date 2011/08/22
235
+ * @id TextExtPrompt.showPrompt
236
+ */
237
+ p.showPrompt = function()
238
+ {
239
+ var self = this,
240
+ input = self.input()
241
+ ;
242
+
243
+ if($.trim(self.val()).length === 0 && !input.is(':focus'))
244
+ self.containerElement().removeClass(CSS_HIDE_PROMPT);
245
+ };
246
+
247
+ /**
248
+ * Hides prompt HTML element.
249
+ *
250
+ * @signature TextExtPrompt.hidePrompt()
251
+ *
252
+ * @author agorbatchev
253
+ * @date 2011/08/22
254
+ * @id TextExtPrompt.hidePrompt
255
+ */
256
+ p.hidePrompt = function()
257
+ {
258
+ this.stopTimer('prompt');
259
+ this.containerElement().addClass(CSS_HIDE_PROMPT);
260
+ };
261
+
262
+ /**
263
+ * Reacts to the `focus` event and hides the prompt effect.
264
+ *
265
+ * @signature TextExtPrompt.onFocus
266
+ *
267
+ * @param e {Object} jQuery event.
268
+ * @author agorbatchev
269
+ * @date 2011/08/08
270
+ * @id TextExtPrompt.onFocus
271
+ */
272
+ p.onFocus = function(e)
273
+ {
274
+ this.hidePrompt();
275
+ };
276
+
277
+ //--------------------------------------------------------------------------------
278
+ // Core functionality
279
+
280
+ /**
281
+ * Sets the prompt display to the specified string.
282
+ *
283
+ * @signature TextExtPrompt.setPrompt(str)
284
+ *
285
+ * @oaram str {String} String that will be displayed in the prompt.
286
+ *
287
+ * @author agorbatchev
288
+ * @date 2011/08/18
289
+ * @id TextExtPrompt.setPrompt
290
+ */
291
+ p.setPrompt = function(str)
292
+ {
293
+ this.containerElement().text(str);
294
+ };
295
+
296
+ /**
297
+ * Returns prompt effect HTML element.
298
+ *
299
+ * @signature TextExtPrompt.containerElement()
300
+ *
301
+ * @author agorbatchev
302
+ * @date 2011/08/08
303
+ * @id TextExtPrompt.containerElement
304
+ */
305
+ p.containerElement = function()
306
+ {
307
+ return $(this).data('container');
308
+ };
309
+ })(jQuery);
@@ -0,0 +1,175 @@
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
+ * Suggestions plugin allows to easily specify the list of suggestion items that the
13
+ * Autocomplete plugin would present to the user.
14
+ *
15
+ * @author agorbatchev
16
+ * @date 2011/08/18
17
+ * @id TextExtSuggestions
18
+ */
19
+ function TextExtSuggestions() {};
20
+
21
+ $.fn.textext.TextExtSuggestions = TextExtSuggestions;
22
+ $.fn.textext.addPlugin('suggestions', TextExtSuggestions);
23
+
24
+ var p = TextExtSuggestions.prototype,
25
+ /**
26
+ * Suggestions plugin only has one option and that is to set suggestion items. It could be
27
+ * changed when passed to the `$().textext()` function. For example:
28
+ *
29
+ * $('textarea').textext({
30
+ * plugins: 'suggestions',
31
+ * suggestions: [ "item1", "item2" ]
32
+ * })
33
+ *
34
+ * @author agorbatchev
35
+ * @date 2011/08/18
36
+ * @id TextExtSuggestions.options
37
+ */
38
+
39
+ /**
40
+ * List of items that Autocomplete plugin would display in the dropdown.
41
+ *
42
+ * @name suggestions
43
+ * @default null
44
+ * @author agorbatchev
45
+ * @date 2011/08/18
46
+ * @id TextExtSuggestions.options.suggestions
47
+ */
48
+ OPT_SUGGESTIONS = 'suggestions',
49
+
50
+ /**
51
+ * Suggestions plugin dispatches or reacts to the following events.
52
+ *
53
+ * @author agorbatchev
54
+ * @date 2011/08/17
55
+ * @id TextExtSuggestions.events
56
+ */
57
+
58
+ /**
59
+ * Suggestions plugin reacts to the `getSuggestions` event and returns `suggestions` items
60
+ * from the options.
61
+ *
62
+ * @name getSuggestions
63
+ * @author agorbatchev
64
+ * @date 2011/08/19
65
+ * @id TextExtSuggestions.events.getSuggestions
66
+ */
67
+
68
+ /**
69
+ * Suggestions plugin triggers the `setSuggestions` event to pass its own list of `Suggestions`
70
+ * to the Autocomplete plugin.
71
+ *
72
+ * @name setSuggestions
73
+ * @author agorbatchev
74
+ * @date 2011/08/19
75
+ * @id TextExtSuggestions.events.setSuggestions
76
+ */
77
+
78
+ /**
79
+ * Suggestions plugin reacts to the `postInit` event to pass its list of `suggestions` to the
80
+ * Autocomplete right away.
81
+ *
82
+ * @name postInit
83
+ * @author agorbatchev
84
+ * @date 2011/08/19
85
+ * @id TextExtSuggestions.events.postInit
86
+ */
87
+
88
+ DEFAULT_OPTS = {
89
+ suggestions : null
90
+ }
91
+ ;
92
+
93
+ /**
94
+ * Initialization method called by the core during plugin instantiation.
95
+ *
96
+ * @signature TextExtSuggestions.init(core)
97
+ *
98
+ * @param core {TextExt} Instance of the TextExt core class.
99
+ *
100
+ * @author agorbatchev
101
+ * @date 2011/08/18
102
+ * @id TextExtSuggestions.init
103
+ */
104
+ p.init = function(core)
105
+ {
106
+ var self = this;
107
+
108
+ self.baseInit(core, DEFAULT_OPTS);
109
+
110
+ self.on({
111
+ getSuggestions : self.onGetSuggestions,
112
+ postInit : self.onPostInit
113
+ });
114
+ };
115
+
116
+ /**
117
+ * Triggers `setSuggestions` and passes supplied suggestions to the Autocomplete plugin.
118
+ *
119
+ * @signature TextExtSuggestions.setSuggestions(suggestions, showHideDropdown)
120
+ *
121
+ * @param suggestions {Array} List of suggestions. With the default `ItemManager` it should
122
+ * be a list of strings.
123
+ * @param showHideDropdown {Boolean} If it's undesirable to show the dropdown right after
124
+ * suggestions are set, `false` should be passed for this argument.
125
+ *
126
+ * @author agorbatchev
127
+ * @date 2011/08/19
128
+ * @id TextExtSuggestions.setSuggestions
129
+ */
130
+ p.setSuggestions = function(suggestions, showHideDropdown)
131
+ {
132
+ this.trigger('setSuggestions', { result : suggestions, showHideDropdown : showHideDropdown != false });
133
+ };
134
+
135
+ /**
136
+ * Reacts to the `postInit` event and triggers `setSuggestions` event to set suggestions list
137
+ * right after initialization.
138
+ *
139
+ * @signature TextExtSuggestions.onPostInit(e)
140
+ *
141
+ * @param e {Object} jQuery event.
142
+ *
143
+ * @author agorbatchev
144
+ * @date 2011/08/19
145
+ * @id TextExtSuggestions.onPostInit
146
+ */
147
+ p.onPostInit = function(e)
148
+ {
149
+ var self = this;
150
+ self.setSuggestions(self.opts(OPT_SUGGESTIONS), false);
151
+ };
152
+
153
+ /**
154
+ * Reacts to the `getSuggestions` event and triggers `setSuggestions` event with the list
155
+ * of `suggestions` specified in the options.
156
+ *
157
+ * @signature TextExtSuggestions.onGetSuggestions(e, data)
158
+ *
159
+ * @param e {Object} jQuery event.
160
+ * @param data {Object} Payload from the `getSuggestions` event with the user query, eg `{ query: {String} }`.
161
+ *
162
+ * @author agorbatchev
163
+ * @date 2011/08/19
164
+ * @id TextExtSuggestions.onGetSuggestions
165
+ */
166
+ p.onGetSuggestions = function(e, data)
167
+ {
168
+ var self = this,
169
+ suggestions = self.opts(OPT_SUGGESTIONS)
170
+ ;
171
+
172
+ suggestions.sort();
173
+ self.setSuggestions(self.itemManager().filter(suggestions, data.query));
174
+ };
175
+ })(jQuery);