georgia 0.7.8 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +60 -16
- data/Rakefile +17 -10
- data/app/assets/images/georgia/arrow.png +0 -0
- data/app/assets/images/georgia/close.png +0 -0
- data/app/assets/javascripts/georgia/application.js +3 -6
- data/app/assets/javascripts/georgia/bootstrap-vendor.js.coffee +1 -1
- data/app/assets/javascripts/georgia/ckeditor/config.js +1 -1
- data/app/assets/javascripts/georgia/components/flash.js.coffee +1 -1
- data/app/assets/javascripts/georgia/components/media-library.js.coffee +1 -1
- data/app/assets/javascripts/georgia/components/tables.js.coffee +30 -0
- data/app/assets/javascripts/georgia/components/tables/{checkbox.js.coffee → checkboxable.js.coffee} +10 -39
- data/app/assets/javascripts/georgia/components/tables/media.js.coffee +17 -29
- data/app/assets/javascripts/georgia/components/tables/pages.js.coffee +26 -44
- data/app/assets/javascripts/georgia/components/tags.js.coffee +13 -24
- data/app/assets/javascripts/georgia/vendor/ekko-lightbox.min.js +7 -0
- data/app/assets/javascripts/georgia/vendor/textext.core.js +1618 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.ajax.js +354 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.arrow.js +106 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.autocomplete.js +1110 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.clear.js +116 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.filter.js +242 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.focus.js +174 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.prompt.js +309 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.suggestions.js +175 -0
- data/app/assets/javascripts/georgia/vendor/textext.plugin.tags.js +698 -0
- data/app/assets/stylesheets/georgia/application.css.scss +71 -12
- data/app/assets/stylesheets/georgia/components/_button.scss +3 -20
- data/app/assets/stylesheets/georgia/components/_label.scss +36 -1
- data/app/assets/stylesheets/georgia/components/_portlet.scss +4 -1
- data/app/assets/stylesheets/georgia/components/_status.scss +9 -0
- data/app/assets/stylesheets/georgia/components/_table.scss +7 -0
- data/app/assets/stylesheets/georgia/layout/_base.scss +22 -5
- data/app/assets/stylesheets/georgia/layout/_print.scss +8 -0
- data/app/assets/stylesheets/georgia/modules/_activities.scss +3 -0
- data/app/assets/stylesheets/georgia/modules/_footer.scss +3 -1
- data/app/assets/stylesheets/georgia/modules/_form_with_helpers.scss +2 -2
- data/app/assets/stylesheets/georgia/modules/_header.scss +4 -13
- data/app/assets/stylesheets/georgia/modules/_link.scss +6 -1
- data/app/assets/stylesheets/georgia/modules/_login.scss +7 -0
- data/app/assets/stylesheets/georgia/modules/_media.scss +10 -0
- data/app/assets/stylesheets/georgia/modules/_navigation.scss +5 -0
- data/app/assets/stylesheets/georgia/modules/_pages.scss +3 -0
- data/app/assets/stylesheets/georgia/modules/_results.scss +11 -4
- data/app/assets/stylesheets/georgia/modules/_sidebar.scss +6 -21
- data/app/assets/stylesheets/georgia/modules/_users.scss +3 -0
- data/app/assets/stylesheets/georgia/overrides/_flatly.scss +16 -0
- data/app/assets/stylesheets/georgia/overrides/_textext.scss +54 -0
- data/app/assets/stylesheets/georgia/settings/_base.scss +1 -1
- data/app/assets/stylesheets/georgia/settings/_colors.scss +31 -1
- data/app/assets/stylesheets/georgia/settings/_z-index.scss +2 -2
- data/app/assets/stylesheets/georgia/vendor/_bootswatch-flatly-theme.scss +7 -0
- data/app/assets/stylesheets/georgia/vendor/_ekko-lightbox.min.scss +6 -0
- data/app/assets/stylesheets/georgia/vendor/_select2_bootstrap.scss +497 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.core.scss +29 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.arrow.scss +13 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.autocomplete.scss +35 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.clear.scss +13 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.focus.scss +12 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.prompt.scss +16 -0
- data/app/assets/stylesheets/georgia/vendor/_textext.plugin.tags.scss +49 -0
- data/app/controllers/georgia/api/media_controller.rb +4 -2
- data/app/controllers/georgia/api/tags_controller.rb +10 -7
- data/app/controllers/georgia/application_controller.rb +17 -2
- data/app/controllers/georgia/concerns/frontendable.rb +2 -3
- data/app/controllers/georgia/dashboard_controller.rb +5 -7
- data/app/controllers/georgia/links_controller.rb +1 -0
- data/app/controllers/georgia/media_controller.rb +50 -41
- data/app/controllers/georgia/menus_controller.rb +16 -6
- data/app/controllers/georgia/pages_controller.rb +98 -58
- data/app/controllers/georgia/revisions_controller.rb +120 -24
- data/app/controllers/georgia/ui_associations_controller.rb +1 -0
- data/app/controllers/georgia/users_controller.rb +31 -11
- data/app/controllers/georgia/widgets_controller.rb +13 -4
- data/app/helpers/georgia/application_helper.rb +4 -0
- data/app/helpers/georgia/forms_helper.rb +2 -2
- data/app/helpers/georgia/ui_helper.rb +78 -12
- data/app/helpers/georgia/users_helper.rb +21 -0
- data/app/mailers/georgia/notifier.rb +4 -4
- data/app/models/ckeditor/asset.rb +16 -4
- data/app/models/ckeditor/asset_search.rb +15 -0
- data/app/models/ckeditor/attachment_file.rb +7 -0
- data/app/models/ckeditor/picture.rb +10 -0
- data/app/models/georgia/clone.rb +3 -1
- data/app/models/georgia/concerns/contentable.rb +2 -3
- data/app/models/georgia/concerns/searchable.rb +32 -0
- data/app/models/georgia/concerns/taggable.rb +2 -2
- data/app/models/georgia/concerns/treeable.rb +0 -1
- data/app/models/georgia/content.rb +1 -3
- data/app/models/georgia/dashboard.rb +7 -0
- data/app/models/georgia/link.rb +10 -3
- data/app/models/georgia/menu.rb +4 -4
- data/app/models/georgia/page.rb +75 -10
- data/app/models/georgia/revision.rb +10 -5
- data/app/models/georgia/role.rb +5 -5
- data/app/models/georgia/role_assignment.rb +8 -0
- data/app/models/georgia/slide.rb +4 -4
- data/app/models/georgia/status.rb +3 -5
- data/app/models/georgia/ui_association.rb +3 -5
- data/app/models/georgia/ui_section.rb +1 -1
- data/app/models/georgia/user.rb +5 -14
- data/app/models/georgia/widget.rb +3 -3
- data/app/policies/georgia/api_policy.rb +13 -0
- data/app/policies/georgia/application_policy.rb +30 -0
- data/app/policies/georgia/concerns/content_policy.rb +56 -0
- data/app/policies/georgia/concerns/publishing_policy.rb +52 -0
- data/app/policies/georgia/dashboard_policy.rb +19 -0
- data/app/policies/georgia/media_policy.rb +56 -0
- data/app/policies/georgia/navigation_policy.rb +42 -0
- data/app/policies/georgia/page_policy.rb +26 -0
- data/app/policies/georgia/revision_policy.rb +7 -44
- data/app/policies/georgia/ui_association_policy.rb +4 -0
- data/app/policies/georgia/user_policy.rb +46 -0
- data/app/policies/georgia/widget_policy.rb +42 -0
- data/app/presenters/georgia/active_facet_presenter.rb +2 -1
- data/app/presenters/georgia/link_portlet.rb +2 -2
- data/app/presenters/georgia/pagination_presenter.rb +45 -7
- data/app/presenters/georgia/permission_table_presenter.rb +80 -0
- data/app/presenters/georgia/revision_status_message.rb +73 -0
- data/app/presenters/georgia/sidebar_link_presenter.rb +1 -1
- data/app/presenters/georgia/slide_portlet.rb +5 -1
- data/app/routes/georgia/pageable_route_concern.rb +35 -0
- data/app/searches/georgia/media_search.rb +39 -0
- data/app/searches/georgia/page_search.rb +47 -0
- data/app/searches/georgia/search_definition.rb +72 -0
- data/app/searches/georgia/tag_search.rb +32 -0
- data/app/services/georgia/clone_revision.rb +71 -0
- data/app/services/georgia/compress_files.rb +49 -0
- data/app/services/georgia/copy_page.rb +100 -0
- data/app/services/georgia/create_activity.rb +16 -0
- data/app/services/georgia/create_media_asset.rb +53 -0
- data/app/services/georgia/parse_json_tags.rb +21 -0
- data/app/services/georgia/update_revision.rb +52 -0
- data/app/views/georgia/api/media/pictures.html.erb +1 -1
- data/app/views/georgia/ckeditor/assets/_asset.html.erb +2 -4
- data/app/views/georgia/ckeditor/pictures/_picture.html.erb +1 -6
- data/app/views/georgia/dashboard/panels/_messages.html.erb +26 -28
- data/app/views/georgia/dashboard/panels/_reviews.html.erb +23 -22
- data/app/views/georgia/dashboard/show.html.erb +9 -3
- data/app/views/georgia/header/_media.html.erb +2 -2
- data/app/views/georgia/header/_navigation.html.erb +3 -3
- data/app/views/georgia/header/_pages.html.erb +3 -3
- data/app/views/georgia/header/_users.html.erb +2 -2
- data/app/views/georgia/header/_widgets.html.erb +1 -1
- data/app/views/georgia/media/_header.html.erb +4 -2
- data/app/views/georgia/media/create.js.erb +1 -0
- data/app/views/georgia/media/destroy.js.erb +3 -0
- data/app/views/georgia/media/edit.html.erb +35 -30
- data/app/views/georgia/media/search.html.erb +2 -2
- data/app/views/georgia/menus/index.html.erb +1 -1
- data/app/views/georgia/pages/_header.html.erb +4 -4
- data/app/views/georgia/pages/_page.html.erb +1 -1
- data/app/views/georgia/pages/search.html.erb +4 -5
- data/app/views/georgia/pages/settings.html.erb +72 -61
- data/app/views/georgia/revisions/_revision.html.erb +12 -7
- data/app/views/georgia/revisions/edit.html.erb +17 -11
- data/app/views/georgia/revisions/fields/_content.html.erb +1 -2
- data/app/views/georgia/revisions/fields/_message.html.erb +11 -0
- data/app/views/georgia/revisions/fields/_ui_section.html.erb +1 -1
- data/app/views/georgia/revisions/fields/_widgets.html.erb +1 -1
- data/app/views/georgia/revisions/index.html.erb +2 -2
- data/app/views/georgia/revisions/messages/_awaiting_review.html.erb +15 -0
- data/app/views/georgia/revisions/messages/_continue_draft.html.erb +8 -0
- data/app/views/georgia/revisions/messages/_edit_current_revision.html.erb +12 -0
- data/app/views/georgia/revisions/messages/_insufficient_rights.html.erb +6 -0
- data/app/views/georgia/revisions/messages/_request_review.html.erb +7 -0
- data/app/views/georgia/revisions/messages/_review.html.erb +7 -0
- data/app/views/georgia/revisions/messages/_start_draft.html.erb +4 -0
- data/app/views/georgia/revisions/panels/_actions.html.erb +7 -0
- data/app/views/georgia/revisions/panels/_activities.html.erb +6 -0
- data/app/views/georgia/revisions/panels/_drafts.html.erb +28 -0
- data/app/views/georgia/revisions/panels/_info.html.erb +39 -0
- data/app/views/georgia/shared/modals/_media_library.html.erb +3 -1
- data/app/views/georgia/shared/search/_messages.html.erb +1 -1
- data/app/views/georgia/users/_form.html.erb +17 -2
- data/app/views/georgia/users/_user.html.erb +1 -1
- data/app/views/georgia/users/edit.html.erb +0 -1
- data/app/views/georgia/users/index.html.erb +1 -1
- data/app/views/georgia/users/permissions.html.erb +15 -0
- data/app/views/georgia/users/sessions/new.html.erb +3 -3
- data/app/views/layouts/georgia/_footer.html.erb +1 -3
- data/app/views/layouts/georgia/_head.html.erb +3 -4
- data/app/views/layouts/georgia/_header.html.erb +8 -10
- data/app/views/public_activity/_default.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_copy.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_create.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_decline.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_publish.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_unpublish.html.erb +15 -0
- data/app/views/public_activity/georgia_page/_update.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_approve.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_decline.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_draft.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_restore.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_review.html.erb +15 -0
- data/app/views/public_activity/georgia_revision/_update.html.erb +15 -0
- data/config/initializers/acts_as_taggable_on.rb +13 -12
- data/config/initializers/ckeditor.rb +36 -16
- data/config/initializers/devise.rb +17 -15
- data/config/initializers/elasticsearch.rb +44 -0
- data/config/initializers/inflections.rb +1 -1
- data/config/routes.rb +13 -36
- data/db/migrate/001_create_ckeditor_assets.rb +6 -5
- data/db/migrate/002_create_georgia_contents.rb +2 -4
- data/db/migrate/008_create_georgia_roles.rb +0 -2
- data/db/migrate/015_add_receives_notifications_to_users.rb +7 -0
- data/db/migrate/016_add_role_id_to_users.rb +7 -0
- data/db/migrate/017_add_status_to_revisions.rb +7 -0
- data/db/migrate/018_create_georgia_role_assignments.rb +11 -0
- data/db/migrate/019_create_activities.rb +23 -0
- data/db/migrate/020_remove_georgia_revisions_state.rb +11 -0
- data/db/migrate/021_add_revised_by_id_to_georgia_revisions.rb +13 -0
- data/lib/generators/georgia/install/install_generator.rb +3 -29
- data/lib/generators/georgia/install/templates/app/controllers/pages_controller.rb +1 -1
- data/lib/generators/georgia/install/templates/config/initializers/georgia.rb +3 -7
- data/lib/generators/georgia/setup/setup_generator.rb +29 -0
- data/lib/georgia.rb +26 -9
- data/lib/georgia/engine.rb +6 -25
- data/lib/georgia/permissions.rb +57 -0
- data/lib/georgia/uploader/adapter.rb +4 -1
- data/lib/georgia/uploader/storage/file.rb +23 -0
- data/lib/georgia/version.rb +1 -1
- data/lib/tasks/georgia_tasks.rake +99 -0
- metadata +463 -461
- data/app/assets/fonts/georgia/signika-bold-webfont.eot +0 -0
- data/app/assets/fonts/georgia/signika-bold-webfont.svg +0 -1711
- data/app/assets/fonts/georgia/signika-bold-webfont.ttf +0 -0
- data/app/assets/fonts/georgia/signika-bold-webfont.woff +0 -0
- data/app/assets/fonts/georgia/signika-light-webfont.eot +0 -0
- data/app/assets/fonts/georgia/signika-light-webfont.svg +0 -1680
- data/app/assets/fonts/georgia/signika-light-webfont.ttf +0 -0
- data/app/assets/fonts/georgia/signika-light-webfont.woff +0 -0
- data/app/assets/fonts/georgia/signika-regular-webfont.eot +0 -0
- data/app/assets/fonts/georgia/signika-regular-webfont.svg +0 -1746
- data/app/assets/fonts/georgia/signika-regular-webfont.ttf +0 -0
- data/app/assets/fonts/georgia/signika-regular-webfont.woff +0 -0
- data/app/assets/images/georgia/bg-body-bar.jpg +0 -0
- data/app/assets/images/georgia/content-types/avi.jpg +0 -0
- data/app/assets/images/georgia/content-types/css.jpg +0 -0
- data/app/assets/images/georgia/content-types/csv.jpg +0 -0
- data/app/assets/images/georgia/content-types/doc.jpg +0 -0
- data/app/assets/images/georgia/content-types/docx.jpg +0 -0
- data/app/assets/images/georgia/content-types/eps.jpg +0 -0
- data/app/assets/images/georgia/content-types/gif.jpg +0 -0
- data/app/assets/images/georgia/content-types/gz.jpg +0 -0
- data/app/assets/images/georgia/content-types/html.jpg +0 -0
- data/app/assets/images/georgia/content-types/jpeg.jpg +0 -0
- data/app/assets/images/georgia/content-types/jpg.jpg +0 -0
- data/app/assets/images/georgia/content-types/mp3.jpg +0 -0
- data/app/assets/images/georgia/content-types/ods.jpg +0 -0
- data/app/assets/images/georgia/content-types/odt.jpg +0 -0
- data/app/assets/images/georgia/content-types/pdf.jpg +0 -0
- data/app/assets/images/georgia/content-types/png.jpg +0 -0
- data/app/assets/images/georgia/content-types/ppt.jpg +0 -0
- data/app/assets/images/georgia/content-types/pptx.jpg +0 -0
- data/app/assets/images/georgia/content-types/rar.jpg +0 -0
- data/app/assets/images/georgia/content-types/tar.jpg +0 -0
- data/app/assets/images/georgia/content-types/txt.jpg +0 -0
- data/app/assets/images/georgia/content-types/wav.jpg +0 -0
- data/app/assets/images/georgia/content-types/xls.jpg +0 -0
- data/app/assets/images/georgia/content-types/zip.jpg +0 -0
- data/app/assets/images/georgia/down_arrow.gif +0 -0
- data/app/assets/images/georgia/grippy_large.png +0 -0
- data/app/assets/images/georgia/logo.png +0 -0
- data/app/assets/images/georgia/up_arrow.gif +0 -0
- data/app/assets/javascripts/georgia/keybindings.js.coffee +0 -42
- data/app/assets/stylesheets/georgia/components/_state.scss +0 -17
- data/app/assets/stylesheets/georgia/settings/_fonts.scss +0 -3
- data/app/decorators/georgia/link_decorator.rb +0 -9
- data/app/decorators/georgia/links_decorator.rb +0 -4
- data/app/helpers/georgia/internationalization_helper.rb +0 -45
- data/app/helpers/georgia/menus_helper.rb +0 -20
- data/app/helpers/georgia/meta_tags_helper.rb +0 -22
- data/app/helpers/georgia/pages_helper.rb +0 -30
- data/app/helpers/georgia/routes_helper.rb +0 -25
- data/app/helpers/georgia/twitter_helper.rb +0 -24
- data/app/models/ability.rb +0 -19
- data/app/models/acts_as_taggable_on/tag.rb +0 -5
- data/app/models/georgia/concerns/cacheable.rb +0 -18
- data/app/models/georgia/concerns/orderable.rb +0 -21
- data/app/models/georgia/concerns/publishable.rb +0 -35
- data/app/models/georgia/concerns/revisionable.rb +0 -38
- data/app/models/georgia/concerns/slugable.rb +0 -48
- data/app/models/georgia/concerns/statable.rb +0 -64
- data/app/models/georgia/concerns/templatable.rb +0 -20
- data/app/policies/georgia/policy.rb +0 -17
- data/app/presenters/georgia/page_actions_presenter.rb +0 -92
- data/app/presenters/georgia/warning_message.rb +0 -55
- data/app/services/create_media_asset.rb +0 -51
- data/app/sweepers/navigation_sweeper.rb +0 -12
- data/app/views/georgia/media/sidebar/_facets.html.erb +0 -12
- data/app/views/menus/_dropdown_group.html.erb +0 -10
- data/app/views/menus/_dropdown_link.html.erb +0 -3
- data/app/views/menus/_dropdown_menu.html.erb +0 -11
- data/app/views/menus/_link.html.erb +0 -1
- data/app/views/menus/_menu.html.erb +0 -7
- data/config/initializers/simple_form.rb +0 -79
- data/config/locales/georgia.en.yml +0 -4
- data/lib/georgia/indexer.rb +0 -33
- data/lib/georgia/indexer/adapter.rb +0 -44
- data/lib/georgia/indexer/extensions/solr_adapter/acts_as_taggable_on/tag.rb +0 -30
- data/lib/georgia/indexer/extensions/solr_adapter/ckeditor/asset.rb +0 -46
- data/lib/georgia/indexer/extensions/solr_adapter/georgia/page.rb +0 -75
- data/lib/georgia/indexer/extensions/tire_adapter/acts_as_taggable_on/tag.rb +0 -34
- data/lib/georgia/indexer/extensions/tire_adapter/ckeditor/asset.rb +0 -57
- data/lib/georgia/indexer/extensions/tire_adapter/georgia/page.rb +0 -55
- data/lib/georgia/indexer/solr_adapter.rb +0 -20
- data/lib/georgia/indexer/tire_adapter.rb +0 -18
- data/lib/tasks/assets.rake +0 -20
- data/lib/tasks/georgia.rake +0 -65
- data/lib/tasks/sidekiq.rake +0 -8
- data/lib/tasks/solr.rake +0 -21
- data/lib/tasks/upgrade.rake +0 -39
- 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);
|