coalla-cms 0.4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +81 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +168 -0
- data/Rakefile +29 -0
- data/app/assets/fonts/glyphicons/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons/glyphicons-halflings-regular.svg +229 -0
- data/app/assets/fonts/glyphicons/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/images/blank.gif +0 -0
- data/app/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/admin/admin.js +295 -0
- data/app/assets/javascripts/admin/custom_admin.js +0 -0
- data/app/assets/javascripts/admin/jquery-migrate.min.js +2 -0
- data/app/assets/javascripts/admin/photo_uploader.js +67 -0
- data/app/assets/javascripts/admin/vendor/bootstrap.min.js +7 -0
- data/app/assets/javascripts/admin/vendor/jquery-ui-timepicker-addon-ru.js +40 -0
- data/app/assets/javascripts/admin/vendor/jquery.tagsinput.js +365 -0
- data/app/assets/javascripts/admin/vendor/jquery.tokeninput.patched.js +875 -0
- data/app/assets/javascripts/admin/vendor/underscore-min.js +5 -0
- data/app/assets/javascripts/ckeditor/plugins/autogrow/plugin.js +209 -0
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/icons/hidpi/mediaembed.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/icons/mediaembed.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/mediaembed/plugin.js +64 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/LICENSE.txt +303 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad-gallery-css-diff.htm +831 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_next.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_prev.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_scroll_back.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_scroll_forward.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.css +185 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.js +984 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.min - ref.js +10 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.min.js +1 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/loader.gif +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/opa75.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/placeholder.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/ad-gallery/trans.gif +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/blank.gif +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_loading.gif +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_loading@2x.gif +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_overlay.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_sprite.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_sprite@2x.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/fancybox_buttons.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-buttons.css +97 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-buttons.js +122 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-media.js +199 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-thumbs.css +55 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-thumbs.js +162 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.css +274 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.js +2020 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.pack.js +46 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/README.md +66 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/dialogs/slideshow.js +1396 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/dialogs/slideshow.min.js +1 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/icons/placeholder.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/icons/slideshow.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/Serbian_translation.txt +9 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/el.js +37 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/en.js +35 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/fr.js +35 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/ru.js +35 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/sr-latn.js +35 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/lang/sr.js +35 -0
- data/app/assets/javascripts/ckeditor/plugins/slideshow/plugin.js +217 -0
- data/app/assets/stylesheets/admin/admin.scss +302 -0
- data/app/assets/stylesheets/admin/custom_admin.scss +1 -0
- data/app/assets/stylesheets/admin/vendor/bootstrap.min.css +14 -0
- data/app/assets/stylesheets/admin/vendor/jquery.tagsinput.css +99 -0
- data/app/assets/stylesheets/admin/vendor/token-input-facebook.patched.css +126 -0
- data/app/assets/stylesheets/admin/vendor/token-input.patched.css +116 -0
- data/app/controllers/admin/autocomplete_controller.rb +14 -0
- data/app/controllers/admin/image_upload_controller.rb +27 -0
- data/app/controllers/admin/lookups_controller.rb +47 -0
- data/app/controllers/admin/sortable_controller.rb +26 -0
- data/app/controllers/concerns/admin/path_history.rb +39 -0
- data/app/helpers/admin/search_helper.rb +59 -0
- data/app/helpers/admin_helper.rb +29 -0
- data/app/helpers/common_helper.rb +16 -0
- data/app/helpers/lookup_helper.rb +45 -0
- data/app/helpers/nested_fields_helper.rb +12 -0
- data/app/helpers/static_text_formatter.rb +25 -0
- data/app/helpers/twitter_builder_helper.rb +253 -0
- data/app/helpers/twitter_form_builder.rb +196 -0
- data/app/models/file_upload.rb +19 -0
- data/app/models/lookup.rb +6 -0
- data/app/uploaders/file_uploader.rb +10 -0
- data/app/uploaders/generic_image_uploader.rb +74 -0
- data/app/utils/admin_structure.rb +67 -0
- data/app/utils/bootstrap_link_renderer.rb +40 -0
- data/app/utils/table_helpers.rb +196 -0
- data/app/views/admin/base/_sort.haml +34 -0
- data/app/views/admin/common/_file_upload_template.haml +14 -0
- data/app/views/admin/common/_header.html.haml +27 -0
- data/app/views/admin/common/_image_upload_template.html.haml +40 -0
- data/app/views/admin/common/_menu.html.haml +2 -0
- data/app/views/admin/common/_menu_section.haml +10 -0
- data/app/views/admin/common/_menu_separator.haml +1 -0
- data/app/views/admin/common/_nested_fields_for.html.haml +5 -0
- data/app/views/admin/common/_nested_fields_for_element.html.haml +5 -0
- data/app/views/admin/common/_slide.haml +41 -0
- data/app/views/admin/common/_slides.html.haml +17 -0
- data/app/views/admin/common/_table_template.html.haml +14 -0
- data/app/views/admin/common/_upload_form.html.haml +5 -0
- data/app/views/admin/common/image_uploaded.js.haml +7 -0
- data/app/views/admin/common/upload_failed.js.erb +11 -0
- data/app/views/admin/common/upload_image.js.erb +6 -0
- data/app/views/admin/home/dashboard.html.haml +5 -0
- data/app/views/admin/lookups/_form.html.haml +16 -0
- data/app/views/admin/lookups/edit.html.haml +5 -0
- data/app/views/admin/lookups/index.html.haml +6 -0
- data/app/views/layouts/admin.html.haml +38 -0
- data/app/views/structure/_section.haml +16 -0
- data/coalla-cms.gemspec +39 -0
- data/config/locales/devise.ru.yml +59 -0
- data/config/locales/will_paginate.ru.yml +6 -0
- data/lib/coalla/cms/engine.rb +16 -0
- data/lib/coalla/cms/version.rb +5 -0
- data/lib/coalla/ext/mapper.rb +14 -0
- data/lib/coalla/orm/page_slider.rb +53 -0
- data/lib/coalla/orm/relation.rb +32 -0
- data/lib/coalla/orm/sanitized.rb +16 -0
- data/lib/coalla/sanitize/config/default.rb +526 -0
- data/lib/coalla-cms.rb +16 -0
- data/lib/generators/coalla/cms/create_admin_generator.rb +50 -0
- data/lib/generators/coalla/cms/create_admin_login_view_generator.rb +23 -0
- data/lib/generators/coalla/cms/file_uploads/install_generator.rb +35 -0
- data/lib/generators/coalla/cms/file_uploads/mount_generator.rb +34 -0
- data/lib/generators/coalla/cms/file_uploads/templates/add_column_migration.rb.erb +5 -0
- data/lib/generators/coalla/cms/file_uploads/templates/migration.rb +17 -0
- data/lib/generators/coalla/cms/image/install_generator.rb +39 -0
- data/lib/generators/coalla/cms/image/mount_generator.rb +50 -0
- data/lib/generators/coalla/cms/image/templates/migration.rb.erb +9 -0
- data/lib/generators/coalla/cms/image/templates/model.rb.erb +5 -0
- data/lib/generators/coalla/cms/image/templates/mount/migration.rb.erb +6 -0
- data/lib/generators/coalla/cms/image/templates/mount/uploader.rb.erb +3 -0
- data/lib/generators/coalla/cms/image/templates/uploader.rb.erb +3 -0
- data/lib/generators/coalla/cms/init_generator.rb +113 -0
- data/lib/generators/coalla/cms/lookups/install_generator.rb +43 -0
- data/lib/generators/coalla/cms/lookups/templates/migration.rb +13 -0
- data/lib/generators/coalla/cms/market/install_generator.rb +71 -0
- data/lib/generators/coalla/cms/market/templates/controllers/categories_controller.rb +47 -0
- data/lib/generators/coalla/cms/market/templates/controllers/products_controller.rb +50 -0
- data/lib/generators/coalla/cms/market/templates/controllers/properties_controller.rb +59 -0
- data/lib/generators/coalla/cms/market/templates/market.rb +5 -0
- data/lib/generators/coalla/cms/market/templates/market.ru.yml +53 -0
- data/lib/generators/coalla/cms/market/templates/migrations/create_categories.rb +15 -0
- data/lib/generators/coalla/cms/market/templates/migrations/create_product_properties.rb +18 -0
- data/lib/generators/coalla/cms/market/templates/migrations/create_products.rb +18 -0
- data/lib/generators/coalla/cms/market/templates/migrations/create_properties.rb +11 -0
- data/lib/generators/coalla/cms/market/templates/models/category.rb +36 -0
- data/lib/generators/coalla/cms/market/templates/models/product.rb +16 -0
- data/lib/generators/coalla/cms/market/templates/models/product_property.rb +14 -0
- data/lib/generators/coalla/cms/market/templates/models/property.rb +7 -0
- data/lib/generators/coalla/cms/market/templates/views/categories/_form.html.haml +10 -0
- data/lib/generators/coalla/cms/market/templates/views/categories/edit.html.haml +5 -0
- data/lib/generators/coalla/cms/market/templates/views/categories/index.html.haml +17 -0
- data/lib/generators/coalla/cms/market/templates/views/categories/new.html.haml +4 -0
- data/lib/generators/coalla/cms/market/templates/views/products/_form.html.haml +17 -0
- data/lib/generators/coalla/cms/market/templates/views/products/_product_property_fields.html.haml +13 -0
- data/lib/generators/coalla/cms/market/templates/views/products/edit.html.haml +5 -0
- data/lib/generators/coalla/cms/market/templates/views/products/index.html.haml +17 -0
- data/lib/generators/coalla/cms/market/templates/views/products/new.html.haml +4 -0
- data/lib/generators/coalla/cms/market/templates/views/properties/_form.html.haml +9 -0
- data/lib/generators/coalla/cms/market/templates/views/properties/edit.html.haml +5 -0
- data/lib/generators/coalla/cms/market/templates/views/properties/index.html.haml +15 -0
- data/lib/generators/coalla/cms/market/templates/views/properties/new.html.haml +4 -0
- data/lib/generators/coalla/cms/news/scaffold_generator.rb +50 -0
- data/lib/generators/coalla/cms/news/templates/entity.rb.erb +10 -0
- data/lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb +47 -0
- data/lib/generators/coalla/cms/news/templates/entity_image_uploader.rb.erb +7 -0
- data/lib/generators/coalla/cms/news/templates/migration.rb.erb +15 -0
- data/lib/generators/coalla/cms/news/templates/views/_form.haml.erb +16 -0
- data/lib/generators/coalla/cms/news/templates/views/edit.haml.erb +5 -0
- data/lib/generators/coalla/cms/news/templates/views/index.haml.erb +18 -0
- data/lib/generators/coalla/cms/news/templates/views/new.haml.erb +5 -0
- data/lib/generators/coalla/cms/orm_helpers.rb +31 -0
- data/lib/generators/coalla/cms/scaffold_generator.rb +53 -0
- data/lib/generators/coalla/cms/scaffold_helper.rb +11 -0
- data/lib/generators/coalla/cms/setup_admin_generator.rb +60 -0
- data/lib/generators/coalla/cms/setup_routes_generator.rb +28 -0
- data/lib/generators/coalla/cms/slider/init_generator.rb +41 -0
- data/lib/generators/coalla/cms/slider/templates/migration.rb.erb +25 -0
- data/lib/generators/coalla/cms/slider/templates/slider_image.rb.erb +10 -0
- data/lib/generators/coalla/cms/slider/templates/slider_image_uploader.rb.erb +7 -0
- data/lib/generators/coalla/cms/slider/templates/slider_upload_controller.rb.erb +19 -0
- data/lib/generators/coalla/cms/templates/.gitattributes +4 -0
- data/lib/generators/coalla/cms/templates/.gitignore +86 -0
- data/lib/generators/coalla/cms/templates/activerecord.ru.yml +13 -0
- data/lib/generators/coalla/cms/templates/assets.rb +13 -0
- data/lib/generators/coalla/cms/templates/controllers/admin/base_controller.rb.erb +35 -0
- data/lib/generators/coalla/cms/templates/controllers/admin/home_controller.rb.erb +6 -0
- data/lib/generators/coalla/cms/templates/controllers/admin/scaffold_controller_template.rb.erb +45 -0
- data/lib/generators/coalla/cms/templates/controllers/home_controller.rb.erb +6 -0
- data/lib/generators/coalla/cms/templates/database.yml.erb +35 -0
- data/lib/generators/coalla/cms/templates/devise.ru.yml +59 -0
- data/lib/generators/coalla/cms/templates/initializers/carrierwave.rb +51 -0
- data/lib/generators/coalla/cms/templates/migration.rb +11 -0
- data/lib/generators/coalla/cms/templates/migration_existing.rb +15 -0
- data/lib/generators/coalla/cms/templates/schedule.rb +3 -0
- data/lib/generators/coalla/cms/templates/structure.rb +0 -0
- data/lib/generators/coalla/cms/templates/views/admin/scaffold_template/_form.html.haml.erb +14 -0
- data/lib/generators/coalla/cms/templates/views/admin/scaffold_template/edit.html.haml.erb +5 -0
- data/lib/generators/coalla/cms/templates/views/admin/scaffold_template/index.html.haml.erb +15 -0
- data/lib/generators/coalla/cms/templates/views/admin/scaffold_template/new.html.haml.erb +4 -0
- data/lib/generators/coalla/cms/templates/views/administrators/sessions/new.html.haml +19 -0
- data/lib/generators/coalla/cms/templates/views/home/index.html.haml.erb +1 -0
- data/lib/generators/coalla/cms/wysiwyg/ckeditor_generator.rb +17 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/mediaembed/icons/hidpi/mediaembed.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/mediaembed/icons/mediaembed.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/mediaembed/plugin.js +64 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/LICENSE.txt +303 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad-gallery-css-diff.htm +831 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_next.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_prev.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_scroll_back.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/ad_scroll_forward.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.css +185 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.js +984 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.min - ref.js +10 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/jquery.ad-gallery.min.js +1 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/loader.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/opa75.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/placeholder.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/ad-gallery/trans.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/blank.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_loading.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_loading@2x.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_overlay.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_sprite.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/fancybox_sprite@2x.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/fancybox_buttons.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-buttons.css +97 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-buttons.js +122 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-media.js +199 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-thumbs.css +55 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/helpers/jquery.fancybox-thumbs.js +162 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.css +274 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.js +2020 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/3rdParty/fancybox2/jquery.fancybox.pack.js +46 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/README.md +66 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/dialogs/slideshow.js +1396 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/dialogs/slideshow.min.js +1 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/icons/placeholder.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/icons/slideshow.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/Serbian_translation.txt +9 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/el.js +37 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/en.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/fr.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/ru.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/sr-latn.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/lang/sr.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/ckeditor/plugins/slideshow/plugin.js +217 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-blockquote.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h1.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h2.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h3.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h4.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h5.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-h6.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-p.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/lbl-pre.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/wymiframe.css +276 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/iframe/default/wymiframe.html +26 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/jquery.wymeditor.js +4819 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/lang/en.js +45 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/lang/ru.js +55 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/plugins/imageupload/icons.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/plugins/imageupload/jquery.wymeditor.imageupload.js +150 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js +91 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/plugins/resizable/readme.txt +124 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/compact/icons.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/compact/skin.css +134 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/compact/skin.js +35 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/default/icons.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/default/skin.css +341 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/default/skin.js +40 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/images/bg.header.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/images/bg.selector.silver.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/images/bg.wymeditor.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/images/icons.silver.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/skin.css +131 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/minimal/skin.js +30 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/COPYING +674 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/README +27 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/images/bg.header.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/images/bg.selector.silver.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/images/bg.wymeditor.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/images/icons.silver.gif +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/skin.css +297 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/silver/skin.js +61 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/twopanels/icons.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/twopanels/skin.css +134 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/twopanels/skin.js +39 -0
- data/lib/generators/coalla/cms/wysiwyg/templates/wymeditor/skins/wymeditor_icon.png +0 -0
- data/lib/generators/coalla/cms/wysiwyg/wymeditor_generator.rb +17 -0
- metadata +581 -0
@@ -0,0 +1,875 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Plugin: Tokenizing Autocomplete Text Entry
|
3
|
+
* Version 1.6.0
|
4
|
+
*
|
5
|
+
* Copyright (c) 2009 James Smith (http://loopj.com)
|
6
|
+
* Licensed jointly under the GPL and MIT licenses,
|
7
|
+
* choose which one suits your project best!
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function ($) {
|
12
|
+
// Default settings
|
13
|
+
var DEFAULT_SETTINGS = {
|
14
|
+
// Search settings
|
15
|
+
method: "GET",
|
16
|
+
contentType: "json",
|
17
|
+
queryParam: "q",
|
18
|
+
searchDelay: 300,
|
19
|
+
minChars: 1,
|
20
|
+
propertyToSearch: "name",
|
21
|
+
jsonContainer: null,
|
22
|
+
|
23
|
+
// Display settings
|
24
|
+
hintText: "Type in a search term",
|
25
|
+
noResultsText: "No results",
|
26
|
+
searchingText: "Searching...",
|
27
|
+
deleteText: "×",
|
28
|
+
animateDropdown: true,
|
29
|
+
|
30
|
+
// Tokenization settings
|
31
|
+
tokenLimit: null,
|
32
|
+
tokenDelimiter: ",",
|
33
|
+
preventDuplicates: false,
|
34
|
+
|
35
|
+
// Output settings
|
36
|
+
tokenValue: "id",
|
37
|
+
|
38
|
+
// Prepopulation settings
|
39
|
+
prePopulate: null,
|
40
|
+
processPrePopulate: false,
|
41
|
+
|
42
|
+
//Coalla patch
|
43
|
+
showAllOnFocus: false,
|
44
|
+
useCache: true,
|
45
|
+
|
46
|
+
// Manipulation settings
|
47
|
+
idPrefix: "token-input-",
|
48
|
+
|
49
|
+
// Formatters
|
50
|
+
resultsFormatter: function(item){ return "<li>" + item[this.propertyToSearch]+ "</li>" },
|
51
|
+
tokenFormatter: function(item) { return "<li><p>" + item[this.propertyToSearch] + "</p></li>" },
|
52
|
+
|
53
|
+
// Callbacks
|
54
|
+
onResult: null,
|
55
|
+
onAdd: null,
|
56
|
+
onDelete: null,
|
57
|
+
onReady: null
|
58
|
+
};
|
59
|
+
|
60
|
+
// Default classes to use when theming
|
61
|
+
var DEFAULT_CLASSES = {
|
62
|
+
tokenList: "token-input-list",
|
63
|
+
token: "token-input-token",
|
64
|
+
tokenDelete: "token-input-delete-token",
|
65
|
+
selectedToken: "token-input-selected-token",
|
66
|
+
highlightedToken: "token-input-highlighted-token",
|
67
|
+
dropdown: "token-input-dropdown",
|
68
|
+
dropdownItem: "token-input-dropdown-item",
|
69
|
+
dropdownItem2: "token-input-dropdown-item2",
|
70
|
+
selectedDropdownItem: "token-input-selected-dropdown-item",
|
71
|
+
inputToken: "token-input-input-token"
|
72
|
+
};
|
73
|
+
|
74
|
+
// Input box position "enum"
|
75
|
+
var POSITION = {
|
76
|
+
BEFORE: 0,
|
77
|
+
AFTER: 1,
|
78
|
+
END: 2
|
79
|
+
};
|
80
|
+
|
81
|
+
// Keys "enum"
|
82
|
+
var KEY = {
|
83
|
+
BACKSPACE: 8,
|
84
|
+
TAB: 9,
|
85
|
+
ENTER: 13,
|
86
|
+
ESCAPE: 27,
|
87
|
+
SPACE: 32,
|
88
|
+
PAGE_UP: 33,
|
89
|
+
PAGE_DOWN: 34,
|
90
|
+
END: 35,
|
91
|
+
HOME: 36,
|
92
|
+
LEFT: 37,
|
93
|
+
UP: 38,
|
94
|
+
RIGHT: 39,
|
95
|
+
DOWN: 40,
|
96
|
+
NUMPAD_ENTER: 108,
|
97
|
+
COMMA: 188
|
98
|
+
};
|
99
|
+
|
100
|
+
// Additional public (exposed) methods
|
101
|
+
var methods = {
|
102
|
+
init: function(url_or_data_or_function, options) {
|
103
|
+
var settings = $.extend({}, DEFAULT_SETTINGS, options || {});
|
104
|
+
|
105
|
+
return this.each(function () {
|
106
|
+
$(this).data("tokenInputObject", new $.TokenList(this, url_or_data_or_function, settings));
|
107
|
+
});
|
108
|
+
},
|
109
|
+
clear: function() {
|
110
|
+
this.data("tokenInputObject").clear();
|
111
|
+
return this;
|
112
|
+
},
|
113
|
+
add: function(item) {
|
114
|
+
this.data("tokenInputObject").add(item);
|
115
|
+
return this;
|
116
|
+
},
|
117
|
+
remove: function(item) {
|
118
|
+
this.data("tokenInputObject").remove(item);
|
119
|
+
return this;
|
120
|
+
},
|
121
|
+
get: function() {
|
122
|
+
return this.data("tokenInputObject").getTokens();
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
// Expose the .tokenInput function to jQuery as a plugin
|
127
|
+
$.fn.tokenInput = function (method) {
|
128
|
+
// Method calling and initialization logic
|
129
|
+
if(methods[method]) {
|
130
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
131
|
+
} else {
|
132
|
+
return methods.init.apply(this, arguments);
|
133
|
+
}
|
134
|
+
};
|
135
|
+
|
136
|
+
// TokenList class for each input
|
137
|
+
$.TokenList = function (input, url_or_data, settings) {
|
138
|
+
//
|
139
|
+
// Initialization
|
140
|
+
//
|
141
|
+
|
142
|
+
// Configure the data source
|
143
|
+
if($.type(url_or_data) === "string" || $.type(url_or_data) === "function") {
|
144
|
+
// Set the url to query against
|
145
|
+
settings.url = url_or_data;
|
146
|
+
|
147
|
+
// If the URL is a function, evaluate it here to do our initalization work
|
148
|
+
var url = computeURL();
|
149
|
+
|
150
|
+
// Make a smart guess about cross-domain if it wasn't explicitly specified
|
151
|
+
if(settings.crossDomain === undefined) {
|
152
|
+
if(url.indexOf("://") === -1) {
|
153
|
+
settings.crossDomain = false;
|
154
|
+
} else {
|
155
|
+
settings.crossDomain = (location.href.split(/\/+/g)[1] !== url.split(/\/+/g)[1]);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
} else if(typeof(url_or_data) === "object") {
|
159
|
+
// Set the local data to search through
|
160
|
+
settings.local_data = url_or_data;
|
161
|
+
}
|
162
|
+
|
163
|
+
// Build class names
|
164
|
+
if(settings.classes) {
|
165
|
+
// Use custom class names
|
166
|
+
settings.classes = $.extend({}, DEFAULT_CLASSES, settings.classes);
|
167
|
+
} else if(settings.theme) {
|
168
|
+
// Use theme-suffixed default class names
|
169
|
+
settings.classes = {};
|
170
|
+
$.each(DEFAULT_CLASSES, function(key, value) {
|
171
|
+
settings.classes[key] = value + "-" + settings.theme;
|
172
|
+
});
|
173
|
+
} else {
|
174
|
+
settings.classes = DEFAULT_CLASSES;
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
// Save the tokens
|
179
|
+
var saved_tokens = [];
|
180
|
+
|
181
|
+
// Keep track of the number of tokens in the list
|
182
|
+
var token_count = 0;
|
183
|
+
|
184
|
+
// Basic cache to save on db hits
|
185
|
+
var cache = new $.TokenList.Cache();
|
186
|
+
|
187
|
+
// Keep track of the timeout, old vals
|
188
|
+
var timeout;
|
189
|
+
var input_val;
|
190
|
+
|
191
|
+
// Create a new text input an attach keyup events
|
192
|
+
var input_box = $("<input type=\"text\" autocomplete=\"off\">")
|
193
|
+
.css({
|
194
|
+
outline: "none"
|
195
|
+
})
|
196
|
+
.attr("id", settings.idPrefix + input.id)
|
197
|
+
.focus(function () {
|
198
|
+
if (settings.tokenLimit === null || settings.tokenLimit !== token_count) {
|
199
|
+
//Coalla patch
|
200
|
+
if (settings.showAllOnFocus) {
|
201
|
+
run_search('');
|
202
|
+
} else {
|
203
|
+
show_dropdown_hint();
|
204
|
+
}
|
205
|
+
}
|
206
|
+
})
|
207
|
+
.blur(function () {
|
208
|
+
hide_dropdown();
|
209
|
+
$(this).val("");
|
210
|
+
})
|
211
|
+
.bind("keyup keydown blur update", resize_input)
|
212
|
+
.keydown(function (event) {
|
213
|
+
var previous_token;
|
214
|
+
var next_token;
|
215
|
+
|
216
|
+
switch(event.keyCode) {
|
217
|
+
case KEY.LEFT:
|
218
|
+
case KEY.RIGHT:
|
219
|
+
case KEY.UP:
|
220
|
+
case KEY.DOWN:
|
221
|
+
if(!$(this).val()) {
|
222
|
+
previous_token = input_token.prev();
|
223
|
+
next_token = input_token.next();
|
224
|
+
|
225
|
+
if((previous_token.length && previous_token.get(0) === selected_token) || (next_token.length && next_token.get(0) === selected_token)) {
|
226
|
+
// Check if there is a previous/next token and it is selected
|
227
|
+
if(event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) {
|
228
|
+
deselect_token($(selected_token), POSITION.BEFORE);
|
229
|
+
} else {
|
230
|
+
deselect_token($(selected_token), POSITION.AFTER);
|
231
|
+
}
|
232
|
+
} else if((event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) && previous_token.length) {
|
233
|
+
// We are moving left, select the previous token if it exists
|
234
|
+
select_token($(previous_token.get(0)));
|
235
|
+
} else if((event.keyCode === KEY.RIGHT || event.keyCode === KEY.DOWN) && next_token.length) {
|
236
|
+
// We are moving right, select the next token if it exists
|
237
|
+
select_token($(next_token.get(0)));
|
238
|
+
}
|
239
|
+
} else {
|
240
|
+
var dropdown_item = null;
|
241
|
+
|
242
|
+
if(event.keyCode === KEY.DOWN || event.keyCode === KEY.RIGHT) {
|
243
|
+
dropdown_item = $(selected_dropdown_item).next();
|
244
|
+
} else {
|
245
|
+
dropdown_item = $(selected_dropdown_item).prev();
|
246
|
+
}
|
247
|
+
|
248
|
+
if(dropdown_item.length) {
|
249
|
+
select_dropdown_item(dropdown_item);
|
250
|
+
}
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
break;
|
254
|
+
|
255
|
+
case KEY.BACKSPACE:
|
256
|
+
previous_token = input_token.prev();
|
257
|
+
|
258
|
+
if(!$(this).val().length) {
|
259
|
+
if(selected_token) {
|
260
|
+
delete_token($(selected_token));
|
261
|
+
hidden_input.change();
|
262
|
+
} else if(previous_token.length) {
|
263
|
+
select_token($(previous_token.get(0)));
|
264
|
+
}
|
265
|
+
|
266
|
+
return false;
|
267
|
+
} else if($(this).val().length === 1) {
|
268
|
+
hide_dropdown();
|
269
|
+
} else {
|
270
|
+
// set a timeout just long enough to let this function finish.
|
271
|
+
setTimeout(function(){do_search();}, 5);
|
272
|
+
}
|
273
|
+
break;
|
274
|
+
|
275
|
+
case KEY.TAB:
|
276
|
+
case KEY.ENTER:
|
277
|
+
case KEY.NUMPAD_ENTER:
|
278
|
+
// case KEY.COMMA: - Coalla patch, webkit интерпретирует букву 'б' как запятую
|
279
|
+
if(selected_dropdown_item) {
|
280
|
+
add_token($(selected_dropdown_item).data("tokeninput"));
|
281
|
+
hidden_input.change();
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
break;
|
285
|
+
|
286
|
+
case KEY.ESCAPE:
|
287
|
+
hide_dropdown();
|
288
|
+
return true;
|
289
|
+
|
290
|
+
default:
|
291
|
+
if(String.fromCharCode(event.which)) {
|
292
|
+
// set a timeout just long enough to let this function finish.
|
293
|
+
setTimeout(function(){do_search();}, 5);
|
294
|
+
}
|
295
|
+
break;
|
296
|
+
}
|
297
|
+
});
|
298
|
+
|
299
|
+
// Keep a reference to the original input box
|
300
|
+
var hidden_input = $(input)
|
301
|
+
.hide()
|
302
|
+
.val("")
|
303
|
+
.focus(function () {
|
304
|
+
input_box.focus();
|
305
|
+
})
|
306
|
+
.blur(function () {
|
307
|
+
input_box.blur();
|
308
|
+
});
|
309
|
+
|
310
|
+
// Keep a reference to the selected token and dropdown item
|
311
|
+
var selected_token = null;
|
312
|
+
var selected_token_index = 0;
|
313
|
+
var selected_dropdown_item = null;
|
314
|
+
|
315
|
+
// The list to store the token items in
|
316
|
+
var token_list = $("<ul />")
|
317
|
+
.addClass(settings.classes.tokenList)
|
318
|
+
.click(function (event) {
|
319
|
+
var li = $(event.target).closest("li");
|
320
|
+
if(li && li.get(0) && $.data(li.get(0), "tokeninput")) {
|
321
|
+
toggle_select_token(li);
|
322
|
+
} else {
|
323
|
+
// Deselect selected token
|
324
|
+
if(selected_token) {
|
325
|
+
deselect_token($(selected_token), POSITION.END);
|
326
|
+
}
|
327
|
+
|
328
|
+
// Focus input box
|
329
|
+
input_box.focus();
|
330
|
+
}
|
331
|
+
})
|
332
|
+
.mouseover(function (event) {
|
333
|
+
var li = $(event.target).closest("li");
|
334
|
+
if(li && selected_token !== this) {
|
335
|
+
li.addClass(settings.classes.highlightedToken);
|
336
|
+
}
|
337
|
+
})
|
338
|
+
.mouseout(function (event) {
|
339
|
+
var li = $(event.target).closest("li");
|
340
|
+
if(li && selected_token !== this) {
|
341
|
+
li.removeClass(settings.classes.highlightedToken);
|
342
|
+
}
|
343
|
+
})
|
344
|
+
.insertBefore(hidden_input);
|
345
|
+
|
346
|
+
// The token holding the input box
|
347
|
+
var input_token = $("<li />")
|
348
|
+
.addClass(settings.classes.inputToken)
|
349
|
+
.appendTo(token_list)
|
350
|
+
.append(input_box);
|
351
|
+
|
352
|
+
// The list to store the dropdown items in
|
353
|
+
var dropdown = $("<div>")
|
354
|
+
.addClass(settings.classes.dropdown)
|
355
|
+
.appendTo("body")
|
356
|
+
.hide();
|
357
|
+
|
358
|
+
// Magic element to help us resize the text input
|
359
|
+
var input_resizer = $("<tester/>")
|
360
|
+
.insertAfter(input_box)
|
361
|
+
.css({
|
362
|
+
position: "absolute",
|
363
|
+
top: -9999,
|
364
|
+
left: -9999,
|
365
|
+
width: "auto",
|
366
|
+
fontSize: input_box.css("fontSize"),
|
367
|
+
fontFamily: input_box.css("fontFamily"),
|
368
|
+
fontWeight: input_box.css("fontWeight"),
|
369
|
+
letterSpacing: input_box.css("letterSpacing"),
|
370
|
+
whiteSpace: "nowrap"
|
371
|
+
});
|
372
|
+
|
373
|
+
// Pre-populate list if items exist
|
374
|
+
hidden_input.val("");
|
375
|
+
var li_data = settings.prePopulate || hidden_input.data("pre");
|
376
|
+
if(settings.processPrePopulate && $.isFunction(settings.onResult)) {
|
377
|
+
li_data = settings.onResult.call(hidden_input, li_data);
|
378
|
+
}
|
379
|
+
if(li_data && li_data.length) {
|
380
|
+
$.each(li_data, function (index, value) {
|
381
|
+
insert_token(value);
|
382
|
+
checkTokenLimit();
|
383
|
+
});
|
384
|
+
}
|
385
|
+
|
386
|
+
// Initialization is done
|
387
|
+
if($.isFunction(settings.onReady)) {
|
388
|
+
settings.onReady.call();
|
389
|
+
}
|
390
|
+
|
391
|
+
//
|
392
|
+
// Public functions
|
393
|
+
//
|
394
|
+
|
395
|
+
this.clear = function() {
|
396
|
+
token_list.children("li").each(function() {
|
397
|
+
if ($(this).children("input").length === 0) {
|
398
|
+
delete_token($(this));
|
399
|
+
}
|
400
|
+
});
|
401
|
+
}
|
402
|
+
|
403
|
+
this.add = function(item) {
|
404
|
+
add_token(item);
|
405
|
+
}
|
406
|
+
|
407
|
+
this.remove = function(item) {
|
408
|
+
token_list.children("li").each(function() {
|
409
|
+
if ($(this).children("input").length === 0) {
|
410
|
+
var currToken = $(this).data("tokeninput");
|
411
|
+
var match = true;
|
412
|
+
for (var prop in item) {
|
413
|
+
if (item[prop] !== currToken[prop]) {
|
414
|
+
match = false;
|
415
|
+
break;
|
416
|
+
}
|
417
|
+
}
|
418
|
+
if (match) {
|
419
|
+
delete_token($(this));
|
420
|
+
}
|
421
|
+
}
|
422
|
+
});
|
423
|
+
}
|
424
|
+
|
425
|
+
this.getTokens = function() {
|
426
|
+
return saved_tokens;
|
427
|
+
}
|
428
|
+
|
429
|
+
//
|
430
|
+
// Private functions
|
431
|
+
//
|
432
|
+
|
433
|
+
function checkTokenLimit() {
|
434
|
+
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
|
435
|
+
input_box.hide();
|
436
|
+
hide_dropdown();
|
437
|
+
return;
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
function resize_input() {
|
442
|
+
if(input_val === (input_val = input_box.val())) {return;}
|
443
|
+
|
444
|
+
// Enter new content into resizer and resize input accordingly
|
445
|
+
var escaped = input_val.replace(/&/g, '&').replace(/\s/g,' ').replace(/</g, '<').replace(/>/g, '>');
|
446
|
+
input_resizer.html(escaped);
|
447
|
+
input_box.width(input_resizer.width() + 30);
|
448
|
+
}
|
449
|
+
|
450
|
+
function is_printable_character(keycode) {
|
451
|
+
return ((keycode >= 48 && keycode <= 90) || // 0-1a-z
|
452
|
+
(keycode >= 96 && keycode <= 111) || // numpad 0-9 + - / * .
|
453
|
+
(keycode >= 186 && keycode <= 192) || // ; = , - . / ^
|
454
|
+
(keycode >= 219 && keycode <= 222)); // ( \ ) '
|
455
|
+
}
|
456
|
+
|
457
|
+
// Inner function to a token to the list
|
458
|
+
function insert_token(item) {
|
459
|
+
var this_token = settings.tokenFormatter(item);
|
460
|
+
this_token = $(this_token)
|
461
|
+
.addClass(settings.classes.token)
|
462
|
+
.insertBefore(input_token);
|
463
|
+
|
464
|
+
// The 'delete token' button
|
465
|
+
$("<span>" + settings.deleteText + "</span>")
|
466
|
+
.addClass(settings.classes.tokenDelete)
|
467
|
+
.appendTo(this_token)
|
468
|
+
.click(function () {
|
469
|
+
delete_token($(this).parent());
|
470
|
+
hidden_input.change();
|
471
|
+
return false;
|
472
|
+
});
|
473
|
+
|
474
|
+
// Store data on the token
|
475
|
+
var token_data = {"id": item.id};
|
476
|
+
token_data[settings.propertyToSearch] = item[settings.propertyToSearch];
|
477
|
+
$.data(this_token.get(0), "tokeninput", item);
|
478
|
+
|
479
|
+
// Save this token for duplicate checking
|
480
|
+
saved_tokens = saved_tokens.slice(0,selected_token_index).concat([token_data]).concat(saved_tokens.slice(selected_token_index));
|
481
|
+
selected_token_index++;
|
482
|
+
|
483
|
+
// Update the hidden input
|
484
|
+
update_hidden_input(saved_tokens, hidden_input);
|
485
|
+
|
486
|
+
token_count += 1;
|
487
|
+
|
488
|
+
// Check the token limit
|
489
|
+
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
|
490
|
+
input_box.hide();
|
491
|
+
hide_dropdown();
|
492
|
+
}
|
493
|
+
|
494
|
+
return this_token;
|
495
|
+
}
|
496
|
+
|
497
|
+
// Add a token to the token list based on user input
|
498
|
+
function add_token (item) {
|
499
|
+
var callback = settings.onAdd;
|
500
|
+
|
501
|
+
// See if the token already exists and select it if we don't want duplicates
|
502
|
+
if(token_count > 0 && settings.preventDuplicates) {
|
503
|
+
var found_existing_token = null;
|
504
|
+
token_list.children().each(function () {
|
505
|
+
var existing_token = $(this);
|
506
|
+
var existing_data = $.data(existing_token.get(0), "tokeninput");
|
507
|
+
if(existing_data && existing_data.id === item.id) {
|
508
|
+
found_existing_token = existing_token;
|
509
|
+
return false;
|
510
|
+
}
|
511
|
+
});
|
512
|
+
|
513
|
+
if(found_existing_token) {
|
514
|
+
select_token(found_existing_token);
|
515
|
+
input_token.insertAfter(found_existing_token);
|
516
|
+
input_box.focus();
|
517
|
+
return;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
// Insert the new tokens
|
522
|
+
if(settings.tokenLimit == null || token_count < settings.tokenLimit) {
|
523
|
+
insert_token(item);
|
524
|
+
checkTokenLimit();
|
525
|
+
}
|
526
|
+
|
527
|
+
// Clear input box
|
528
|
+
input_box.val("");
|
529
|
+
|
530
|
+
// Don't show the help dropdown, they've got the idea
|
531
|
+
hide_dropdown();
|
532
|
+
|
533
|
+
// Execute the onAdd callback if defined
|
534
|
+
if($.isFunction(callback)) {
|
535
|
+
callback.call(hidden_input,item);
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
// Select a token in the token list
|
540
|
+
function select_token (token) {
|
541
|
+
token.addClass(settings.classes.selectedToken);
|
542
|
+
selected_token = token.get(0);
|
543
|
+
|
544
|
+
// Hide input box
|
545
|
+
input_box.val("");
|
546
|
+
|
547
|
+
// Hide dropdown if it is visible (eg if we clicked to select token)
|
548
|
+
hide_dropdown();
|
549
|
+
}
|
550
|
+
|
551
|
+
// Deselect a token in the token list
|
552
|
+
function deselect_token (token, position) {
|
553
|
+
token.removeClass(settings.classes.selectedToken);
|
554
|
+
selected_token = null;
|
555
|
+
|
556
|
+
if(position === POSITION.BEFORE) {
|
557
|
+
input_token.insertBefore(token);
|
558
|
+
selected_token_index--;
|
559
|
+
} else if(position === POSITION.AFTER) {
|
560
|
+
input_token.insertAfter(token);
|
561
|
+
selected_token_index++;
|
562
|
+
} else {
|
563
|
+
input_token.appendTo(token_list);
|
564
|
+
selected_token_index = token_count;
|
565
|
+
}
|
566
|
+
|
567
|
+
// Show the input box and give it focus again
|
568
|
+
input_box.focus();
|
569
|
+
}
|
570
|
+
|
571
|
+
// Toggle selection of a token in the token list
|
572
|
+
function toggle_select_token(token) {
|
573
|
+
var previous_selected_token = selected_token;
|
574
|
+
|
575
|
+
if(selected_token) {
|
576
|
+
deselect_token($(selected_token), POSITION.END);
|
577
|
+
}
|
578
|
+
|
579
|
+
if(previous_selected_token === token.get(0)) {
|
580
|
+
deselect_token(token, POSITION.END);
|
581
|
+
} else {
|
582
|
+
select_token(token);
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
586
|
+
// Delete a token from the token list
|
587
|
+
function delete_token (token) {
|
588
|
+
// Remove the id from the saved list
|
589
|
+
var token_data = $.data(token.get(0), "tokeninput");
|
590
|
+
var callback = settings.onDelete;
|
591
|
+
|
592
|
+
var index = token.prevAll().length;
|
593
|
+
if(index > selected_token_index) index--;
|
594
|
+
|
595
|
+
// Delete the token
|
596
|
+
token.remove();
|
597
|
+
selected_token = null;
|
598
|
+
|
599
|
+
// Show the input box and give it focus again
|
600
|
+
input_box.focus();
|
601
|
+
|
602
|
+
// Remove this token from the saved list
|
603
|
+
saved_tokens = saved_tokens.slice(0,index).concat(saved_tokens.slice(index+1));
|
604
|
+
if(index < selected_token_index) selected_token_index--;
|
605
|
+
|
606
|
+
// Update the hidden input
|
607
|
+
update_hidden_input(saved_tokens, hidden_input);
|
608
|
+
|
609
|
+
token_count -= 1;
|
610
|
+
|
611
|
+
if(settings.tokenLimit !== null) {
|
612
|
+
input_box
|
613
|
+
.show()
|
614
|
+
.val("")
|
615
|
+
.focus();
|
616
|
+
}
|
617
|
+
|
618
|
+
// Execute the onDelete callback if defined
|
619
|
+
if($.isFunction(callback)) {
|
620
|
+
callback.call(hidden_input,token_data);
|
621
|
+
}
|
622
|
+
}
|
623
|
+
|
624
|
+
// Update the hidden input box value
|
625
|
+
function update_hidden_input(saved_tokens, hidden_input) {
|
626
|
+
var token_values = $.map(saved_tokens, function (el) {
|
627
|
+
return el[settings.tokenValue];
|
628
|
+
});
|
629
|
+
hidden_input.val(token_values.join(settings.tokenDelimiter));
|
630
|
+
|
631
|
+
}
|
632
|
+
|
633
|
+
// Hide and clear the results dropdown
|
634
|
+
function hide_dropdown () {
|
635
|
+
dropdown.hide().empty();
|
636
|
+
selected_dropdown_item = null;
|
637
|
+
}
|
638
|
+
|
639
|
+
function show_dropdown() {
|
640
|
+
dropdown
|
641
|
+
.css({
|
642
|
+
position: "absolute",
|
643
|
+
top: $(token_list).offset().top + $(token_list).outerHeight(),
|
644
|
+
left: $(token_list).offset().left,
|
645
|
+
zindex: 999
|
646
|
+
})
|
647
|
+
.show();
|
648
|
+
}
|
649
|
+
|
650
|
+
function show_dropdown_searching () {
|
651
|
+
if(settings.searchingText) {
|
652
|
+
dropdown.html("<p>"+settings.searchingText+"</p>");
|
653
|
+
show_dropdown();
|
654
|
+
}
|
655
|
+
}
|
656
|
+
|
657
|
+
function show_dropdown_hint () {
|
658
|
+
if(settings.hintText) {
|
659
|
+
dropdown.html("<p>"+settings.hintText+"</p>");
|
660
|
+
show_dropdown();
|
661
|
+
}
|
662
|
+
}
|
663
|
+
|
664
|
+
// Highlight the query part of the search term
|
665
|
+
function highlight_term(value, term) {
|
666
|
+
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
|
667
|
+
}
|
668
|
+
|
669
|
+
var regexp_special_chars = new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]', 'g');
|
670
|
+
function regexp_escape(term) {
|
671
|
+
return term.replace(regexp_special_chars, '\\$&');
|
672
|
+
}
|
673
|
+
|
674
|
+
function find_value_and_highlight_term(template, value, term) {
|
675
|
+
return template.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + regexp_escape(value) + ")(?![^<>]*>)(?![^&;]+;)", "g"), highlight_term(value, term));
|
676
|
+
}
|
677
|
+
|
678
|
+
// Populate the results dropdown with some results
|
679
|
+
function populate_dropdown (query, results) {
|
680
|
+
if(results && results.length) {
|
681
|
+
dropdown.empty();
|
682
|
+
var dropdown_ul = $("<ul>")
|
683
|
+
.appendTo(dropdown)
|
684
|
+
.mouseover(function (event) {
|
685
|
+
select_dropdown_item($(event.target).closest("li"));
|
686
|
+
})
|
687
|
+
.mousedown(function (event) {
|
688
|
+
add_token($(event.target).closest("li").data("tokeninput"));
|
689
|
+
hidden_input.change();
|
690
|
+
return false;
|
691
|
+
})
|
692
|
+
.hide();
|
693
|
+
|
694
|
+
$.each(results, function(index, value) {
|
695
|
+
var this_li = settings.resultsFormatter(value);
|
696
|
+
|
697
|
+
this_li = find_value_and_highlight_term(this_li ,value[settings.propertyToSearch], query);
|
698
|
+
|
699
|
+
this_li = $(this_li).appendTo(dropdown_ul);
|
700
|
+
|
701
|
+
if(index % 2) {
|
702
|
+
this_li.addClass(settings.classes.dropdownItem);
|
703
|
+
} else {
|
704
|
+
this_li.addClass(settings.classes.dropdownItem2);
|
705
|
+
}
|
706
|
+
|
707
|
+
if(index === 0) {
|
708
|
+
select_dropdown_item(this_li);
|
709
|
+
}
|
710
|
+
|
711
|
+
$.data(this_li.get(0), "tokeninput", value);
|
712
|
+
});
|
713
|
+
|
714
|
+
show_dropdown();
|
715
|
+
|
716
|
+
if(settings.animateDropdown) {
|
717
|
+
dropdown_ul.slideDown("fast");
|
718
|
+
} else {
|
719
|
+
dropdown_ul.show();
|
720
|
+
}
|
721
|
+
} else {
|
722
|
+
if(settings.noResultsText) {
|
723
|
+
dropdown.html("<p>"+settings.noResultsText+"</p>");
|
724
|
+
show_dropdown();
|
725
|
+
}
|
726
|
+
}
|
727
|
+
}
|
728
|
+
|
729
|
+
// Highlight an item in the results dropdown
|
730
|
+
function select_dropdown_item (item) {
|
731
|
+
if(item) {
|
732
|
+
if(selected_dropdown_item) {
|
733
|
+
deselect_dropdown_item($(selected_dropdown_item));
|
734
|
+
}
|
735
|
+
|
736
|
+
item.addClass(settings.classes.selectedDropdownItem);
|
737
|
+
selected_dropdown_item = item.get(0);
|
738
|
+
}
|
739
|
+
}
|
740
|
+
|
741
|
+
// Remove highlighting from an item in the results dropdown
|
742
|
+
function deselect_dropdown_item (item) {
|
743
|
+
item.removeClass(settings.classes.selectedDropdownItem);
|
744
|
+
selected_dropdown_item = null;
|
745
|
+
}
|
746
|
+
|
747
|
+
// Do a search and show the "searching" dropdown if the input is longer
|
748
|
+
// than settings.minChars
|
749
|
+
function do_search() {
|
750
|
+
var query = input_box.val().toLowerCase();
|
751
|
+
|
752
|
+
if(query && query.length) {
|
753
|
+
if(selected_token) {
|
754
|
+
deselect_token($(selected_token), POSITION.AFTER);
|
755
|
+
}
|
756
|
+
|
757
|
+
if(query.length >= settings.minChars) {
|
758
|
+
show_dropdown_searching();
|
759
|
+
clearTimeout(timeout);
|
760
|
+
|
761
|
+
timeout = setTimeout(function(){
|
762
|
+
run_search(query);
|
763
|
+
}, settings.searchDelay);
|
764
|
+
} else {
|
765
|
+
hide_dropdown();
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
// Do the actual search
|
771
|
+
function run_search(query) {
|
772
|
+
var cache_key = query + computeURL();
|
773
|
+
var cached_results = cache.get(cache_key);
|
774
|
+
//Coalla patch
|
775
|
+
if(settings.useCache && cached_results) {
|
776
|
+
populate_dropdown(query, cached_results);
|
777
|
+
} else {
|
778
|
+
// Are we doing an ajax search or local data search?
|
779
|
+
if(settings.url) {
|
780
|
+
var url = computeURL();
|
781
|
+
// Extract exisiting get params
|
782
|
+
var ajax_params = {};
|
783
|
+
ajax_params.data = {};
|
784
|
+
if(url.indexOf("?") > -1) {
|
785
|
+
var parts = url.split("?");
|
786
|
+
ajax_params.url = parts[0];
|
787
|
+
|
788
|
+
var param_array = parts[1].split("&");
|
789
|
+
$.each(param_array, function (index, value) {
|
790
|
+
var kv = value.split("=");
|
791
|
+
ajax_params.data[kv[0]] = kv[1];
|
792
|
+
});
|
793
|
+
} else {
|
794
|
+
ajax_params.url = url;
|
795
|
+
}
|
796
|
+
|
797
|
+
// Prepare the request
|
798
|
+
ajax_params.data[settings.queryParam] = query;
|
799
|
+
ajax_params.type = settings.method;
|
800
|
+
ajax_params.dataType = settings.contentType;
|
801
|
+
if(settings.crossDomain) {
|
802
|
+
ajax_params.dataType = "jsonp";
|
803
|
+
}
|
804
|
+
|
805
|
+
// Attach the success callback
|
806
|
+
ajax_params.success = function(results) {
|
807
|
+
if($.isFunction(settings.onResult)) {
|
808
|
+
results = settings.onResult.call(hidden_input, results);
|
809
|
+
}
|
810
|
+
cache.add(cache_key, settings.jsonContainer ? results[settings.jsonContainer] : results);
|
811
|
+
|
812
|
+
// only populate the dropdown if the results are associated with the active search query
|
813
|
+
if(input_box.val().toLowerCase() === query) {
|
814
|
+
populate_dropdown(query, settings.jsonContainer ? results[settings.jsonContainer] : results);
|
815
|
+
}
|
816
|
+
};
|
817
|
+
|
818
|
+
// Make the request
|
819
|
+
$.ajax(ajax_params);
|
820
|
+
} else if(settings.local_data) {
|
821
|
+
// Do the search through local data
|
822
|
+
var results = $.grep(settings.local_data, function (row) {
|
823
|
+
return row[settings.propertyToSearch].toLowerCase().indexOf(query.toLowerCase()) > -1;
|
824
|
+
});
|
825
|
+
|
826
|
+
if($.isFunction(settings.onResult)) {
|
827
|
+
results = settings.onResult.call(hidden_input, results);
|
828
|
+
}
|
829
|
+
cache.add(cache_key, results);
|
830
|
+
populate_dropdown(query, results);
|
831
|
+
}
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
// compute the dynamic URL
|
836
|
+
function computeURL() {
|
837
|
+
var url = settings.url;
|
838
|
+
if(typeof settings.url == 'function') {
|
839
|
+
url = settings.url.call();
|
840
|
+
}
|
841
|
+
return url;
|
842
|
+
}
|
843
|
+
};
|
844
|
+
|
845
|
+
// Really basic cache for the results
|
846
|
+
$.TokenList.Cache = function (options) {
|
847
|
+
var settings = $.extend({
|
848
|
+
max_size: 500
|
849
|
+
}, options);
|
850
|
+
|
851
|
+
var data = {};
|
852
|
+
var size = 0;
|
853
|
+
|
854
|
+
var flush = function () {
|
855
|
+
data = {};
|
856
|
+
size = 0;
|
857
|
+
};
|
858
|
+
|
859
|
+
this.add = function (query, results) {
|
860
|
+
if(size > settings.max_size) {
|
861
|
+
flush();
|
862
|
+
}
|
863
|
+
|
864
|
+
if(!data[query]) {
|
865
|
+
size += 1;
|
866
|
+
}
|
867
|
+
|
868
|
+
data[query] = results;
|
869
|
+
};
|
870
|
+
|
871
|
+
this.get = function (query) {
|
872
|
+
return data[query];
|
873
|
+
};
|
874
|
+
};
|
875
|
+
}(jQuery));
|