archangel 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +5 -1
- data/.erb-lint.yml +23 -0
- data/.eslintrc.json +1 -1
- data/.nvmrc +1 -1
- data/.rubocop.yml +7 -1
- data/.rubocop_exclude.yml +0 -1
- data/.sass-lint.yml +8 -0
- data/.travis.yml +13 -5
- data/Gemfile +19 -13
- data/README.md +10 -6
- data/app/assets/javascripts/archangel/input/datetimepicker.js +31 -77
- data/app/assets/javascripts/archangel/input/meta_keywords.js +0 -12
- data/app/assets/javascripts/archangel/input/wysiwyg.js.erb +51 -36
- data/app/assets/javascripts/archangel/object/flash.js +11 -8
- data/app/assets/javascripts/archangel/object/routes/backend.js +10 -10
- data/app/controllers/archangel/application_controller.rb +23 -13
- data/app/controllers/archangel/auth/invitations_controller.rb +22 -0
- data/app/controllers/archangel/auth/registrations_controller.rb +7 -3
- data/app/controllers/archangel/auth_controller.rb +8 -3
- data/app/controllers/archangel/backend/assets_controller.rb +9 -11
- data/app/controllers/archangel/backend/collections_controller.rb +3 -3
- data/app/controllers/archangel/backend/dashboards_controller.rb +1 -1
- data/app/controllers/archangel/backend/designs_controller.rb +43 -0
- data/app/controllers/archangel/backend/entries_controller.rb +25 -40
- data/app/controllers/archangel/backend/pages_controller.rb +7 -5
- data/app/controllers/archangel/backend/profiles_controller.rb +3 -2
- data/app/controllers/archangel/backend/sites_controller.rb +8 -14
- data/app/controllers/archangel/backend/users_controller.rb +6 -11
- data/app/controllers/archangel/backend/widgets_controller.rb +3 -3
- data/app/controllers/archangel/backend_controller.rb +6 -4
- data/app/controllers/archangel/frontend/homepages_controller.rb +33 -0
- data/app/controllers/archangel/frontend/pages_controller.rb +32 -43
- data/app/controllers/archangel/frontend_controller.rb +25 -1
- data/app/controllers/concerns/archangel/controllers/authenticatable_concern.rb +19 -0
- data/app/controllers/concerns/archangel/controllers/authorizable_concern.rb +19 -0
- data/app/controllers/concerns/archangel/controllers/metatagable_concern.rb +45 -0
- data/app/controllers/concerns/archangel/controllers/paginatable_concern.rb +43 -0
- data/app/controllers/concerns/archangel/controllers/resourceful_concern.rb +63 -26
- data/app/controllers/concerns/archangel/controllers/skip_authorizable_concern.rb +19 -0
- data/app/controllers/concerns/archangel/controllers/themable_concern.rb +34 -0
- data/app/controllers/concerns/archangel/helpers/actionable_concern.rb +76 -0
- data/app/helpers/archangel/application_helper.rb +35 -1
- data/app/helpers/archangel/backend/metatags_helper.rb +52 -0
- data/app/models/archangel/asset.rb +1 -1
- data/app/models/archangel/collection.rb +4 -7
- data/app/models/archangel/{template.rb → design.rb} +5 -13
- data/app/models/archangel/entry.rb +8 -28
- data/app/models/archangel/field.rb +1 -1
- data/app/models/archangel/page.rb +12 -48
- data/app/models/archangel/site.rb +17 -11
- data/app/models/archangel/user.rb +14 -7
- data/app/models/archangel/widget.rb +4 -4
- data/app/models/concerns/archangel/models/entry_validatable_concern.rb +74 -0
- data/app/models/concerns/archangel/models/metatagable_concern.rb +22 -0
- data/app/models/concerns/archangel/models/publishable_concern.rb +57 -0
- data/app/{helpers/archangel/auth_helper.rb → policies/archangel/design_policy.rb} +2 -2
- data/app/policies/archangel/site_policy.rb +0 -9
- data/app/services/archangel/{template_render_service.rb → design_render_service.rb} +3 -3
- data/app/services/archangel/render_service.rb +1 -1
- data/app/themes/default/assets/javascripts/default/auth.js +10 -13
- data/app/themes/default/assets/javascripts/default/backend.js +16 -37
- data/app/themes/default/assets/javascripts/default/backend/archangel.js +25 -0
- data/app/themes/default/assets/javascripts/default/backend/entries/sorting.js +37 -0
- data/app/themes/default/assets/javascripts/default/backend/misc/metatags.js +16 -0
- data/app/themes/default/assets/javascripts/default/common/flash.js +4 -43
- data/app/themes/default/assets/javascripts/default/frontend.js +11 -13
- data/app/themes/default/assets/stylesheets/default/_theme.scss +13 -0
- data/app/themes/default/assets/stylesheets/default/_variables.scss +113 -0
- data/app/themes/default/assets/stylesheets/default/auth.css +15 -13
- data/app/themes/default/assets/stylesheets/default/auth/_flash.scss +9 -0
- data/app/themes/default/assets/stylesheets/default/auth/default.scss +7 -0
- data/app/themes/default/assets/stylesheets/default/backend.css +10 -9
- data/app/themes/default/assets/stylesheets/default/backend/_entries.scss +25 -0
- data/app/themes/default/assets/stylesheets/default/backend/_flash.scss +19 -0
- data/app/themes/default/assets/stylesheets/default/backend/_footer.scss +15 -0
- data/app/themes/default/assets/stylesheets/default/backend/_global.scss +22 -0
- data/app/themes/default/assets/stylesheets/default/backend/_sidebar.scss +60 -0
- data/app/themes/default/assets/stylesheets/default/backend/_tables.scss +18 -0
- data/app/themes/default/assets/stylesheets/default/backend/_top.scss +25 -0
- data/app/themes/default/assets/stylesheets/default/backend/default.scss +16 -0
- data/app/themes/default/assets/stylesheets/default/common/_borders.scss +7 -0
- data/app/themes/default/assets/stylesheets/default/common/_cards.scss +15 -0
- data/app/themes/default/assets/stylesheets/default/common/_forms.scss +5 -0
- data/app/themes/default/assets/stylesheets/default/common/_global.scss +8 -0
- data/app/themes/default/assets/stylesheets/default/common/_mixins.scss +38 -0
- data/app/themes/default/assets/stylesheets/default/common/_navbar.scss +90 -0
- data/app/themes/default/assets/stylesheets/default/frontend.css +15 -13
- data/app/themes/default/assets/stylesheets/default/frontend/default.scss +5 -0
- data/app/themes/default/views/layouts/auth.html.erb +10 -8
- data/app/themes/default/views/layouts/backend.html.erb +16 -9
- data/app/themes/default/views/layouts/backend/_footer.html.erb +10 -6
- data/app/themes/default/views/layouts/backend/_header.html.erb +28 -24
- data/app/themes/default/views/layouts/backend/_sidebar.html.erb +65 -45
- data/app/themes/default/views/layouts/frontend.html.erb +20 -0
- data/app/views/archangel/backend/assets/_asset.html.erb +14 -7
- data/app/views/archangel/backend/assets/_buttons.html.erb +7 -5
- data/app/views/archangel/backend/assets/_form.html.erb +1 -1
- data/app/views/archangel/backend/assets/edit.html.erb +8 -14
- data/app/views/archangel/backend/assets/index.html.erb +36 -44
- data/app/views/archangel/backend/assets/new.html.erb +8 -14
- data/app/views/archangel/backend/assets/show.html.erb +33 -39
- data/app/views/archangel/backend/collections/_buttons.html.erb +8 -6
- data/app/views/archangel/backend/collections/_collection.html.erb +5 -4
- data/app/views/archangel/backend/collections/_form.html.erb +1 -1
- data/app/views/archangel/backend/collections/edit.html.erb +8 -14
- data/app/views/archangel/backend/collections/index.html.erb +34 -42
- data/app/views/archangel/backend/collections/new.html.erb +8 -14
- data/app/views/archangel/backend/collections/show.html.erb +21 -27
- data/app/views/archangel/backend/dashboards/show.html.erb +7 -17
- data/app/views/archangel/backend/designs/_buttons.html.erb +20 -0
- data/app/views/archangel/backend/designs/_design.html.erb +11 -0
- data/app/views/archangel/backend/{templates → designs}/_form.html.erb +2 -2
- data/app/views/archangel/backend/designs/edit.html.erb +15 -0
- data/app/views/archangel/backend/designs/index.html.erb +43 -0
- data/app/views/archangel/backend/designs/new.html.erb +15 -0
- data/app/views/archangel/backend/designs/show.html.erb +23 -0
- data/app/views/archangel/backend/entries/_buttons.html.erb +8 -6
- data/app/views/archangel/backend/entries/_entry.html.erb +17 -9
- data/app/views/archangel/backend/entries/_form.html.erb +6 -11
- data/app/views/archangel/backend/entries/edit.html.erb +8 -14
- data/app/views/archangel/backend/entries/index.html.erb +39 -47
- data/app/views/archangel/backend/entries/new.html.erb +8 -14
- data/app/views/archangel/backend/entries/show.html.erb +14 -20
- data/app/views/archangel/backend/pages/_buttons.html.erb +7 -5
- data/app/views/archangel/backend/pages/_form.html.erb +4 -3
- data/app/views/archangel/backend/pages/_metatag_fields.html.erb +3 -3
- data/app/views/archangel/backend/pages/_page.html.erb +13 -8
- data/app/views/archangel/backend/pages/edit.html.erb +8 -14
- data/app/views/archangel/backend/pages/index.html.erb +35 -43
- data/app/views/archangel/backend/pages/new.html.erb +8 -14
- data/app/views/archangel/backend/pages/show.html.erb +15 -31
- data/app/views/archangel/backend/profiles/_buttons.html.erb +7 -2
- data/app/views/archangel/backend/profiles/_form.html.erb +4 -2
- data/app/views/archangel/backend/profiles/edit.html.erb +8 -14
- data/app/views/archangel/backend/profiles/show.html.erb +20 -26
- data/app/views/archangel/backend/sites/_buttons.html.erb +2 -2
- data/app/views/archangel/backend/sites/_form.html.erb +10 -2
- data/app/views/archangel/backend/sites/_metatag_fields.html.erb +3 -3
- data/app/views/archangel/backend/sites/edit.html.erb +8 -14
- data/app/views/archangel/backend/sites/show.html.erb +22 -28
- data/app/views/archangel/backend/users/_buttons.html.erb +7 -5
- data/app/views/archangel/backend/users/_form.html.erb +1 -1
- data/app/views/archangel/backend/users/_user.html.erb +10 -6
- data/app/views/archangel/backend/users/edit.html.erb +8 -14
- data/app/views/archangel/backend/users/index.html.erb +35 -43
- data/app/views/archangel/backend/users/new.html.erb +8 -14
- data/app/views/archangel/backend/users/show.html.erb +16 -27
- data/app/views/archangel/backend/widgets/_buttons.html.erb +7 -5
- data/app/views/archangel/backend/widgets/_form.html.erb +2 -2
- data/app/views/archangel/backend/widgets/_widget.html.erb +5 -4
- data/app/views/archangel/backend/widgets/edit.html.erb +8 -14
- data/app/views/archangel/backend/widgets/index.html.erb +34 -42
- data/app/views/archangel/backend/widgets/new.html.erb +8 -14
- data/app/views/archangel/backend/widgets/show.html.erb +20 -31
- data/app/views/archangel/frontend/pages/show.json.jbuilder +4 -3
- data/app/views/archangel/shared/_flash_messages.html.erb +5 -2
- data/app/views/devise/confirmations/new.html.erb +10 -8
- data/app/views/devise/invitations/edit.html.erb +17 -0
- data/app/views/devise/invitations/new.html.erb +15 -0
- data/app/views/devise/mailer/invitation_instructions.html.erb +11 -0
- data/app/views/devise/mailer/invitation_instructions.text.erb +11 -0
- data/app/views/devise/passwords/edit.html.erb +14 -18
- data/app/views/devise/passwords/new.html.erb +8 -8
- data/app/views/devise/registrations/edit.html.erb +18 -28
- data/app/views/devise/registrations/new.html.erb +19 -31
- data/app/views/devise/sessions/new.html.erb +11 -19
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/_links.html.erb +19 -35
- data/app/views/devise/unlocks/new.html.erb +9 -8
- data/archangel.gemspec +12 -14
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/simple_form.rb +18 -6
- data/config/initializers/simple_form_bootstrap.rb +520 -88
- data/config/locales/active_record.en.yml +14 -10
- data/config/locales/en.yml +10 -43
- data/config/locales/simple_form.en.yml +8 -7
- data/config/routes.rb +27 -40
- data/db/migrate/20190408164034_rename_archangel_pages_path_to_permalink.rb +5 -0
- data/db/migrate/20190417194514_add_settings_to_archangel_sites.rb +5 -0
- data/db/migrate/20190418150532_rename_archangel_templates_to_archangel_designs.rb +5 -0
- data/db/migrate/20190418150533_rename_archangel_pages_template_id_to_design_id.rb +5 -0
- data/db/migrate/20190418150534_rename_archangel_widgets_template_id_to_design_id.rb +5 -0
- data/db/migrate/20190421165525_rename_archangel_entries_available_at_to_published_at.rb +5 -0
- data/db/seeds.rb +41 -46
- data/docs/Developers.md +9 -7
- data/docs/Extension/Controllers.md +1 -1
- data/docs/Extension/Uploaders.md +1 -1
- data/lib/archangel.rb +2 -11
- data/lib/archangel/commands/base_command.rb +4 -8
- data/lib/archangel/commands/extension_command.rb +14 -14
- data/lib/archangel/commands/templates/common/Gemfile +24 -0
- data/lib/archangel/commands/templates/{extension → common}/Rakefile +1 -1
- data/lib/archangel/commands/templates/{extension → common}/bin/rails.tt +0 -0
- data/lib/archangel/commands/templates/{extension → common}/lib/%extension_name%.rb.tt +0 -0
- data/lib/archangel/commands/templates/{extension → common}/lib/%extension_name%/engine.rb.tt +0 -0
- data/lib/archangel/commands/templates/{extension → common}/lib/%extension_name%/version.rb.tt +0 -0
- data/lib/archangel/commands/templates/common/spec/rails_helper.rb.tt +0 -4
- data/lib/archangel/commands/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt +10 -10
- data/lib/archangel/commands/templates/theme/README.md +2 -2
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/config/locales/en.yml.tt +1 -1
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.html.erb +20 -0
- data/lib/archangel/commands/templates/theme/theme.gemspec.tt +3 -3
- data/lib/archangel/commands/theme_command.rb +30 -27
- data/lib/archangel/config.rb +1 -2
- data/lib/archangel/constants/theme.rb +1 -1
- data/lib/archangel/engine.rb +3 -1
- data/lib/archangel/i18n.rb +5 -1
- data/lib/archangel/liquid/drop.rb +3 -45
- data/lib/archangel/liquid/drops/page_drop.rb +4 -4
- data/lib/archangel/liquid/drops/site_drop.rb +1 -0
- data/lib/archangel/liquid/tags/asset_tag.rb +4 -5
- data/lib/archangel/liquid/tags/collection_tag.rb +3 -5
- data/lib/archangel/liquid/tags/collectionfor_tag.rb +3 -4
- data/lib/archangel/liquid/tags/gist_tag.rb +3 -3
- data/lib/archangel/liquid/tags/noembed_tag.rb +1 -1
- data/lib/archangel/liquid/tags/vimeo_tag.rb +15 -9
- data/lib/archangel/liquid/tags/widget_tag.rb +9 -12
- data/lib/archangel/liquid/tags/youtube_tag.rb +44 -30
- data/lib/archangel/testing_support/factories/{archangel_templates.rb → archangel_designs.rb} +4 -4
- data/lib/archangel/testing_support/factories/archangel_entries.rb +5 -5
- data/lib/archangel/testing_support/factories/archangel_pages.rb +3 -3
- data/lib/archangel/testing_support/factories/archangel_users.rb +6 -0
- data/lib/archangel/testing_support/factories/archangel_widgets.rb +3 -3
- data/lib/archangel/testing_support/helpers/authorization_helpers.rb +5 -29
- data/lib/archangel/testing_support/helpers/fill_in_auth_form_helpers.rb +34 -0
- data/lib/archangel/testing_support/helpers/fill_in_form_helpers.rb +21 -0
- data/lib/archangel/testing_support/support/capybara.rb +0 -3
- data/lib/archangel/testing_support/support/shoulda.rb +0 -1
- data/lib/archangel/version.rb +5 -1
- data/lib/generators/archangel/install/install_generator.rb +15 -33
- data/lib/generators/archangel/install/templates/config/archangel.yml +0 -5
- data/lib/templates/erb/scaffold/_form.html.erb +2 -2
- data/package.json +5 -12
- data/spec/features/auth/invitation_spec.rb +86 -0
- data/spec/features/auth/log_in/attempts_spec.rb +50 -0
- data/spec/features/auth/log_in/locked_spec.rb +29 -0
- data/spec/features/auth/log_in/log_in_spec.rb +51 -0
- data/spec/features/auth/log_in/unconfirmed_spec.rb +22 -0
- data/spec/features/auth/log_out_spec.rb +11 -4
- data/spec/features/auth/password_reset_spec.rb +28 -0
- data/spec/features/auth/registration_spec.rb +28 -16
- data/spec/features/backend/assets/create_spec.rb +68 -0
- data/spec/features/backend/assets/delete_spec.rb +32 -0
- data/spec/features/backend/assets/listing_spec.rb +83 -0
- data/spec/features/backend/assets/show_spec.rb +57 -0
- data/spec/features/backend/collections/create_spec.rb +97 -0
- data/spec/features/backend/collections/delete_spec.rb +32 -0
- data/spec/features/backend/collections/listing_spec.rb +93 -0
- data/spec/features/backend/collections/show_spec.rb +43 -0
- data/spec/features/backend/dashboard/show_spec.rb +17 -0
- data/spec/features/backend/designs/create_spec.rb +76 -0
- data/spec/features/backend/designs/delete_spec.rb +32 -0
- data/spec/features/backend/designs/listing_spec.rb +77 -0
- data/spec/features/backend/designs/show_spec.rb +48 -0
- data/spec/features/backend/entries/create_spec.rb +98 -0
- data/spec/features/backend/entries/delete_spec.rb +35 -0
- data/spec/features/backend/entries/listing_sorting_spec.rb +32 -0
- data/spec/features/backend/entries/listing_spec.rb +100 -0
- data/spec/features/backend/entries/show_spec.rb +62 -0
- data/spec/features/backend/pages/create_metatags_spec.rb +59 -0
- data/spec/features/backend/pages/create_spec.rb +143 -0
- data/spec/features/backend/pages/delete_spec.rb +32 -0
- data/spec/features/backend/pages/liquid_tags_spec.rb +159 -0
- data/spec/features/backend/pages/listing_spec.rb +75 -0
- data/spec/features/backend/pages/show_spec.rb +47 -0
- data/spec/features/backend/profile/delete_spec.rb +41 -0
- data/spec/features/backend/profile/show_spec.rb +46 -0
- data/spec/features/backend/profile/update_spec.rb +144 -0
- data/spec/features/backend/site/show_spec.rb +46 -0
- data/spec/features/backend/site/update_spec.rb +46 -0
- data/spec/features/backend/site/update_with_metatags_spec.rb +45 -0
- data/spec/features/backend/users/create_spec.rb +90 -0
- data/spec/features/backend/users/delete_spec.rb +32 -0
- data/spec/features/backend/users/listing_spec.rb +69 -0
- data/spec/features/backend/users/show_spec.rb +87 -0
- data/spec/features/backend/users/update_spec.rb +49 -0
- data/spec/features/backend/widgets/create_spec.rb +111 -0
- data/spec/features/backend/widgets/delete_spec.rb +42 -0
- data/spec/features/backend/widgets/listing_spec.rb +89 -0
- data/spec/features/backend/widgets/show_spec.rb +47 -0
- data/spec/features/frontend/liquid/filters/link_to_spec.rb +49 -0
- data/spec/features/frontend/liquid/tags/asset_spec.rb +81 -0
- data/spec/features/frontend/liquid/tags/collection_tag_spec.rb +94 -0
- data/spec/features/frontend/liquid/tags/collectionfor_tag_spec.rb +159 -0
- data/spec/features/frontend/liquid/tags/gist_spec.rb +57 -0
- data/spec/features/frontend/liquid/tags/noembed_tag_spec.rb +106 -0
- data/spec/features/frontend/liquid/tags/vimeo_spec.rb +79 -0
- data/spec/features/frontend/liquid/tags/widget_spec.rb +40 -0
- data/spec/features/frontend/liquid/tags/youtube_spec.rb +89 -0
- data/spec/features/frontend/liquid/variables/current_page_spec.rb +74 -0
- data/spec/features/frontend/liquid/variables/page_spec.rb +58 -0
- data/spec/features/frontend/liquid/variables/site_spec.rb +46 -0
- data/spec/features/frontend/liquid/variables/unknown_spec.rb +19 -0
- data/spec/features/frontend/metatags/default_spec.rb +46 -0
- data/spec/features/frontend/metatags/page_spec.rb +58 -0
- data/spec/features/frontend/metatags/site_spec.rb +42 -0
- data/spec/fixtures/schemas/backend/assets/wysiwyg_error.json +11 -0
- data/spec/fixtures/schemas/backend/assets/wysiwyg_url.json +11 -0
- data/spec/fixtures/schemas/frontend/errors/not_found.json +11 -0
- data/spec/fixtures/schemas/frontend/pages/show.json +25 -0
- data/spec/requests/backend/assets_spec.rb +81 -0
- data/spec/requests/backend/designs_spec.rb +115 -0
- data/spec/requests/backend/entries_spec.rb +32 -0
- data/spec/requests/backend/pages_spec.rb +113 -0
- data/spec/requests/backend/site_spec.rb +65 -0
- data/spec/requests/backend/widgets_spec.rb +109 -0
- data/spec/requests/frontend/html/homepage_spec.rb +70 -0
- data/spec/requests/frontend/html/nested_page_spec.rb +97 -0
- data/spec/requests/frontend/html/page_spec.rb +78 -0
- data/spec/requests/frontend/json/homepage_spec.rb +80 -0
- data/spec/requests/frontend/json/nested_page_spec.rb +111 -0
- data/spec/requests/frontend/json/page_spec.rb +92 -0
- data/spec/support/helpers/ajax_helpers.rb +27 -0
- data/spec/support/helpers/json_response.rb +18 -0
- data/{lib/archangel/testing_support → spec/support}/matchers/have_meta.rb +0 -0
- data/{lib/archangel/testing_support → spec/support}/matchers/have_title.rb +0 -0
- data/spec/support/matchers/match_response_schema.rb +12 -0
- data/spec/support/missing_translation.rb +13 -0
- data/spec/support/selenium.rb +26 -0
- data/spec/support/timecop.rb +15 -0
- data/spec/unit/helpers/archangel/application_helper_spec.rb +65 -0
- data/spec/unit/helpers/archangel/flash_helper_spec.rb +41 -0
- data/spec/{inputs → unit/inputs}/archangel/date_picker_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/date_time_picker_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/field_classification_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/language_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/meta_keywords_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/role_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/theme_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/time_picker_input_spec.rb +0 -0
- data/spec/{inputs → unit/inputs}/archangel/wysiwyg_input_spec.rb +0 -0
- data/spec/{jobs → unit/jobs}/archangel/application_job_spec.rb +0 -0
- data/spec/{lib → unit/lib}/archangel/commands/extension_command_spec.rb +11 -6
- data/spec/{lib → unit/lib}/archangel/commands/theme_command_spec.rb +11 -6
- data/spec/{lib → unit/lib}/tasks/archangel/version_task_spec.rb +0 -0
- data/spec/{mailers → unit/mailers}/archangel/application_mailer_spec.rb +0 -0
- data/spec/{models → unit/models}/archangel/asset_spec.rb +7 -15
- data/spec/{models → unit/models}/archangel/collection_spec.rb +3 -16
- data/spec/unit/models/archangel/design_spec.rb +22 -0
- data/spec/unit/models/archangel/entry_spec.rb +104 -0
- data/spec/{models → unit/models}/archangel/field_spec.rb +5 -7
- data/spec/{models → unit/models}/archangel/metatag_spec.rb +1 -5
- data/spec/{models → unit/models}/archangel/page_spec.rb +46 -44
- data/spec/{models → unit/models}/archangel/site_spec.rb +15 -8
- data/spec/{models → unit/models}/archangel/user_spec.rb +29 -39
- data/spec/{models → unit/models}/archangel/widget_spec.rb +5 -20
- data/spec/{policies → unit/policies}/archangel/asset_policy_spec.rb +0 -0
- data/spec/{policies → unit/policies}/archangel/collection_policy_spec.rb +0 -0
- data/spec/{policies/archangel/template_policy_spec.rb → unit/policies/archangel/design_policy_spec.rb} +2 -2
- data/spec/{policies → unit/policies}/archangel/entries_policy_spec.rb +0 -0
- data/spec/{policies → unit/policies}/archangel/page_policy_spec.rb +0 -0
- data/spec/{policies → unit/policies}/archangel/site_policy_spec.rb +2 -6
- data/spec/{policies → unit/policies}/archangel/user_policy_spec.rb +0 -0
- data/spec/{policies → unit/policies}/archangel/widget_policy_spec.rb +0 -0
- data/spec/unit/services/archangel/design_render_service_spec.rb +46 -0
- data/spec/unit/services/archangel/render_service_spec.rb +43 -0
- data/spec/{uploaders → unit/uploaders}/archangel/application_uploader_spec.rb +4 -2
- data/spec/{uploaders → unit/uploaders}/archangel/asset_uploader_spec.rb +5 -3
- data/vendor/assets/javascripts/flatpickr/flatpickr.js +2 -0
- data/vendor/assets/javascripts/jodit/jodit.js +9 -0
- data/vendor/assets/javascripts/select2/select2.js +5891 -0
- data/vendor/assets/javascripts/sortable/sortable.js +2 -2
- data/vendor/assets/stylesheets/flatpickr/flatpickr.css +13 -0
- data/vendor/assets/stylesheets/jodit/jodit.css +296 -0
- data/vendor/assets/stylesheets/select2/select2.css +480 -0
- metadata +227 -322
- data/.editorconfig +0 -19
- data/.hound.yml +0 -21
- data/.jshintignore +0 -5
- data/.jshintrc +0 -30
- data/.rubocop_todo.yml +0 -3
- data/.scss-lint.yml +0 -22
- data/app/assets/javascripts/archangel/object/translate/datetimepicker.js.erb +0 -41
- data/app/assets/javascripts/archangel/object/translate/sortable.js.erb +0 -10
- data/app/assets/javascripts/archangel/sortable.js +0 -72
- data/app/controllers/archangel/backend/templates_controller.rb +0 -43
- data/app/controllers/concerns/archangel/actionable_concern.rb +0 -161
- data/app/controllers/concerns/archangel/authenticatable_concern.rb +0 -14
- data/app/controllers/concerns/archangel/authorizable_concern.rb +0 -14
- data/app/controllers/concerns/archangel/controllers/backend/resourceful_concern.rb +0 -28
- data/app/controllers/concerns/archangel/paginatable_concern.rb +0 -36
- data/app/controllers/concerns/archangel/seoable_concern.rb +0 -40
- data/app/controllers/concerns/archangel/skip_authorizable_concern.rb +0 -14
- data/app/controllers/concerns/archangel/themable_concern.rb +0 -27
- data/app/helpers/archangel/backend/assets_helper.rb +0 -14
- data/app/helpers/archangel/backend/collections_helper.rb +0 -14
- data/app/helpers/archangel/backend/dashboards_helper.rb +0 -14
- data/app/helpers/archangel/backend/entries_helper.rb +0 -14
- data/app/helpers/archangel/backend/pages_helper.rb +0 -14
- data/app/helpers/archangel/backend/sites_helper.rb +0 -14
- data/app/helpers/archangel/backend/templates_helper.rb +0 -14
- data/app/helpers/archangel/backend/users_helper.rb +0 -14
- data/app/helpers/archangel/backend/widgets_helper.rb +0 -14
- data/app/helpers/archangel/backend_helper.rb +0 -9
- data/app/helpers/archangel/frontend/pages_helper.rb +0 -14
- data/app/helpers/archangel/frontend_helper.rb +0 -9
- data/app/policies/archangel/template_policy.rb +0 -9
- data/app/themes/default/assets/javascripts/default/backend/core.js +0 -76
- data/app/themes/default/assets/javascripts/default/backend/templates.js +0 -26
- data/app/themes/default/assets/javascripts/default/common/cards.js +0 -28
- data/app/themes/default/assets/stylesheets/default/auth/core.scss +0 -20
- data/app/themes/default/assets/stylesheets/default/backend/bootstrap/_tables.scss +0 -40
- data/app/themes/default/assets/stylesheets/default/backend/core.scss +0 -23
- data/app/themes/default/assets/stylesheets/default/common/_bootstrap.scss +0 -49
- data/app/themes/default/assets/stylesheets/default/common/_selectize.scss +0 -348
- data/app/themes/default/assets/stylesheets/default/common/_variables.scss +0 -82
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_animate.scss +0 -27
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_aside.scss +0 -67
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_avatars.scss +0 -42
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_badge.scss +0 -3
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_breadcrumb-menu.scss +0 -36
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_breadcrumb.scss +0 -4
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_buttons.scss +0 -408
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_callout.scss +0 -58
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_card.scss +0 -199
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_charts.scss +0 -9
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_dropdown-menu-right.scss +0 -8
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_dropdown.scss +0 -70
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_footer.scss +0 -9
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_forms.scss +0 -4
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_grid.scss +0 -15
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_input-group.scss +0 -5
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_layout.scss +0 -390
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_loading.scss +0 -128
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_mixins.scss +0 -1
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_mobile.scss +0 -0
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_modal.scss +0 -12
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_nav.scss +0 -39
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_navbar.scss +0 -122
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_others.scss +0 -4
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_progress.scss +0 -15
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_rtl.scss +0 -287
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_sidebar.scss +0 -462
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_switches.scss +0 -286
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_tables.scss +0 -20
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_temp.scss +0 -39
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_typography.scss +0 -36
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_utilities.scss +0 -3
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_variables.scss +0 -208
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/_widgets.scss +0 -251
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/mixins/_all.scss +0 -117
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/utilities/_background.scss +0 -20
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/utilities/_borders.scss +0 -17
- data/app/themes/default/assets/stylesheets/default/common/bootstrap/utilities/_display.scss +0 -14
- data/app/themes/default/assets/stylesheets/default/frontend/core.scss +0 -20
- data/app/themes/default/views/layouts/frontend.liquid +0 -22
- data/app/views/archangel/backend/dashboards/_buttons.html.erb +0 -3
- data/app/views/archangel/backend/sites/_additional_colors.html.erb +0 -49
- data/app/views/archangel/backend/sites/_alerts.html.erb +0 -130
- data/app/views/archangel/backend/sites/_badge.html.erb +0 -99
- data/app/views/archangel/backend/sites/_button.html.erb +0 -243
- data/app/views/archangel/backend/sites/_buttons_group.html.erb +0 -230
- data/app/views/archangel/backend/sites/_cards.html.erb +0 -441
- data/app/views/archangel/backend/sites/_carousel.html.erb +0 -159
- data/app/views/archangel/backend/sites/_colors.html.erb +0 -41
- data/app/views/archangel/backend/sites/_display_headings.html.erb +0 -41
- data/app/views/archangel/backend/sites/_dl.html.erb +0 -38
- data/app/views/archangel/backend/sites/_dropdowns.html.erb +0 -475
- data/app/views/archangel/backend/sites/_forms.html.erb +0 -1176
- data/app/views/archangel/backend/sites/_grays.html.erb +0 -21
- data/app/views/archangel/backend/sites/_headings.html.erb +0 -21
- data/app/views/archangel/backend/sites/_inline_text.html.erb +0 -45
- data/app/views/archangel/backend/sites/_jumbotron.html.erb +0 -45
- data/app/views/archangel/backend/sites/_list_group.html.erb +0 -254
- data/app/views/archangel/backend/sites/_modals.html.erb +0 -41
- data/app/views/archangel/backend/sites/_navs.html.erb +0 -389
- data/app/views/archangel/backend/sites/_pagination.html.erb +0 -160
- data/app/views/archangel/backend/sites/_social_buttons.html.erb +0 -746
- data/app/views/archangel/backend/sites/_tables.html.erb +0 -372
- data/app/views/archangel/backend/sites/sample.html.erb +0 -38
- data/app/views/archangel/backend/templates/_buttons.html.erb +0 -18
- data/app/views/archangel/backend/templates/_template.html.erb +0 -10
- data/app/views/archangel/backend/templates/edit.html.erb +0 -21
- data/app/views/archangel/backend/templates/index.html.erb +0 -49
- data/app/views/archangel/backend/templates/new.html.erb +0 -21
- data/app/views/archangel/backend/templates/show.html.erb +0 -34
- data/config/initializers/liquid.rb +0 -4
- data/lib/archangel/commands/templates/common/.editorconfig +0 -19
- data/lib/archangel/commands/templates/common/.rubocop.yml +0 -32
- data/lib/archangel/commands/templates/extension/Gemfile +0 -27
- data/lib/archangel/commands/templates/extension/app/assets/javascripts/archangel/auth/%extension_name%.js.tt +0 -3
- data/lib/archangel/commands/templates/extension/app/assets/javascripts/archangel/backend/%extension_name%.js.tt +0 -3
- data/lib/archangel/commands/templates/extension/app/assets/javascripts/archangel/frontend/%extension_name%.js.tt +0 -3
- data/lib/archangel/commands/templates/extension/app/assets/stylesheets/archangel/auth/%extension_name%.css.tt +0 -5
- data/lib/archangel/commands/templates/extension/app/assets/stylesheets/archangel/backend/%extension_name%.css.tt +0 -5
- data/lib/archangel/commands/templates/extension/app/assets/stylesheets/archangel/frontend/%extension_name%.css.tt +0 -5
- data/lib/archangel/commands/templates/theme/Gemfile +0 -27
- data/lib/archangel/commands/templates/theme/Rakefile +0 -29
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/auth.js +0 -2
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/backend.js +0 -2
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/auth.css +0 -4
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/backend.css +0 -4
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.liquid +0 -18
- data/lib/archangel/commands/templates/theme/bin/rails.tt +0 -11
- data/lib/archangel/commands/templates/theme/lib/%theme_name%.rb.tt +0 -9
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/engine.rb.tt +0 -29
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/version.rb.tt +0 -5
- data/lib/archangel/liquid/tags/csrf_meta_tags_tag.rb +0 -29
- data/lib/archangel/liquid/tags/locale_tag.rb +0 -28
- data/lib/archangel/liquid/tags/meta_tags_tag.rb +0 -31
- data/lib/archangel/liquid/tags/text_direction_tag.rb +0 -29
- data/lib/archangel/liquid/tags/theme_javascript_tag.rb +0 -31
- data/lib/archangel/liquid/tags/theme_stylesheet_tag.rb +0 -31
- data/lib/archangel/liquid_view.rb +0 -68
- data/lib/archangel/testing_support/context/view_controller_context.rb +0 -55
- data/lib/archangel/testing_support/helpers/controller_helpers.rb +0 -20
- data/lib/archangel/testing_support/helpers/form_helpers.rb +0 -18
- data/lib/archangel/testing_support/helpers/routing_helpers.rb +0 -22
- data/lib/archangel/testing_support/support/controller.rb +0 -11
- data/lib/archangel/testing_support/support/liquid_filters.rb +0 -23
- data/lib/archangel/testing_support/support/liquid_tags.rb +0 -23
- data/lib/archangel/testing_support/support/verify_partial_doubles.rb +0 -21
- data/spec/controllers/archangel/application_controller_spec.rb +0 -183
- data/spec/controllers/archangel/auth/registrations_controller_spec.rb +0 -10
- data/spec/controllers/archangel/auth_controller_spec.rb +0 -8
- data/spec/controllers/archangel/backend/assets_controller_spec.rb +0 -226
- data/spec/controllers/archangel/backend/collections_controller_spec.rb +0 -252
- data/spec/controllers/archangel/backend/dashboards_controller_spec.rb +0 -27
- data/spec/controllers/archangel/backend/entries_controller_spec.rb +0 -273
- data/spec/controllers/archangel/backend/pages_controller_spec.rb +0 -220
- data/spec/controllers/archangel/backend/profiles_controller_spec.rb +0 -115
- data/spec/controllers/archangel/backend/sites_controller_spec.rb +0 -121
- data/spec/controllers/archangel/backend/templates_controller_spec.rb +0 -190
- data/spec/controllers/archangel/backend/users_controller_spec.rb +0 -181
- data/spec/controllers/archangel/backend/widgets_controller_spec.rb +0 -190
- data/spec/controllers/archangel/backend_controller_spec.rb +0 -8
- data/spec/controllers/archangel/frontend/pages_controller_spec.rb +0 -51
- data/spec/controllers/archangel/frontend_controller_spec.rb +0 -8
- data/spec/controllers/concerns/archangel/controllers/backend/resourceful_concern_spec.rb +0 -90
- data/spec/features/auth/log_in_spec.rb +0 -126
- data/spec/features/backend/pages/duplicate_slugs_spec.rb +0 -41
- data/spec/features/frontend/liquid_drop_variables_spec.rb +0 -133
- data/spec/features/frontend/pages/homepage_redirect_spec.rb +0 -15
- data/spec/features/frontend/pages/metatags_spec.rb +0 -73
- data/spec/helpers/archangel/application_helper_spec.rb +0 -30
- data/spec/helpers/archangel/auth_helper_spec.rb +0 -8
- data/spec/helpers/archangel/backend/assets_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/collections_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/dashboards_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/entries_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/pages_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/sites_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/templates_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/users_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend/widgets_helper_spec.rb +0 -10
- data/spec/helpers/archangel/backend_helper_spec.rb +0 -8
- data/spec/helpers/archangel/flash_helper_spec.rb +0 -47
- data/spec/helpers/archangel/frontend/pages_helper_spec.rb +0 -10
- data/spec/helpers/archangel/frontend_helper_spec.rb +0 -8
- data/spec/lib/archangel/liquid/drop_spec.rb +0 -10
- data/spec/lib/archangel/liquid/drops/page_drop_spec.rb +0 -69
- data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +0 -63
- data/spec/lib/archangel/liquid/filters/link_to_filter_spec.rb +0 -59
- data/spec/lib/archangel/liquid/tags/application_tag_spec.rb +0 -12
- data/spec/lib/archangel/liquid/tags/asset_tag_spec.rb +0 -91
- data/spec/lib/archangel/liquid/tags/collection_tag_spec.rb +0 -104
- data/spec/lib/archangel/liquid/tags/collectionfor_tag_spec.rb +0 -163
- data/spec/lib/archangel/liquid/tags/csrf_meta_tags_tag_spec.rb +0 -33
- data/spec/lib/archangel/liquid/tags/gist_tag_spec.rb +0 -42
- data/spec/lib/archangel/liquid/tags/locale_tag_spec.rb +0 -22
- data/spec/lib/archangel/liquid/tags/meta_tags_tag_spec.rb +0 -24
- data/spec/lib/archangel/liquid/tags/noembed_tag_spec.rb +0 -76
- data/spec/lib/archangel/liquid/tags/text_direction_tag_spec.rb +0 -32
- data/spec/lib/archangel/liquid/tags/theme_javascript_tag_spec.rb +0 -26
- data/spec/lib/archangel/liquid/tags/theme_stylesheet_tag_spec.rb +0 -28
- data/spec/lib/archangel/liquid/tags/vimeo_tag_spec.rb +0 -39
- data/spec/lib/archangel/liquid/tags/widget_tag_spec.rb +0 -59
- data/spec/lib/archangel/liquid/tags/youtube_tag_spec.rb +0 -39
- data/spec/models/archangel/entry_spec.rb +0 -62
- data/spec/models/archangel/template_spec.rb +0 -45
- data/spec/policies/archangel/application_policy_spec.rb +0 -8
- data/spec/services/archangel/render_service_spec.rb +0 -37
- data/spec/services/archangel/template_render_service_spec.rb +0 -42
- data/spec/support/.keep +0 -0
- data/spec/uploaders/archangel/avatar_uploader_spec.rb +0 -50
- data/spec/uploaders/archangel/logo_uploader_spec.rb +0 -50
- data/vendor/assets/icons/trumbowyg/icons.svg +0 -1
- data/vendor/assets/javascripts/daterangepicker/daterangepicker.js +0 -1529
- data/vendor/assets/javascripts/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js +0 -143
- data/vendor/assets/javascripts/trumbowyg/plugins/base64/trumbowyg.base64.js +0 -129
- data/vendor/assets/javascripts/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +0 -110
- data/vendor/assets/javascripts/trumbowyg/plugins/colors/trumbowyg.colors.js +0 -183
- data/vendor/assets/javascripts/trumbowyg/plugins/noembed/trumbowyg.noembed.js +0 -104
- data/vendor/assets/javascripts/trumbowyg/plugins/upload/trumbowyg.upload.js +0 -261
- data/vendor/assets/javascripts/trumbowyg/trumbowyg.js +0 -1765
- data/vendor/assets/stylesheets/daterangepicker/_daterangepicker.scss +0 -405
- data/vendor/assets/stylesheets/trumbowyg/_trumbowyg.scss +0 -831
- data/vendor/assets/stylesheets/trumbowyg/plugins/colors/_trumbowyg.colors.scss +0 -38
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails_helper"
|
4
|
-
|
5
|
-
module Archangel
|
6
|
-
RSpec.describe Template, type: :model do
|
7
|
-
context "validations" do
|
8
|
-
it { is_expected.to validate_presence_of(:content) }
|
9
|
-
it { is_expected.to validate_presence_of(:name) }
|
10
|
-
|
11
|
-
it { is_expected.to allow_value(true).for(:partial) }
|
12
|
-
it { is_expected.to allow_value(false).for(:partial) }
|
13
|
-
|
14
|
-
it { is_expected.to_not allow_value(nil).for(:partial) }
|
15
|
-
|
16
|
-
it { is_expected.to allow_value("{{ foo }}").for(:content) }
|
17
|
-
it { is_expected.to_not allow_value("{{ foo }").for(:content) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context "associations" do
|
21
|
-
it { is_expected.to belong_to(:site) }
|
22
|
-
|
23
|
-
it "belongs to Template" do
|
24
|
-
expect(subject).to(
|
25
|
-
belong_to(:parent).conditions(partial: false)
|
26
|
-
.class_name("Archangel::Template")
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "#status" do
|
32
|
-
it "returns `partial` for partial Templates" do
|
33
|
-
page = build(:template, :partial)
|
34
|
-
|
35
|
-
expect(page.status).to eq("partial")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns `full` for non-partial Templates" do
|
39
|
-
page = build(:template)
|
40
|
-
|
41
|
-
expect(page.status).to eq("full")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails_helper"
|
4
|
-
|
5
|
-
module Archangel
|
6
|
-
RSpec.describe RenderService, type: :service do
|
7
|
-
context "#new" do
|
8
|
-
it "builds the liquid content" do
|
9
|
-
content = <<-LIQUID
|
10
|
-
{% assign foo="bar" %}
|
11
|
-
~{{ foo }}~
|
12
|
-
*{{ bat }}*
|
13
|
-
LIQUID
|
14
|
-
|
15
|
-
rendered = described_class.new(content, bat: "baz").call
|
16
|
-
|
17
|
-
expect(rendered).to include("~bar~")
|
18
|
-
expect(rendered).to include("*baz*")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context ".call" do
|
23
|
-
it "builds the liquid content" do
|
24
|
-
content = <<-LIQUID
|
25
|
-
{% assign foo="bar" %}
|
26
|
-
~{{ foo }}~
|
27
|
-
*{{ bat }}*
|
28
|
-
LIQUID
|
29
|
-
|
30
|
-
rendered = described_class.call(content, bat: "baz")
|
31
|
-
|
32
|
-
expect(rendered).to include("~bar~")
|
33
|
-
expect(rendered).to include("*baz*")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails_helper"
|
4
|
-
|
5
|
-
module Archangel
|
6
|
-
RSpec.describe TemplateRenderService, type: :service do
|
7
|
-
context "#new" do
|
8
|
-
it "builds the liquid content" do
|
9
|
-
template = create(:template)
|
10
|
-
content = "<p>This is the content of the page</p>"
|
11
|
-
|
12
|
-
rendered = described_class.new(template,
|
13
|
-
content_for_layout: content).call
|
14
|
-
|
15
|
-
expect(rendered).to include("<p>This is the content of the page</p>")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context ".call" do
|
20
|
-
it "builds the liquid content" do
|
21
|
-
template = create(:template)
|
22
|
-
content = "<p>This is the content of the page</p>"
|
23
|
-
|
24
|
-
rendered = described_class.call(template,
|
25
|
-
content_for_layout: content)
|
26
|
-
|
27
|
-
expect(rendered).to include("<p>This is the content of the page</p>")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "builds the liquid content even without `{{ content_for_layout }}`" do
|
31
|
-
template = create(:template, content: "FULL TEMPLATE")
|
32
|
-
content = "<p>Content of the page is still rendered</p>"
|
33
|
-
|
34
|
-
rendered = described_class.call(template,
|
35
|
-
content_for_layout: content)
|
36
|
-
|
37
|
-
expect(rendered)
|
38
|
-
.to include("<p>Content of the page is still rendered</p>")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/spec/support/.keep
DELETED
File without changes
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails_helper"
|
4
|
-
|
5
|
-
module Archangel
|
6
|
-
RSpec.describe AvatarUploader, type: :uploader do
|
7
|
-
let(:user) { create(:user) }
|
8
|
-
let(:uploader) { described_class.new(user, :avatar) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
described_class.enable_processing = true
|
12
|
-
|
13
|
-
uploader.store!(fixture_file_upload(uploader_test_image))
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
described_class.enable_processing = false
|
18
|
-
|
19
|
-
uploader.remove!
|
20
|
-
end
|
21
|
-
|
22
|
-
it "uses default image" do
|
23
|
-
expect(subject.default_url).to include("assets/archangel/fallback/avatar")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "scales an original image to be no larger than 512 by 512 pixels" do
|
27
|
-
expect(uploader).to be_no_larger_than(512, 512)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "scales a large image to be no larger than 256 by 256 pixels" do
|
31
|
-
expect(uploader.large).to be_no_larger_than(256, 256)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "scales a medium image to be no larger than 128 by 128 pixels" do
|
35
|
-
expect(uploader.medium).to be_no_larger_than(128, 128)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "scales a small image to be no larger than 64 by 64 pixels" do
|
39
|
-
expect(uploader.small).to be_no_larger_than(64, 64)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "scales a tiny image to be no larger than 32 by 32 pixels" do
|
43
|
-
expect(uploader.tiny).to be_no_larger_than(32, 32)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "makes the image with 666 permissions" do
|
47
|
-
expect(uploader).to have_permissions(0o666)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails_helper"
|
4
|
-
|
5
|
-
module Archangel
|
6
|
-
RSpec.describe LogoUploader, type: :uploader do
|
7
|
-
let(:site) { create(:site) }
|
8
|
-
let(:uploader) { described_class.new(site, :logo) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
described_class.enable_processing = true
|
12
|
-
|
13
|
-
uploader.store!(fixture_file_upload(uploader_test_image))
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
described_class.enable_processing = false
|
18
|
-
|
19
|
-
uploader.remove!
|
20
|
-
end
|
21
|
-
|
22
|
-
it "uses default image" do
|
23
|
-
expect(subject.default_url).to include("assets/archangel/fallback/logo")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "scales an original image to be no larger than 512 by 512 pixels" do
|
27
|
-
expect(uploader).to be_no_larger_than(512, 512)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "scales a large image to be no larger than 256 by 256 pixels" do
|
31
|
-
expect(uploader.large).to be_no_larger_than(256, 256)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "scales a medium image to be no larger than 128 by 128 pixels" do
|
35
|
-
expect(uploader.medium).to be_no_larger_than(128, 128)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "scales a small image to be no larger than 64 by 64 pixels" do
|
39
|
-
expect(uploader.small).to be_no_larger_than(64, 64)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "scales a tiny image to be no larger than 32 by 32 pixels" do
|
43
|
-
expect(uploader.tiny).to be_no_larger_than(32, 32)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "makes the image with 666 permissions" do
|
47
|
-
expect(uploader).to have_permissions(0o666)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg"><symbol id="trumbowyg-blockquote" viewBox="0 0 72 72"><path d="M21.3 31.9h-.6c.8-1.2 1.9-2.2 3.4-3.2 2.1-1.4 5-2.7 9.2-3.3l-1.4-8.9c-4.7.7-8.5 2.1-11.7 4-2.4 1.4-4.3 3.1-5.8 4.9-2.3 2.7-3.7 5.7-4.5 8.5-.8 2.8-1 5.4-1 7.5 0 2.3.3 4 .4 4.8 0 .1.1.3.1.4 1.2 5.4 6.1 9.5 11.9 9.5 6.7 0 12.2-5.4 12.2-12.2s-5.5-12-12.2-12zM49.5 31.9h-.6c.8-1.2 1.9-2.2 3.4-3.2 2.1-1.4 5-2.7 9.2-3.3l-1.4-8.9c-4.7.7-8.5 2.1-11.7 4-2.4 1.4-4.3 3.1-5.8 4.9-2.3 2.7-3.7 5.7-4.5 8.5-.8 2.8-1 5.4-1 7.5 0 2.3.3 4 .4 4.8 0 .1.1.3.1.4 1.2 5.4 6.1 9.5 11.9 9.5 6.7 0 12.2-5.4 12.2-12.2s-5.5-12-12.2-12z"/></symbol><symbol id="trumbowyg-bold" viewBox="0 0 72 72"><path d="M51.1 37.8c-1.1-1.4-2.5-2.5-4.2-3.3 1.2-.8 2.1-1.8 2.8-3 1-1.6 1.5-3.5 1.5-5.3 0-2-.6-4-1.7-5.8-1.1-1.8-2.8-3.2-4.8-4.1-2-.9-4.6-1.3-7.8-1.3h-16v42h16.3c2.6 0 4.8-.2 6.7-.7 1.9-.5 3.4-1.2 4.7-2.1 1.3-1 2.4-2.4 3.2-4.1.9-1.7 1.3-3.6 1.3-5.7.2-2.5-.5-4.7-2-6.6zM40.8 50.2c-.6.1-1.8.2-3.4.2h-9V38.5h8.3c2.5 0 4.4.2 5.6.6 1.2.4 2 1 2.7 2 .6.9 1 2 1 3.3 0 1.1-.2 2.1-.7 2.9-.5.9-1 1.5-1.7 1.9-.8.4-1.7.8-2.8 1zm2.6-20.4c-.5.7-1.3 1.3-2.5 1.6-.8.3-2.5.4-4.8.4h-7.7V21.6h7.1c1.4 0 2.6 0 3.6.1s1.7.2 2.2.4c1 .3 1.7.8 2.2 1.7.5.9.8 1.8.8 3-.1 1.3-.4 2.2-.9 3z"/></symbol><symbol id="trumbowyg-close" viewBox="0 0 72 72"><path d="M57 20.5l-5.4-5.4-15.5 15.5-15.6-15.5-5.4 5.4L30.7 36 15.1 51.5l5.4 5.4 15.6-15.5 15.5 15.5 5.4-5.4L41.5 36z"/></symbol><symbol id="trumbowyg-create-link" viewBox="0 0 72 72"><path d="M31.1 48.9l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9L15 50.4c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L11 41.8c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7c2.5-2.6 3.1-6.7 1.5-10l-5.9 5.9zM38.7 22.5l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2L42 38c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1c0 .1 0 .1 0 0z"/><path d="M44.2 30.5c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.3-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.9 40.6c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2zM49.9 55.4h-8.5v-5h8.5v-8.9h5.2v8.9h8.5v5h-8.5v8.9h-5.2v-8.9z"/></symbol><symbol id="trumbowyg-del" viewBox="0 0 72 72"><path d="M45.8 45c0 1-.3 1.9-.9 2.8-.6.9-1.6 1.6-3 2.1s-3.1.8-5 .8c-2.1 0-4-.4-5.7-1.1-1.7-.7-2.9-1.7-3.6-2.7-.8-1.1-1.3-2.6-1.5-4.5l-.1-.8-6.7.6v.9c.1 2.8.9 5.4 2.3 7.6 1.5 2.3 3.5 4 6.1 5.1 2.6 1.1 5.7 1.6 9.4 1.6 2.9 0 5.6-.5 8-1.6 2.4-1.1 4.3-2.7 5.6-4.7 1.3-2 2-4.2 2-6.5 0-1.6-.3-3.1-.9-4.5l-.2-.6H44c0 .1 1.8 2.3 1.8 5.5zM29 28.9c-.8-.8-1.2-1.7-1.2-2.9 0-.7.1-1.3.4-1.9.3-.6.7-1.1 1.4-1.6.6-.5 1.4-.9 2.5-1.1 1.1-.3 2.4-.4 3.9-.4 2.9 0 5 .6 6.3 1.7 1.3 1.1 2.1 2.7 2.4 5.1l.1.9 6.8-.5v-.9c-.1-2.5-.8-4.7-2.1-6.7s-3.2-3.5-5.6-4.5c-2.4-1-5.1-1.5-8.1-1.5-2.8 0-5.3.5-7.6 1.4-2.3 1-4.2 2.4-5.4 4.3-1.2 1.9-1.9 3.9-1.9 6.1 0 1.7.4 3.4 1.2 4.9l.3.5h11.8c-2.3-.9-3.9-1.7-5.2-2.9zm13.3-6.2zM22.7 20.3zM13 34.1h46.1v3.4H13z"/></symbol><symbol id="trumbowyg-em" viewBox="0 0 72 72"><path d="M26 57l10.1-42h7.2L33.2 57H26z"/></symbol><symbol id="trumbowyg-fullscreen" viewBox="0 0 72 72"><path d="M25.2 7.1H7.1v17.7l6.7-6.5 10.5 10.5 4.5-4.5-10.4-10.5zM47.2 7.1l6.5 6.7-10.5 10.5 4.5 4.5 10.5-10.4 6.7 6.8V7.1zM47.7 43.2l-4.5 4.5 10.4 10.5-6.8 6.7h18.1V47.2l-6.7 6.5zM24.3 43.2L13.8 53.6l-6.7-6.8v18.1h17.7l-6.5-6.7 10.5-10.5z"/><path fill="currentColor" d="M10.7 28.8h18.1V11.2l-6.6 6.4L11.6 7.1l-4.5 4.5 10.5 10.5zM60.8 28.8l-6.4-6.6 10.5-10.6-4.5-4.5-10.5 10.5-6.7-6.9v18.1zM60.4 64.9l4.5-4.5-10.5-10.5 6.9-6.7H43.2v17.6l6.6-6.4zM11.6 64.9l10.5-10.5 6.7 6.9V43.2H11.1l6.5 6.6L7.1 60.4z"/></symbol><symbol id="trumbowyg-h1" viewBox="0 0 72 72"><path d="M6.4 14.9h7.4v16.7h19.1V14.9h7.4V57h-7.4V38H13.8v19H6.4V14.9zM47.8 22.5c1.4 0 2.8-.1 4.1-.4 1.3-.2 2.5-.6 3.6-1.2 1.1-.5 2-1.3 2.8-2.1.8-.9 1.3-1.9 1.5-3.2h5.5v41.2h-7.4v-29H47.8v-5.3z"/></symbol><symbol id="trumbowyg-h2" viewBox="0 0 72 72"><path d="M1.5 14.9h7.4v16.7H28V14.9h7.4V57H28V38H8.8v19H1.5V14.9zM70.2 56.9H42c0-3.4.9-6.4 2.5-9s3.8-4.8 6.6-6.7c1.3-1 2.7-1.9 4.2-2.9 1.5-.9 2.8-1.9 4-3 1.2-1.1 2.2-2.2 3-3.4.8-1.2 1.2-2.7 1.2-4.3 0-.7-.1-1.5-.3-2.4s-.5-1.6-1-2.4c-.5-.7-1.2-1.3-2.1-1.8-.9-.5-2.1-.7-3.5-.7-1.3 0-2.4.3-3.3.8s-1.6 1.3-2.1 2.2-.9 2-1.2 3.3c-.3 1.3-.4 2.6-.4 4.1h-6.7c0-2.3.3-4.4.9-6.3.6-1.9 1.5-3.6 2.7-5 1.2-1.4 2.7-2.5 4.4-3.3 1.7-.8 3.8-1.2 6.1-1.2 2.5 0 4.6.4 6.3 1.2 1.7.8 3.1 1.9 4.1 3.1 1 1.3 1.8 2.6 2.2 4.1.4 1.5.6 2.9.6 4.2 0 1.6-.3 3.1-.8 4.5-.5 1.3-1.2 2.6-2.1 3.7-.9 1.1-1.8 2.2-2.9 3.1-1.1.9-2.2 1.8-3.4 2.7-1.2.8-2.4 1.6-3.5 2.4-1.2.7-2.3 1.5-3.3 2.2-1 .7-1.9 1.5-2.6 2.3-.7.8-1.3 1.7-1.5 2.6h20.1v5.9z"/></symbol><symbol id="trumbowyg-h3" viewBox="0 0 72 72"><path d="M1.4 14.5h7.4v16.7h19.1V14.5h7.4v42.1h-7.4v-19H8.8v19H1.4V14.5zM53.1 32.4c1.1 0 2.2 0 3.3-.2 1.1-.2 2.1-.5 2.9-1 .9-.5 1.6-1.2 2.1-2 .5-.9.8-1.9.8-3.2 0-1.8-.6-3.2-1.8-4.2-1.2-1.1-2.7-1.6-4.6-1.6-1.2 0-2.2.2-3.1.7-.9.5-1.6 1.1-2.2 1.9-.6.8-1 1.7-1.3 2.7-.3 1-.4 2-.4 3.1h-6.7c.1-2 .5-3.9 1.1-5.6.7-1.7 1.6-3.2 2.7-4.4s2.6-2.2 4.2-2.9c1.6-.7 3.5-1.1 5.6-1.1 1.6 0 3.2.2 4.7.7 1.6.5 2.9 1.2 4.2 2.1 1.2.9 2.2 2.1 3 3.4.7 1.4 1.1 3 1.1 4.8 0 2.1-.5 3.9-1.4 5.4-.9 1.6-2.4 2.7-4.4 3.4v.1c2.4.5 4.2 1.6 5.5 3.5 1.3 1.9 2 4.1 2 6.8 0 2-.4 3.7-1.2 5.3-.8 1.6-1.8 2.9-3.2 3.9-1.3 1.1-2.9 1.9-4.7 2.5-1.8.6-3.6.9-5.6.9-2.4 0-4.5-.3-6.3-1s-3.3-1.7-4.5-2.9c-1.2-1.3-2.1-2.8-2.7-4.5-.6-1.8-1-3.7-1-5.9h6.7c-.1 2.5.5 4.6 1.9 6.3 1.3 1.7 3.3 2.5 5.9 2.5 2.2 0 4.1-.6 5.6-1.9 1.5-1.3 2.3-3.1 2.3-5.4 0-1.6-.3-2.9-.9-3.8-.6-.9-1.5-1.7-2.5-2.2-1-.5-2.2-.8-3.4-.9-1.3-.1-2.6-.2-3.9-.1v-5.2z"/></symbol><symbol id="trumbowyg-h4" viewBox="0 0 72 72"><path d="M1.5 14.9h7.4v16.7H28V14.9h7.4V57H28V38H8.9v19H1.5V14.9zM70.5 47.2h-5.3V57h-6.4v-9.8H41.2v-6.7l17.7-24.8h6.4v26.2h5.3v5.3zm-24.2-5.3h12.5V23.7h-.1L46.3 41.9z"/></symbol><symbol id="trumbowyg-horizontal-rule" viewBox="0 0 72 72"><path d="M9.1 32h54v8h-54z"/></symbol><symbol id="trumbowyg-insert-image" viewBox="0 0 72 72"><path d="M64 17v38H8V17h56m8-8H0v54h72V9z"/><path d="M17.5 22C15 22 13 24 13 26.5s2 4.5 4.5 4.5 4.5-2 4.5-4.5-2-4.5-4.5-4.5zM16 50h27L29.5 32zM36 36.2l8.9-8.5L60.2 50H45.9S35.6 35.9 36 36.2z"/></symbol><symbol id="trumbowyg-italic" viewBox="0 0 72 72"><path d="M26 57l10.1-42h7.2L33.2 57H26z"/></symbol><symbol id="trumbowyg-justify-center" viewBox="0 0 72 72"><path d="M9 14h54v8H9zM9 50h54v8H9zM18 32h36v8H18z"/></symbol><symbol id="trumbowyg-justify-full" viewBox="0 0 72 72"><path d="M9 14h54v8H9zM9 50h54v8H9zM9 32h54v8H9z"/></symbol><symbol id="trumbowyg-justify-left" viewBox="0 0 72 72"><path d="M9 14h54v8H9zM9 50h54v8H9zM9 32h36v8H9z"/></symbol><symbol id="trumbowyg-justify-right" viewBox="0 0 72 72"><path d="M9 14h54v8H9zM9 50h54v8H9zM27 32h36v8H27z"/></symbol><symbol id="trumbowyg-link" viewBox="0 0 72 72"><path d="M30.9 49.1l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9l-5.2-5.2c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L10.8 42c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7C38 50.5 38.6 46.3 37 43l-6.1 6.1zM38.5 22.7l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2-6.5 6.5c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1z"/><path d="M44.1 30.7c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.2-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.8 40.8c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2z"/></symbol><symbol id="trumbowyg-ordered-list" viewBox="0 0 72 72"><path d="M27 14h36v8H27zM27 50h36v8H27zM27 32h36v8H27zM11.8 15.8V22h1.8v-7.8h-1.5l-2.1 1 .3 1.3zM12.1 38.5l.7-.6c1.1-1 2.1-2.1 2.1-3.4 0-1.4-1-2.4-2.7-2.4-1.1 0-2 .4-2.6.8l.5 1.3c.4-.3 1-.6 1.7-.6.9 0 1.3.5 1.3 1.1 0 .9-.9 1.8-2.6 3.3l-1 .9V40H15v-1.5h-2.9zM13.3 53.9c1-.4 1.4-1 1.4-1.8 0-1.1-.9-1.9-2.6-1.9-1 0-1.9.3-2.4.6l.4 1.3c.3-.2 1-.5 1.6-.5.8 0 1.2.3 1.2.8 0 .7-.8.9-1.4.9h-.7v1.3h.7c.8 0 1.6.3 1.6 1.1 0 .6-.5 1-1.4 1-.7 0-1.5-.3-1.8-.5l-.4 1.4c.5.3 1.3.6 2.3.6 2 0 3.2-1 3.2-2.4 0-1.1-.8-1.8-1.7-1.9z"/></symbol><symbol id="trumbowyg-p" viewBox="0 0 72 72"><path d="M47.8 15.1H30.1c-4.7 0-8.5 3.7-8.5 8.4s3.7 8.4 8.4 8.4v25h7V19.8h3v37.1h4.1V19.8h3.7v-4.7z"/></symbol><symbol id="trumbowyg-redo" viewBox="0 0 72 72"><path d="M10.8 51.2c0-5.1 2.1-9.7 5.4-13.1 3.3-3.3 8-5.4 13.1-5.4H46v-12L61.3 36 45.9 51.3V39.1H29.3c-3.3 0-6.4 1.3-8.5 3.5-2.2 2.2-3.5 5.2-3.5 8.5h-6.5z"/></symbol><symbol id="trumbowyg-removeformat" viewBox="0 0 72 72"><path d="M58.2 54.6L52 48.5l3.6-3.6 6.1 6.1 6.4-6.4 3.8 3.8-6.4 6.4 6.1 6.1-3.6 3.6-6.1-6.1-6.4 6.4-3.7-3.8 6.4-6.4zM21.7 52.1H50V57H21.7zM18.8 15.2h34.1v6.4H39.5v24.2h-7.4V21.5H18.8v-6.3z"/></symbol><symbol id="trumbowyg-strikethrough" viewBox="0 0 72 72"><path d="M45.8 45c0 1-.3 1.9-.9 2.8-.6.9-1.6 1.6-3 2.1s-3.1.8-5 .8c-2.1 0-4-.4-5.7-1.1-1.7-.7-2.9-1.7-3.6-2.7-.8-1.1-1.3-2.6-1.5-4.5l-.1-.8-6.7.6v.9c.1 2.8.9 5.4 2.3 7.6 1.5 2.3 3.5 4 6.1 5.1 2.6 1.1 5.7 1.6 9.4 1.6 2.9 0 5.6-.5 8-1.6 2.4-1.1 4.3-2.7 5.6-4.7 1.3-2 2-4.2 2-6.5 0-1.6-.3-3.1-.9-4.5l-.2-.6H44c0 .1 1.8 2.3 1.8 5.5zM29 28.9c-.8-.8-1.2-1.7-1.2-2.9 0-.7.1-1.3.4-1.9.3-.6.7-1.1 1.4-1.6.6-.5 1.4-.9 2.5-1.1 1.1-.3 2.4-.4 3.9-.4 2.9 0 5 .6 6.3 1.7 1.3 1.1 2.1 2.7 2.4 5.1l.1.9 6.8-.5v-.9c-.1-2.5-.8-4.7-2.1-6.7s-3.2-3.5-5.6-4.5c-2.4-1-5.1-1.5-8.1-1.5-2.8 0-5.3.5-7.6 1.4-2.3 1-4.2 2.4-5.4 4.3-1.2 1.9-1.9 3.9-1.9 6.1 0 1.7.4 3.4 1.2 4.9l.3.5h11.8c-2.3-.9-3.9-1.7-5.2-2.9zm13.3-6.2zM22.7 20.3zM13 34.1h46.1v3.4H13z"/></symbol><symbol id="trumbowyg-strong" viewBox="0 0 72 72"><path d="M51.1 37.8c-1.1-1.4-2.5-2.5-4.2-3.3 1.2-.8 2.1-1.8 2.8-3 1-1.6 1.5-3.5 1.5-5.3 0-2-.6-4-1.7-5.8-1.1-1.8-2.8-3.2-4.8-4.1-2-.9-4.6-1.3-7.8-1.3h-16v42h16.3c2.6 0 4.8-.2 6.7-.7 1.9-.5 3.4-1.2 4.7-2.1 1.3-1 2.4-2.4 3.2-4.1.9-1.7 1.3-3.6 1.3-5.7.2-2.5-.5-4.7-2-6.6zM40.8 50.2c-.6.1-1.8.2-3.4.2h-9V38.5h8.3c2.5 0 4.4.2 5.6.6 1.2.4 2 1 2.7 2 .6.9 1 2 1 3.3 0 1.1-.2 2.1-.7 2.9-.5.9-1 1.5-1.7 1.9-.8.4-1.7.8-2.8 1zm2.6-20.4c-.5.7-1.3 1.3-2.5 1.6-.8.3-2.5.4-4.8.4h-7.7V21.6h7.1c1.4 0 2.6 0 3.6.1s1.7.2 2.2.4c1 .3 1.7.8 2.2 1.7.5.9.8 1.8.8 3-.1 1.3-.4 2.2-.9 3z"/></symbol><symbol id="trumbowyg-subscript" viewBox="0 0 72 72"><path d="M32 15h7.8L56 57.1h-7.9L44.3 46H27.4l-4 11.1h-7.6L32 15zm-2.5 25.4h12.9L36 22.3h-.2l-6.3 18.1zM58.7 59.9c.6-1.4 2-2.8 4.1-4.4 1.9-1.3 3.1-2.3 3.7-2.9.8-.9 1.3-1.9 1.3-3 0-.9-.2-1.6-.7-2.2-.5-.6-1.2-.9-2.1-.9-1.2 0-2.1.5-2.5 1.4-.3.5-.4 1.4-.5 2.5h-4c.1-1.8.4-3.2 1-4.3 1.1-2.1 3-3.1 5.8-3.1 2.2 0 3.9.6 5.2 1.8 1.3 1.2 1.9 2.8 1.9 4.8 0 1.5-.5 2.9-1.4 4.1-.6.8-1.6 1.7-3 2.6L66 57.7c-1 .7-1.7 1.2-2.1 1.6-.4.3-.7.7-1 1.1H72V64H57.8c0-1.5.3-2.8.9-4.1z"/></symbol><symbol id="trumbowyg-superscript" viewBox="0 0 72 72"><path d="M32 15h7.8L56 57.1h-7.9l-4-11.1H27.4l-4 11.1h-7.6L32 15zm-2.5 25.4h12.9L36 22.3h-.2l-6.3 18.1zM49.6 28.8c.5-1.1 1.6-2.3 3.4-3.6 1.5-1.1 2.5-1.9 3-2.4.7-.7 1-1.6 1-2.4 0-.7-.2-1.3-.6-1.8-.4-.5-1-.7-1.7-.7-1 0-1.7.4-2.1 1.1-.2.4-.3 1.1-.4 2.1H49c.1-1.5.3-2.6.8-3.5.9-1.7 2.5-2.6 4.8-2.6 1.8 0 3.2.5 4.3 1.5 1.1 1 1.6 2.3 1.6 4 0 1.3-.4 2.4-1.1 3.4-.5.7-1.3 1.4-2.4 2.2l-1.3 1c-.8.6-1.4 1-1.7 1.3-.3.3-.6.6-.8.9h7.4v3H48.8c0-1.3.3-2.4.8-3.5z"/></symbol><symbol id="trumbowyg-underline" viewBox="0 0 72 72"><path d="M36 35zM15.2 55.9h41.6V59H15.2zM21.1 13.9h6.4v21.2c0 1.2.1 2.5.2 3.7.1 1.3.5 2.4 1 3.4.6 1 1.4 1.8 2.6 2.5 1.1.6 2.7 1 4.8 1 2.1 0 3.7-.3 4.8-1 1.1-.6 2-1.5 2.6-2.5.6-1 .9-2.1 1-3.4.1-1.3.2-2.5.2-3.7V13.9H51v23.3c0 2.3-.4 4.4-1.1 6.1-.7 1.7-1.7 3.2-3 4.4-1.3 1.2-2.9 2-4.7 2.6-1.8.6-3.9.9-6.1.9-2.2 0-4.3-.3-6.1-.9-1.8-.6-3.4-1.5-4.7-2.6-1.3-1.2-2.3-2.6-3-4.4-.7-1.7-1.1-3.8-1.1-6.1V13.9z"/></symbol><symbol id="trumbowyg-undo" viewBox="0 0 72 72"><path d="M61.2 51.2c0-5.1-2.1-9.7-5.4-13.1-3.3-3.3-8-5.4-13.1-5.4H26.1v-12L10.8 36l15.3 15.3V39.1h16.7c3.3 0 6.4 1.3 8.5 3.5 2.2 2.2 3.5 5.2 3.5 8.5h6.4z"/></symbol><symbol id="trumbowyg-unlink" viewBox="0 0 72 72"><path d="M30.9 49.1l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9l-5.2-5.2c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L10.8 42c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7C38 50.5 38.6 46.3 37 43l-6.1 6.1zM38.5 22.7l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2-6.5 6.5c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1z"/><path d="M44.1 30.7c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.2-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.8 40.8c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2zM41.3 55.8v-5h22.2v5H41.3z"/></symbol><symbol id="trumbowyg-unordered-list" viewBox="0 0 72 72"><path d="M27 14h36v8H27zM27 50h36v8H27zM9 50h9v8H9zM9 32h9v8H9zM9 14h9v8H9zM27 32h36v8H27z"/></symbol><symbol id="trumbowyg-view-html" viewBox="0 0 72 72"><path fill="none" stroke="currentColor" stroke-width="8" stroke-miterlimit="10" d="M26.9 17.9L9 36.2 26.9 54M45 54l17.9-18.3L45 17.9"/></symbol><symbol id="trumbowyg-base64" viewBox="0 0 72 72"><path d="M64 17v38H8V17h56m8-8H0v54h72V9z"/><path d="M29.9 28.9c-.5-.5-1.1-.8-1.8-.8s-1.4.2-1.9.7c-.5.4-.9 1-1.2 1.6-.3.6-.5 1.3-.6 2.1-.1.7-.2 1.4-.2 1.9l.1.1c.6-.8 1.2-1.4 2-1.8.8-.4 1.7-.5 2.7-.5.9 0 1.8.2 2.6.6.8.4 1.6.9 2.2 1.5.6.6 1 1.3 1.2 2.2.3.8.4 1.6.4 2.5 0 1.1-.2 2.1-.5 3-.3.9-.8 1.7-1.5 2.4-.6.7-1.4 1.2-2.3 1.6-.9.4-1.9.6-3 .6-1.6 0-2.8-.3-3.9-.9-1-.6-1.8-1.4-2.5-2.4-.6-1-1-2.1-1.3-3.4-.2-1.3-.4-2.6-.4-3.9 0-1.3.1-2.6.4-3.8.3-1.3.8-2.4 1.4-3.5.7-1 1.5-1.9 2.5-2.5 1-.6 2.3-1 3.8-1 .9 0 1.7.1 2.5.4.8.3 1.4.6 2 1.1.6.5 1.1 1.1 1.4 1.8.4.7.6 1.5.7 2.5h-4c0-1-.3-1.6-.8-2.1zm-3.5 6.8c-.4.2-.8.5-1 .8-.3.4-.5.8-.6 1.2-.1.5-.2 1-.2 1.5s.1.9.2 1.4c.1.5.4.9.6 1.2.3.4.6.7 1 .9.4.2.9.3 1.4.3.5 0 1-.1 1.3-.3.4-.2.7-.5 1-.9.3-.4.5-.8.6-1.2.1-.5.2-.9.2-1.4 0-.5-.1-1-.2-1.4-.1-.5-.3-.9-.6-1.2-.3-.4-.6-.7-1-.9-.4-.2-.9-.3-1.4-.3-.4 0-.9.1-1.3.3zM36.3 41.3v-3.8l9-12.1H49v12.4h2.7v3.5H49v4.8h-4v-4.8h-8.7zM45 30.7l-5.3 7.2h5.4l-.1-7.2z"/></symbol><symbol id="trumbowyg-back-color" viewBox="0 0 72 72"><path d="M36.5 22.3l-6.3 18.1H43l-6.3-18.1z"/><path d="M9 8.9v54.2h54.1V8.9H9zm39.9 48.2L45 46H28.2l-3.9 11.1h-7.6L32.8 15h7.8l16.2 42.1h-7.9z"/></symbol><symbol id="trumbowyg-fore-color" viewBox="0 0 72 72"><path d="M32 15h7.8L56 57.1h-7.9l-4-11.1H27.4l-4 11.1h-7.6L32 15zm-2.5 25.4h12.9L36 22.3h-.2l-6.3 18.1z"/></symbol><symbol id="trumbowyg-noembed" viewBox="0 0 72 72"><path d="M31.5 33.6V25l11 11-11 11v-8.8z"/><path d="M64 17v38H8V17h56m8-8H0v54h72V9z"/></symbol><symbol id="trumbowyg-upload" viewBox="0 0 72 72"><path d="M64 27v28H8V27H0v36h72V27h-8z"/><path d="M32.1 6.7h8v33.6h-8z"/><path d="M48 35.9L36 49.6 24 36h24z"/></symbol><symbol id="trumbowyg-preformatted" viewBox="0 0 72 72"><path d="M10.3 33.5c.4 0 .9-.1 1.5-.2s1.2-.3 1.8-.7c.6-.3 1.1-.8 1.5-1.3.4-.5.6-1.3.6-2.1V17.1c0-1.4.3-2.6.8-3.6s1.2-1.9 2-2.5c.8-.7 1.6-1.2 2.5-1.5.9-.3 1.6-.5 2.2-.5h5.3v5.3h-3.2c-.7 0-1.3.1-1.8.4-.4.3-.8.6-1 1-.2.4-.4.9-.4 1.3-.1.5-.1.9-.1 1.4v11.4c0 1.2-.2 2.1-.7 2.9-.5.8-1 1.4-1.7 1.8-.6.4-1.3.8-2 1-.7.2-1.3.3-1.7.4v.1c.5 0 1 .1 1.7.3.7.2 1.3.5 2 .9.6.5 1.2 1.1 1.7 1.9.5.8.7 2 .7 3.4v11.1c0 .4 0 .9.1 1.4.1.5.2.9.4 1.3s.6.7 1 1c.4.3 1 .4 1.8.4h3.2V63h-5.3c-.6 0-1.4-.2-2.2-.5-.9-.3-1.7-.8-2.5-1.5s-1.4-1.5-2-2.5c-.5-1-.8-2.2-.8-3.6V43.5c0-.9-.2-1.7-.6-2.3-.4-.6-.9-1.1-1.5-1.5-.6-.4-1.2-.6-1.8-.7-.6-.1-1.1-.2-1.5-.2v-5.3zM61.8 38.7c-.4 0-1 .1-1.6.2-.6.1-1.2.4-1.8.7-.6.3-1.1.7-1.5 1.3-.4.5-.6 1.3-.6 2.1v12.1c0 1.4-.3 2.6-.8 3.6s-1.2 1.9-2 2.5c-.8.7-1.6 1.2-2.5 1.5-.9.3-1.6.5-2.2.5h-5.3v-5.3h3.2c.7 0 1.3-.1 1.8-.4.4-.3.8-.6 1-1 .2-.4.4-.9.4-1.3.1-.5.1-.9.1-1.4V42.3c0-1.2.2-2.1.7-2.9.5-.8 1-1.4 1.7-1.8.6-.4 1.3-.8 2-1 .7-.2 1.3-.3 1.7-.4v-.1c-.5 0-1-.1-1.7-.3-.7-.2-1.3-.5-2-.9-.6-.4-1.2-1.1-1.7-1.9-.5-.8-.7-2-.7-3.4V18.5c0-.4 0-.9-.1-1.4-.1-.5-.2-.9-.4-1.3s-.6-.7-1-1c-.4-.3-1-.4-1.8-.4h-3.2V9.1h5.3c.6 0 1.4.2 2.2.5.9.3 1.7.8 2.5 1.5s1.4 1.5 2 2.5c.5 1 .8 2.2.8 3.6v11.6c0 .9.2 1.7.6 2.3.4.6.9 1.1 1.5 1.5.6.4 1.2.6 1.8.7.6.1 1.2.2 1.6.2v5.2z"/></symbol></svg>
|
@@ -1,1529 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @version: 3.0.2
|
3
|
-
* @author: Dan Grossman http://www.dangrossman.info/
|
4
|
-
* @copyright: Copyright (c) 2012-2018 Dan Grossman. All rights reserved.
|
5
|
-
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
6
|
-
* @website: http://www.daterangepicker.com/
|
7
|
-
*/
|
8
|
-
// Following the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
|
9
|
-
(function (root, factory) {
|
10
|
-
if (typeof define === 'function' && define.amd) {
|
11
|
-
// AMD. Make globaly available as well
|
12
|
-
define(['moment', 'jquery'], function (moment, jquery) {
|
13
|
-
if (!jquery.fn) jquery.fn = {}; // webpack server rendering
|
14
|
-
return factory(moment, jquery);
|
15
|
-
});
|
16
|
-
} else if (typeof module === 'object' && module.exports) {
|
17
|
-
// Node / Browserify
|
18
|
-
//isomorphic issue
|
19
|
-
var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;
|
20
|
-
if (!jQuery) {
|
21
|
-
jQuery = require('jquery');
|
22
|
-
if (!jQuery.fn) jQuery.fn = {};
|
23
|
-
}
|
24
|
-
var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment');
|
25
|
-
module.exports = factory(moment, jQuery);
|
26
|
-
} else {
|
27
|
-
// Browser globals
|
28
|
-
root.daterangepicker = factory(root.moment, root.jQuery);
|
29
|
-
}
|
30
|
-
}(this, function(moment, $) {
|
31
|
-
var DateRangePicker = function(element, options, cb) {
|
32
|
-
|
33
|
-
//default settings for options
|
34
|
-
this.parentEl = 'body';
|
35
|
-
this.element = $(element);
|
36
|
-
this.startDate = moment().startOf('day');
|
37
|
-
this.endDate = moment().endOf('day');
|
38
|
-
this.minDate = false;
|
39
|
-
this.maxDate = false;
|
40
|
-
this.maxSpan = false;
|
41
|
-
this.autoApply = false;
|
42
|
-
this.singleDatePicker = false;
|
43
|
-
this.showDropdowns = false;
|
44
|
-
this.minYear = moment().subtract(100, 'year').format('YYYY');
|
45
|
-
this.maxYear = moment().add(100, 'year').format('YYYY');
|
46
|
-
this.showWeekNumbers = false;
|
47
|
-
this.showISOWeekNumbers = false;
|
48
|
-
this.showCustomRangeLabel = true;
|
49
|
-
this.timePicker = false;
|
50
|
-
this.timePicker24Hour = false;
|
51
|
-
this.timePickerIncrement = 1;
|
52
|
-
this.timePickerSeconds = false;
|
53
|
-
this.linkedCalendars = true;
|
54
|
-
this.autoUpdateInput = true;
|
55
|
-
this.alwaysShowCalendars = false;
|
56
|
-
this.ranges = {};
|
57
|
-
|
58
|
-
this.opens = 'right';
|
59
|
-
if (this.element.hasClass('pull-right'))
|
60
|
-
this.opens = 'left';
|
61
|
-
|
62
|
-
this.drops = 'down';
|
63
|
-
if (this.element.hasClass('dropup'))
|
64
|
-
this.drops = 'up';
|
65
|
-
|
66
|
-
this.buttonClasses = 'btn btn-sm';
|
67
|
-
this.applyButtonClasses = 'btn-primary';
|
68
|
-
this.cancelButtonClasses = 'btn-default';
|
69
|
-
|
70
|
-
this.locale = {
|
71
|
-
direction: 'ltr',
|
72
|
-
format: moment.localeData().longDateFormat('L'),
|
73
|
-
separator: ' - ',
|
74
|
-
applyLabel: 'Apply',
|
75
|
-
cancelLabel: 'Cancel',
|
76
|
-
weekLabel: 'W',
|
77
|
-
customRangeLabel: 'Custom Range',
|
78
|
-
daysOfWeek: moment.weekdaysMin(),
|
79
|
-
monthNames: moment.monthsShort(),
|
80
|
-
firstDay: moment.localeData().firstDayOfWeek()
|
81
|
-
};
|
82
|
-
|
83
|
-
this.callback = function() { };
|
84
|
-
|
85
|
-
//some state information
|
86
|
-
this.isShowing = false;
|
87
|
-
this.leftCalendar = {};
|
88
|
-
this.rightCalendar = {};
|
89
|
-
|
90
|
-
//custom options from user
|
91
|
-
if (typeof options !== 'object' || options === null)
|
92
|
-
options = {};
|
93
|
-
|
94
|
-
//allow setting options with data attributes
|
95
|
-
//data-api options will be overwritten with custom javascript options
|
96
|
-
options = $.extend(this.element.data(), options);
|
97
|
-
|
98
|
-
//html template for the picker UI
|
99
|
-
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
100
|
-
options.template =
|
101
|
-
'<div class="daterangepicker">' +
|
102
|
-
'<div class="ranges"></div>' +
|
103
|
-
'<div class="drp-calendar left">' +
|
104
|
-
'<div class="calendar-table"></div>' +
|
105
|
-
'<div class="calendar-time"></div>' +
|
106
|
-
'</div>' +
|
107
|
-
'<div class="drp-calendar right">' +
|
108
|
-
'<div class="calendar-table"></div>' +
|
109
|
-
'<div class="calendar-time"></div>' +
|
110
|
-
'</div>' +
|
111
|
-
'<div class="drp-buttons">' +
|
112
|
-
'<span class="drp-selected"></span>' +
|
113
|
-
'<button class="cancelBtn" type="button"></button>' +
|
114
|
-
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
115
|
-
'</div>' +
|
116
|
-
'</div>';
|
117
|
-
|
118
|
-
this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
|
119
|
-
this.container = $(options.template).appendTo(this.parentEl);
|
120
|
-
|
121
|
-
//
|
122
|
-
// handle all the possible options overriding defaults
|
123
|
-
//
|
124
|
-
|
125
|
-
if (typeof options.locale === 'object') {
|
126
|
-
|
127
|
-
if (typeof options.locale.direction === 'string')
|
128
|
-
this.locale.direction = options.locale.direction;
|
129
|
-
|
130
|
-
if (typeof options.locale.format === 'string')
|
131
|
-
this.locale.format = options.locale.format;
|
132
|
-
|
133
|
-
if (typeof options.locale.separator === 'string')
|
134
|
-
this.locale.separator = options.locale.separator;
|
135
|
-
|
136
|
-
if (typeof options.locale.daysOfWeek === 'object')
|
137
|
-
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
138
|
-
|
139
|
-
if (typeof options.locale.monthNames === 'object')
|
140
|
-
this.locale.monthNames = options.locale.monthNames.slice();
|
141
|
-
|
142
|
-
if (typeof options.locale.firstDay === 'number')
|
143
|
-
this.locale.firstDay = options.locale.firstDay;
|
144
|
-
|
145
|
-
if (typeof options.locale.applyLabel === 'string')
|
146
|
-
this.locale.applyLabel = options.locale.applyLabel;
|
147
|
-
|
148
|
-
if (typeof options.locale.cancelLabel === 'string')
|
149
|
-
this.locale.cancelLabel = options.locale.cancelLabel;
|
150
|
-
|
151
|
-
if (typeof options.locale.weekLabel === 'string')
|
152
|
-
this.locale.weekLabel = options.locale.weekLabel;
|
153
|
-
|
154
|
-
if (typeof options.locale.customRangeLabel === 'string'){
|
155
|
-
//Support unicode chars in the custom range name.
|
156
|
-
var elem = document.createElement('textarea');
|
157
|
-
elem.innerHTML = options.locale.customRangeLabel;
|
158
|
-
var rangeHtml = elem.value;
|
159
|
-
this.locale.customRangeLabel = rangeHtml;
|
160
|
-
}
|
161
|
-
}
|
162
|
-
this.container.addClass(this.locale.direction);
|
163
|
-
|
164
|
-
if (typeof options.startDate === 'string')
|
165
|
-
this.startDate = moment(options.startDate, this.locale.format);
|
166
|
-
|
167
|
-
if (typeof options.endDate === 'string')
|
168
|
-
this.endDate = moment(options.endDate, this.locale.format);
|
169
|
-
|
170
|
-
if (typeof options.minDate === 'string')
|
171
|
-
this.minDate = moment(options.minDate, this.locale.format);
|
172
|
-
|
173
|
-
if (typeof options.maxDate === 'string')
|
174
|
-
this.maxDate = moment(options.maxDate, this.locale.format);
|
175
|
-
|
176
|
-
if (typeof options.startDate === 'object')
|
177
|
-
this.startDate = moment(options.startDate);
|
178
|
-
|
179
|
-
if (typeof options.endDate === 'object')
|
180
|
-
this.endDate = moment(options.endDate);
|
181
|
-
|
182
|
-
if (typeof options.minDate === 'object')
|
183
|
-
this.minDate = moment(options.minDate);
|
184
|
-
|
185
|
-
if (typeof options.maxDate === 'object')
|
186
|
-
this.maxDate = moment(options.maxDate);
|
187
|
-
|
188
|
-
// sanity check for bad options
|
189
|
-
if (this.minDate && this.startDate.isBefore(this.minDate))
|
190
|
-
this.startDate = this.minDate.clone();
|
191
|
-
|
192
|
-
// sanity check for bad options
|
193
|
-
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
194
|
-
this.endDate = this.maxDate.clone();
|
195
|
-
|
196
|
-
if (typeof options.applyButtonClasses === 'string')
|
197
|
-
this.applyButtonClasses = options.applyButtonClasses;
|
198
|
-
|
199
|
-
if (typeof options.applyClass === 'string') //backwards compat
|
200
|
-
this.applyButtonClasses = options.applyClass;
|
201
|
-
|
202
|
-
if (typeof options.cancelButtonClasses === 'string')
|
203
|
-
this.cancelButtonClasses = options.cancelButtonClasses;
|
204
|
-
|
205
|
-
if (typeof options.cancelClass === 'string') //backwards compat
|
206
|
-
this.cancelButtonClasses = options.cancelClass;
|
207
|
-
|
208
|
-
if (typeof options.maxSpan === 'object')
|
209
|
-
this.maxSpan = options.maxSpan;
|
210
|
-
|
211
|
-
if (typeof options.dateLimit === 'object') //backwards compat
|
212
|
-
this.maxSpan = options.dateLimit;
|
213
|
-
|
214
|
-
if (typeof options.opens === 'string')
|
215
|
-
this.opens = options.opens;
|
216
|
-
|
217
|
-
if (typeof options.drops === 'string')
|
218
|
-
this.drops = options.drops;
|
219
|
-
|
220
|
-
if (typeof options.showWeekNumbers === 'boolean')
|
221
|
-
this.showWeekNumbers = options.showWeekNumbers;
|
222
|
-
|
223
|
-
if (typeof options.showISOWeekNumbers === 'boolean')
|
224
|
-
this.showISOWeekNumbers = options.showISOWeekNumbers;
|
225
|
-
|
226
|
-
if (typeof options.buttonClasses === 'string')
|
227
|
-
this.buttonClasses = options.buttonClasses;
|
228
|
-
|
229
|
-
if (typeof options.buttonClasses === 'object')
|
230
|
-
this.buttonClasses = options.buttonClasses.join(' ');
|
231
|
-
|
232
|
-
if (typeof options.showDropdowns === 'boolean')
|
233
|
-
this.showDropdowns = options.showDropdowns;
|
234
|
-
|
235
|
-
if (typeof options.minYear === 'number')
|
236
|
-
this.minYear = options.minYear;
|
237
|
-
|
238
|
-
if (typeof options.maxYear === 'number')
|
239
|
-
this.maxYear = options.maxYear;
|
240
|
-
|
241
|
-
if (typeof options.showCustomRangeLabel === 'boolean')
|
242
|
-
this.showCustomRangeLabel = options.showCustomRangeLabel;
|
243
|
-
|
244
|
-
if (typeof options.singleDatePicker === 'boolean') {
|
245
|
-
this.singleDatePicker = options.singleDatePicker;
|
246
|
-
if (this.singleDatePicker)
|
247
|
-
this.endDate = this.startDate.clone();
|
248
|
-
}
|
249
|
-
|
250
|
-
if (typeof options.timePicker === 'boolean')
|
251
|
-
this.timePicker = options.timePicker;
|
252
|
-
|
253
|
-
if (typeof options.timePickerSeconds === 'boolean')
|
254
|
-
this.timePickerSeconds = options.timePickerSeconds;
|
255
|
-
|
256
|
-
if (typeof options.timePickerIncrement === 'number')
|
257
|
-
this.timePickerIncrement = options.timePickerIncrement;
|
258
|
-
|
259
|
-
if (typeof options.timePicker24Hour === 'boolean')
|
260
|
-
this.timePicker24Hour = options.timePicker24Hour;
|
261
|
-
|
262
|
-
if (typeof options.autoApply === 'boolean')
|
263
|
-
this.autoApply = options.autoApply;
|
264
|
-
|
265
|
-
if (typeof options.autoUpdateInput === 'boolean')
|
266
|
-
this.autoUpdateInput = options.autoUpdateInput;
|
267
|
-
|
268
|
-
if (typeof options.linkedCalendars === 'boolean')
|
269
|
-
this.linkedCalendars = options.linkedCalendars;
|
270
|
-
|
271
|
-
if (typeof options.isInvalidDate === 'function')
|
272
|
-
this.isInvalidDate = options.isInvalidDate;
|
273
|
-
|
274
|
-
if (typeof options.isCustomDate === 'function')
|
275
|
-
this.isCustomDate = options.isCustomDate;
|
276
|
-
|
277
|
-
if (typeof options.alwaysShowCalendars === 'boolean')
|
278
|
-
this.alwaysShowCalendars = options.alwaysShowCalendars;
|
279
|
-
|
280
|
-
// update day names order to firstDay
|
281
|
-
if (this.locale.firstDay != 0) {
|
282
|
-
var iterator = this.locale.firstDay;
|
283
|
-
while (iterator > 0) {
|
284
|
-
this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
|
285
|
-
iterator--;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
var start, end, range;
|
290
|
-
|
291
|
-
//if no start/end dates set, check if an input element contains initial values
|
292
|
-
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
|
293
|
-
if ($(this.element).is(':text')) {
|
294
|
-
var val = $(this.element).val(),
|
295
|
-
split = val.split(this.locale.separator);
|
296
|
-
|
297
|
-
start = end = null;
|
298
|
-
|
299
|
-
if (split.length == 2) {
|
300
|
-
start = moment(split[0], this.locale.format);
|
301
|
-
end = moment(split[1], this.locale.format);
|
302
|
-
} else if (this.singleDatePicker && val !== "") {
|
303
|
-
start = moment(val, this.locale.format);
|
304
|
-
end = moment(val, this.locale.format);
|
305
|
-
}
|
306
|
-
if (start !== null && end !== null) {
|
307
|
-
this.setStartDate(start);
|
308
|
-
this.setEndDate(end);
|
309
|
-
}
|
310
|
-
}
|
311
|
-
}
|
312
|
-
|
313
|
-
if (typeof options.ranges === 'object') {
|
314
|
-
for (range in options.ranges) {
|
315
|
-
|
316
|
-
if (typeof options.ranges[range][0] === 'string')
|
317
|
-
start = moment(options.ranges[range][0], this.locale.format);
|
318
|
-
else
|
319
|
-
start = moment(options.ranges[range][0]);
|
320
|
-
|
321
|
-
if (typeof options.ranges[range][1] === 'string')
|
322
|
-
end = moment(options.ranges[range][1], this.locale.format);
|
323
|
-
else
|
324
|
-
end = moment(options.ranges[range][1]);
|
325
|
-
|
326
|
-
// If the start or end date exceed those allowed by the minDate or maxSpan
|
327
|
-
// options, shorten the range to the allowable period.
|
328
|
-
if (this.minDate && start.isBefore(this.minDate))
|
329
|
-
start = this.minDate.clone();
|
330
|
-
|
331
|
-
var maxDate = this.maxDate;
|
332
|
-
if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate))
|
333
|
-
maxDate = start.clone().add(this.maxSpan);
|
334
|
-
if (maxDate && end.isAfter(maxDate))
|
335
|
-
end = maxDate.clone();
|
336
|
-
|
337
|
-
// If the end of the range is before the minimum or the start of the range is
|
338
|
-
// after the maximum, don't display this range option at all.
|
339
|
-
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|
340
|
-
|| (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
|
341
|
-
continue;
|
342
|
-
|
343
|
-
//Support unicode chars in the range names.
|
344
|
-
var elem = document.createElement('textarea');
|
345
|
-
elem.innerHTML = range;
|
346
|
-
var rangeHtml = elem.value;
|
347
|
-
|
348
|
-
this.ranges[rangeHtml] = [start, end];
|
349
|
-
}
|
350
|
-
|
351
|
-
var list = '<ul>';
|
352
|
-
for (range in this.ranges) {
|
353
|
-
list += '<li data-range-key="' + range + '">' + range + '</li>';
|
354
|
-
}
|
355
|
-
if (this.showCustomRangeLabel) {
|
356
|
-
list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
|
357
|
-
}
|
358
|
-
list += '</ul>';
|
359
|
-
this.container.find('.ranges').prepend(list);
|
360
|
-
}
|
361
|
-
|
362
|
-
if (typeof cb === 'function') {
|
363
|
-
this.callback = cb;
|
364
|
-
}
|
365
|
-
|
366
|
-
if (!this.timePicker) {
|
367
|
-
this.startDate = this.startDate.startOf('day');
|
368
|
-
this.endDate = this.endDate.endOf('day');
|
369
|
-
this.container.find('.calendar-time').hide();
|
370
|
-
}
|
371
|
-
|
372
|
-
//can't be used together for now
|
373
|
-
if (this.timePicker && this.autoApply)
|
374
|
-
this.autoApply = false;
|
375
|
-
|
376
|
-
if (this.autoApply) {
|
377
|
-
this.container.addClass('auto-apply');
|
378
|
-
}
|
379
|
-
|
380
|
-
if (typeof options.ranges === 'object')
|
381
|
-
this.container.addClass('show-ranges');
|
382
|
-
|
383
|
-
if (this.singleDatePicker) {
|
384
|
-
this.container.addClass('single');
|
385
|
-
this.container.find('.drp-calendar.left').addClass('single');
|
386
|
-
this.container.find('.drp-calendar.left').show();
|
387
|
-
this.container.find('.drp-calendar.right').hide();
|
388
|
-
if (!this.timePicker) {
|
389
|
-
this.container.addClass('auto-apply');
|
390
|
-
}
|
391
|
-
}
|
392
|
-
|
393
|
-
if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
|
394
|
-
this.container.addClass('show-calendar');
|
395
|
-
}
|
396
|
-
|
397
|
-
this.container.addClass('opens' + this.opens);
|
398
|
-
|
399
|
-
//apply CSS classes and labels to buttons
|
400
|
-
this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
|
401
|
-
if (this.applyButtonClasses.length)
|
402
|
-
this.container.find('.applyBtn').addClass(this.applyButtonClasses);
|
403
|
-
if (this.cancelButtonClasses.length)
|
404
|
-
this.container.find('.cancelBtn').addClass(this.cancelButtonClasses);
|
405
|
-
this.container.find('.applyBtn').html(this.locale.applyLabel);
|
406
|
-
this.container.find('.cancelBtn').html(this.locale.cancelLabel);
|
407
|
-
|
408
|
-
//
|
409
|
-
// event listeners
|
410
|
-
//
|
411
|
-
|
412
|
-
this.container.find('.drp-calendar')
|
413
|
-
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
|
414
|
-
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
|
415
|
-
.on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
|
416
|
-
.on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
|
417
|
-
.on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
|
418
|
-
.on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
|
419
|
-
|
420
|
-
this.container.find('.ranges')
|
421
|
-
.on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
|
422
|
-
|
423
|
-
this.container.find('.drp-buttons')
|
424
|
-
.on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
|
425
|
-
.on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
|
426
|
-
|
427
|
-
if (this.element.is('input') || this.element.is('button')) {
|
428
|
-
this.element.on({
|
429
|
-
'click.daterangepicker': $.proxy(this.show, this),
|
430
|
-
'focus.daterangepicker': $.proxy(this.show, this),
|
431
|
-
'keyup.daterangepicker': $.proxy(this.elementChanged, this),
|
432
|
-
'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
|
433
|
-
});
|
434
|
-
} else {
|
435
|
-
this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
|
436
|
-
this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
|
437
|
-
}
|
438
|
-
|
439
|
-
//
|
440
|
-
// if attached to a text input, set the initial value
|
441
|
-
//
|
442
|
-
|
443
|
-
this.updateElement();
|
444
|
-
|
445
|
-
};
|
446
|
-
|
447
|
-
DateRangePicker.prototype = {
|
448
|
-
|
449
|
-
constructor: DateRangePicker,
|
450
|
-
|
451
|
-
setStartDate: function(startDate) {
|
452
|
-
if (typeof startDate === 'string')
|
453
|
-
this.startDate = moment(startDate, this.locale.format);
|
454
|
-
|
455
|
-
if (typeof startDate === 'object')
|
456
|
-
this.startDate = moment(startDate);
|
457
|
-
|
458
|
-
if (!this.timePicker)
|
459
|
-
this.startDate = this.startDate.startOf('day');
|
460
|
-
|
461
|
-
if (this.timePicker && this.timePickerIncrement)
|
462
|
-
this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
463
|
-
|
464
|
-
if (this.minDate && this.startDate.isBefore(this.minDate)) {
|
465
|
-
this.startDate = this.minDate.clone();
|
466
|
-
if (this.timePicker && this.timePickerIncrement)
|
467
|
-
this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
468
|
-
}
|
469
|
-
|
470
|
-
if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
|
471
|
-
this.startDate = this.maxDate.clone();
|
472
|
-
if (this.timePicker && this.timePickerIncrement)
|
473
|
-
this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
474
|
-
}
|
475
|
-
|
476
|
-
if (!this.isShowing)
|
477
|
-
this.updateElement();
|
478
|
-
|
479
|
-
this.updateMonthsInView();
|
480
|
-
},
|
481
|
-
|
482
|
-
setEndDate: function(endDate) {
|
483
|
-
if (typeof endDate === 'string')
|
484
|
-
this.endDate = moment(endDate, this.locale.format);
|
485
|
-
|
486
|
-
if (typeof endDate === 'object')
|
487
|
-
this.endDate = moment(endDate);
|
488
|
-
|
489
|
-
if (!this.timePicker)
|
490
|
-
this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
|
491
|
-
|
492
|
-
if (this.timePicker && this.timePickerIncrement)
|
493
|
-
this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
494
|
-
|
495
|
-
if (this.endDate.isBefore(this.startDate))
|
496
|
-
this.endDate = this.startDate.clone();
|
497
|
-
|
498
|
-
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
499
|
-
this.endDate = this.maxDate.clone();
|
500
|
-
|
501
|
-
if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate))
|
502
|
-
this.endDate = this.startDate.clone().add(this.maxSpan);
|
503
|
-
|
504
|
-
this.previousRightTime = this.endDate.clone();
|
505
|
-
|
506
|
-
this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
507
|
-
|
508
|
-
if (!this.isShowing)
|
509
|
-
this.updateElement();
|
510
|
-
|
511
|
-
this.updateMonthsInView();
|
512
|
-
},
|
513
|
-
|
514
|
-
isInvalidDate: function() {
|
515
|
-
return false;
|
516
|
-
},
|
517
|
-
|
518
|
-
isCustomDate: function() {
|
519
|
-
return false;
|
520
|
-
},
|
521
|
-
|
522
|
-
updateView: function() {
|
523
|
-
if (this.timePicker) {
|
524
|
-
this.renderTimePicker('left');
|
525
|
-
this.renderTimePicker('right');
|
526
|
-
if (!this.endDate) {
|
527
|
-
this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
|
528
|
-
} else {
|
529
|
-
this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
|
530
|
-
}
|
531
|
-
}
|
532
|
-
if (this.endDate)
|
533
|
-
this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
534
|
-
this.updateMonthsInView();
|
535
|
-
this.updateCalendars();
|
536
|
-
this.updateFormInputs();
|
537
|
-
},
|
538
|
-
|
539
|
-
updateMonthsInView: function() {
|
540
|
-
if (this.endDate) {
|
541
|
-
|
542
|
-
//if both dates are visible already, do nothing
|
543
|
-
if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
|
544
|
-
(this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
545
|
-
&&
|
546
|
-
(this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
547
|
-
) {
|
548
|
-
return;
|
549
|
-
}
|
550
|
-
|
551
|
-
this.leftCalendar.month = this.startDate.clone().date(2);
|
552
|
-
if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
|
553
|
-
this.rightCalendar.month = this.endDate.clone().date(2);
|
554
|
-
} else {
|
555
|
-
this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
|
556
|
-
}
|
557
|
-
|
558
|
-
} else {
|
559
|
-
if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
|
560
|
-
this.leftCalendar.month = this.startDate.clone().date(2);
|
561
|
-
this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
|
562
|
-
}
|
563
|
-
}
|
564
|
-
if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
|
565
|
-
this.rightCalendar.month = this.maxDate.clone().date(2);
|
566
|
-
this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
|
567
|
-
}
|
568
|
-
},
|
569
|
-
|
570
|
-
updateCalendars: function() {
|
571
|
-
|
572
|
-
if (this.timePicker) {
|
573
|
-
var hour, minute, second;
|
574
|
-
if (this.endDate) {
|
575
|
-
hour = parseInt(this.container.find('.left .hourselect').val(), 10);
|
576
|
-
minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
|
577
|
-
second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
|
578
|
-
if (!this.timePicker24Hour) {
|
579
|
-
var ampm = this.container.find('.left .ampmselect').val();
|
580
|
-
if (ampm === 'PM' && hour < 12)
|
581
|
-
hour += 12;
|
582
|
-
if (ampm === 'AM' && hour === 12)
|
583
|
-
hour = 0;
|
584
|
-
}
|
585
|
-
} else {
|
586
|
-
hour = parseInt(this.container.find('.right .hourselect').val(), 10);
|
587
|
-
minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
|
588
|
-
second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
|
589
|
-
if (!this.timePicker24Hour) {
|
590
|
-
var ampm = this.container.find('.right .ampmselect').val();
|
591
|
-
if (ampm === 'PM' && hour < 12)
|
592
|
-
hour += 12;
|
593
|
-
if (ampm === 'AM' && hour === 12)
|
594
|
-
hour = 0;
|
595
|
-
}
|
596
|
-
}
|
597
|
-
this.leftCalendar.month.hour(hour).minute(minute).second(second);
|
598
|
-
this.rightCalendar.month.hour(hour).minute(minute).second(second);
|
599
|
-
}
|
600
|
-
|
601
|
-
this.renderCalendar('left');
|
602
|
-
this.renderCalendar('right');
|
603
|
-
|
604
|
-
//highlight any predefined range matching the current start and end dates
|
605
|
-
this.container.find('.ranges li').removeClass('active');
|
606
|
-
if (this.endDate == null) return;
|
607
|
-
|
608
|
-
this.calculateChosenLabel();
|
609
|
-
},
|
610
|
-
|
611
|
-
renderCalendar: function(side) {
|
612
|
-
|
613
|
-
//
|
614
|
-
// Build the matrix of dates that will populate the calendar
|
615
|
-
//
|
616
|
-
|
617
|
-
var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
|
618
|
-
var month = calendar.month.month();
|
619
|
-
var year = calendar.month.year();
|
620
|
-
var hour = calendar.month.hour();
|
621
|
-
var minute = calendar.month.minute();
|
622
|
-
var second = calendar.month.second();
|
623
|
-
var daysInMonth = moment([year, month]).daysInMonth();
|
624
|
-
var firstDay = moment([year, month, 1]);
|
625
|
-
var lastDay = moment([year, month, daysInMonth]);
|
626
|
-
var lastMonth = moment(firstDay).subtract(1, 'month').month();
|
627
|
-
var lastYear = moment(firstDay).subtract(1, 'month').year();
|
628
|
-
var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
|
629
|
-
var dayOfWeek = firstDay.day();
|
630
|
-
|
631
|
-
//initialize a 6 rows x 7 columns array for the calendar
|
632
|
-
var calendar = [];
|
633
|
-
calendar.firstDay = firstDay;
|
634
|
-
calendar.lastDay = lastDay;
|
635
|
-
|
636
|
-
for (var i = 0; i < 6; i++) {
|
637
|
-
calendar[i] = [];
|
638
|
-
}
|
639
|
-
|
640
|
-
//populate the calendar with date objects
|
641
|
-
var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
|
642
|
-
if (startDay > daysInLastMonth)
|
643
|
-
startDay -= 7;
|
644
|
-
|
645
|
-
if (dayOfWeek == this.locale.firstDay)
|
646
|
-
startDay = daysInLastMonth - 6;
|
647
|
-
|
648
|
-
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
|
649
|
-
|
650
|
-
var col, row;
|
651
|
-
for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
|
652
|
-
if (i > 0 && col % 7 === 0) {
|
653
|
-
col = 0;
|
654
|
-
row++;
|
655
|
-
}
|
656
|
-
calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
|
657
|
-
curDate.hour(12);
|
658
|
-
|
659
|
-
if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
|
660
|
-
calendar[row][col] = this.minDate.clone();
|
661
|
-
}
|
662
|
-
|
663
|
-
if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
|
664
|
-
calendar[row][col] = this.maxDate.clone();
|
665
|
-
}
|
666
|
-
|
667
|
-
}
|
668
|
-
|
669
|
-
//make the calendar object available to hoverDate/clickDate
|
670
|
-
if (side == 'left') {
|
671
|
-
this.leftCalendar.calendar = calendar;
|
672
|
-
} else {
|
673
|
-
this.rightCalendar.calendar = calendar;
|
674
|
-
}
|
675
|
-
|
676
|
-
//
|
677
|
-
// Display the calendar
|
678
|
-
//
|
679
|
-
|
680
|
-
var minDate = side == 'left' ? this.minDate : this.startDate;
|
681
|
-
var maxDate = this.maxDate;
|
682
|
-
var selected = side == 'left' ? this.startDate : this.endDate;
|
683
|
-
var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'};
|
684
|
-
|
685
|
-
var html = '<table class="table-condensed">';
|
686
|
-
html += '<thead>';
|
687
|
-
html += '<tr>';
|
688
|
-
|
689
|
-
// add empty cell for week number
|
690
|
-
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
691
|
-
html += '<th></th>';
|
692
|
-
|
693
|
-
if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
|
694
|
-
html += '<th class="prev available"><span></span></th>';
|
695
|
-
} else {
|
696
|
-
html += '<th></th>';
|
697
|
-
}
|
698
|
-
|
699
|
-
var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
|
700
|
-
|
701
|
-
if (this.showDropdowns) {
|
702
|
-
var currentMonth = calendar[1][1].month();
|
703
|
-
var currentYear = calendar[1][1].year();
|
704
|
-
var maxYear = (maxDate && maxDate.year()) || (this.maxYear);
|
705
|
-
var minYear = (minDate && minDate.year()) || (this.minYear);
|
706
|
-
var inMinYear = currentYear == minYear;
|
707
|
-
var inMaxYear = currentYear == maxYear;
|
708
|
-
|
709
|
-
var monthHtml = '<select class="monthselect">';
|
710
|
-
for (var m = 0; m < 12; m++) {
|
711
|
-
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
|
712
|
-
monthHtml += "<option value='" + m + "'" +
|
713
|
-
(m === currentMonth ? " selected='selected'" : "") +
|
714
|
-
">" + this.locale.monthNames[m] + "</option>";
|
715
|
-
} else {
|
716
|
-
monthHtml += "<option value='" + m + "'" +
|
717
|
-
(m === currentMonth ? " selected='selected'" : "") +
|
718
|
-
" disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
|
719
|
-
}
|
720
|
-
}
|
721
|
-
monthHtml += "</select>";
|
722
|
-
|
723
|
-
var yearHtml = '<select class="yearselect">';
|
724
|
-
for (var y = minYear; y <= maxYear; y++) {
|
725
|
-
yearHtml += '<option value="' + y + '"' +
|
726
|
-
(y === currentYear ? ' selected="selected"' : '') +
|
727
|
-
'>' + y + '</option>';
|
728
|
-
}
|
729
|
-
yearHtml += '</select>';
|
730
|
-
|
731
|
-
dateHtml = monthHtml + yearHtml;
|
732
|
-
}
|
733
|
-
|
734
|
-
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
|
735
|
-
if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
|
736
|
-
html += '<th class="next available"><span></span></th>';
|
737
|
-
} else {
|
738
|
-
html += '<th></th>';
|
739
|
-
}
|
740
|
-
|
741
|
-
html += '</tr>';
|
742
|
-
html += '<tr>';
|
743
|
-
|
744
|
-
// add week number label
|
745
|
-
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
746
|
-
html += '<th class="week">' + this.locale.weekLabel + '</th>';
|
747
|
-
|
748
|
-
$.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
|
749
|
-
html += '<th>' + dayOfWeek + '</th>';
|
750
|
-
});
|
751
|
-
|
752
|
-
html += '</tr>';
|
753
|
-
html += '</thead>';
|
754
|
-
html += '<tbody>';
|
755
|
-
|
756
|
-
//adjust maxDate to reflect the maxSpan setting in order to
|
757
|
-
//grey out end dates beyond the maxSpan
|
758
|
-
if (this.endDate == null && this.maxSpan) {
|
759
|
-
var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day');
|
760
|
-
if (!maxDate || maxLimit.isBefore(maxDate)) {
|
761
|
-
maxDate = maxLimit;
|
762
|
-
}
|
763
|
-
}
|
764
|
-
|
765
|
-
for (var row = 0; row < 6; row++) {
|
766
|
-
html += '<tr>';
|
767
|
-
|
768
|
-
// add week number
|
769
|
-
if (this.showWeekNumbers)
|
770
|
-
html += '<td class="week">' + calendar[row][0].week() + '</td>';
|
771
|
-
else if (this.showISOWeekNumbers)
|
772
|
-
html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
|
773
|
-
|
774
|
-
for (var col = 0; col < 7; col++) {
|
775
|
-
|
776
|
-
var classes = [];
|
777
|
-
|
778
|
-
//highlight today's date
|
779
|
-
if (calendar[row][col].isSame(new Date(), "day"))
|
780
|
-
classes.push('today');
|
781
|
-
|
782
|
-
//highlight weekends
|
783
|
-
if (calendar[row][col].isoWeekday() > 5)
|
784
|
-
classes.push('weekend');
|
785
|
-
|
786
|
-
//grey out the dates in other months displayed at beginning and end of this calendar
|
787
|
-
if (calendar[row][col].month() != calendar[1][1].month())
|
788
|
-
classes.push('off');
|
789
|
-
|
790
|
-
//don't allow selection of dates before the minimum date
|
791
|
-
if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
|
792
|
-
classes.push('off', 'disabled');
|
793
|
-
|
794
|
-
//don't allow selection of dates after the maximum date
|
795
|
-
if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
|
796
|
-
classes.push('off', 'disabled');
|
797
|
-
|
798
|
-
//don't allow selection of date if a custom function decides it's invalid
|
799
|
-
if (this.isInvalidDate(calendar[row][col]))
|
800
|
-
classes.push('off', 'disabled');
|
801
|
-
|
802
|
-
//highlight the currently selected start date
|
803
|
-
if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
|
804
|
-
classes.push('active', 'start-date');
|
805
|
-
|
806
|
-
//highlight the currently selected end date
|
807
|
-
if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
|
808
|
-
classes.push('active', 'end-date');
|
809
|
-
|
810
|
-
//highlight dates in-between the selected dates
|
811
|
-
if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
|
812
|
-
classes.push('in-range');
|
813
|
-
|
814
|
-
//apply custom classes for this date
|
815
|
-
var isCustom = this.isCustomDate(calendar[row][col]);
|
816
|
-
if (isCustom !== false) {
|
817
|
-
if (typeof isCustom === 'string')
|
818
|
-
classes.push(isCustom);
|
819
|
-
else
|
820
|
-
Array.prototype.push.apply(classes, isCustom);
|
821
|
-
}
|
822
|
-
|
823
|
-
var cname = '', disabled = false;
|
824
|
-
for (var i = 0; i < classes.length; i++) {
|
825
|
-
cname += classes[i] + ' ';
|
826
|
-
if (classes[i] == 'disabled')
|
827
|
-
disabled = true;
|
828
|
-
}
|
829
|
-
if (!disabled)
|
830
|
-
cname += 'available';
|
831
|
-
|
832
|
-
html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
|
833
|
-
|
834
|
-
}
|
835
|
-
html += '</tr>';
|
836
|
-
}
|
837
|
-
|
838
|
-
html += '</tbody>';
|
839
|
-
html += '</table>';
|
840
|
-
|
841
|
-
this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html);
|
842
|
-
|
843
|
-
},
|
844
|
-
|
845
|
-
renderTimePicker: function(side) {
|
846
|
-
|
847
|
-
// Don't bother updating the time picker if it's currently disabled
|
848
|
-
// because an end date hasn't been clicked yet
|
849
|
-
if (side == 'right' && !this.endDate) return;
|
850
|
-
|
851
|
-
var html, selected, minDate, maxDate = this.maxDate;
|
852
|
-
|
853
|
-
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate)))
|
854
|
-
maxDate = this.startDate.clone().add(this.maxSpan);
|
855
|
-
|
856
|
-
if (side == 'left') {
|
857
|
-
selected = this.startDate.clone();
|
858
|
-
minDate = this.minDate;
|
859
|
-
} else if (side == 'right') {
|
860
|
-
selected = this.endDate.clone();
|
861
|
-
minDate = this.startDate;
|
862
|
-
|
863
|
-
//Preserve the time already selected
|
864
|
-
var timeSelector = this.container.find('.drp-calendar.right .calendar-time');
|
865
|
-
if (timeSelector.html() != '') {
|
866
|
-
|
867
|
-
selected.hour(selected.hour() || timeSelector.find('.hourselect option:selected').val());
|
868
|
-
selected.minute(selected.minute() || timeSelector.find('.minuteselect option:selected').val());
|
869
|
-
selected.second(selected.second() || timeSelector.find('.secondselect option:selected').val());
|
870
|
-
|
871
|
-
if (!this.timePicker24Hour) {
|
872
|
-
var ampm = timeSelector.find('.ampmselect option:selected').val();
|
873
|
-
if (ampm === 'PM' && selected.hour() < 12)
|
874
|
-
selected.hour(selected.hour() + 12);
|
875
|
-
if (ampm === 'AM' && selected.hour() === 12)
|
876
|
-
selected.hour(0);
|
877
|
-
}
|
878
|
-
|
879
|
-
}
|
880
|
-
|
881
|
-
if (selected.isBefore(this.startDate))
|
882
|
-
selected = this.startDate.clone();
|
883
|
-
|
884
|
-
if (maxDate && selected.isAfter(maxDate))
|
885
|
-
selected = maxDate.clone();
|
886
|
-
|
887
|
-
}
|
888
|
-
|
889
|
-
//
|
890
|
-
// hours
|
891
|
-
//
|
892
|
-
|
893
|
-
html = '<select class="hourselect">';
|
894
|
-
|
895
|
-
var start = this.timePicker24Hour ? 0 : 1;
|
896
|
-
var end = this.timePicker24Hour ? 23 : 12;
|
897
|
-
|
898
|
-
for (var i = start; i <= end; i++) {
|
899
|
-
var i_in_24 = i;
|
900
|
-
if (!this.timePicker24Hour)
|
901
|
-
i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
|
902
|
-
|
903
|
-
var time = selected.clone().hour(i_in_24);
|
904
|
-
var disabled = false;
|
905
|
-
if (minDate && time.minute(59).isBefore(minDate))
|
906
|
-
disabled = true;
|
907
|
-
if (maxDate && time.minute(0).isAfter(maxDate))
|
908
|
-
disabled = true;
|
909
|
-
|
910
|
-
if (i_in_24 == selected.hour() && !disabled) {
|
911
|
-
html += '<option value="' + i + '" selected="selected">' + i + '</option>';
|
912
|
-
} else if (disabled) {
|
913
|
-
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
|
914
|
-
} else {
|
915
|
-
html += '<option value="' + i + '">' + i + '</option>';
|
916
|
-
}
|
917
|
-
}
|
918
|
-
|
919
|
-
html += '</select> ';
|
920
|
-
|
921
|
-
//
|
922
|
-
// minutes
|
923
|
-
//
|
924
|
-
|
925
|
-
html += ': <select class="minuteselect">';
|
926
|
-
|
927
|
-
for (var i = 0; i < 60; i += this.timePickerIncrement) {
|
928
|
-
var padded = i < 10 ? '0' + i : i;
|
929
|
-
var time = selected.clone().minute(i);
|
930
|
-
|
931
|
-
var disabled = false;
|
932
|
-
if (minDate && time.second(59).isBefore(minDate))
|
933
|
-
disabled = true;
|
934
|
-
if (maxDate && time.second(0).isAfter(maxDate))
|
935
|
-
disabled = true;
|
936
|
-
|
937
|
-
if (selected.minute() == i && !disabled) {
|
938
|
-
html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
|
939
|
-
} else if (disabled) {
|
940
|
-
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
|
941
|
-
} else {
|
942
|
-
html += '<option value="' + i + '">' + padded + '</option>';
|
943
|
-
}
|
944
|
-
}
|
945
|
-
|
946
|
-
html += '</select> ';
|
947
|
-
|
948
|
-
//
|
949
|
-
// seconds
|
950
|
-
//
|
951
|
-
|
952
|
-
if (this.timePickerSeconds) {
|
953
|
-
html += ': <select class="secondselect">';
|
954
|
-
|
955
|
-
for (var i = 0; i < 60; i++) {
|
956
|
-
var padded = i < 10 ? '0' + i : i;
|
957
|
-
var time = selected.clone().second(i);
|
958
|
-
|
959
|
-
var disabled = false;
|
960
|
-
if (minDate && time.isBefore(minDate))
|
961
|
-
disabled = true;
|
962
|
-
if (maxDate && time.isAfter(maxDate))
|
963
|
-
disabled = true;
|
964
|
-
|
965
|
-
if (selected.second() == i && !disabled) {
|
966
|
-
html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
|
967
|
-
} else if (disabled) {
|
968
|
-
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
|
969
|
-
} else {
|
970
|
-
html += '<option value="' + i + '">' + padded + '</option>';
|
971
|
-
}
|
972
|
-
}
|
973
|
-
|
974
|
-
html += '</select> ';
|
975
|
-
}
|
976
|
-
|
977
|
-
//
|
978
|
-
// AM/PM
|
979
|
-
//
|
980
|
-
|
981
|
-
if (!this.timePicker24Hour) {
|
982
|
-
html += '<select class="ampmselect">';
|
983
|
-
|
984
|
-
var am_html = '';
|
985
|
-
var pm_html = '';
|
986
|
-
|
987
|
-
if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
|
988
|
-
am_html = ' disabled="disabled" class="disabled"';
|
989
|
-
|
990
|
-
if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
|
991
|
-
pm_html = ' disabled="disabled" class="disabled"';
|
992
|
-
|
993
|
-
if (selected.hour() >= 12) {
|
994
|
-
html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
|
995
|
-
} else {
|
996
|
-
html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
|
997
|
-
}
|
998
|
-
|
999
|
-
html += '</select>';
|
1000
|
-
}
|
1001
|
-
|
1002
|
-
this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html);
|
1003
|
-
|
1004
|
-
},
|
1005
|
-
|
1006
|
-
updateFormInputs: function() {
|
1007
|
-
|
1008
|
-
if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
|
1009
|
-
this.container.find('button.applyBtn').removeAttr('disabled');
|
1010
|
-
} else {
|
1011
|
-
this.container.find('button.applyBtn').attr('disabled', 'disabled');
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
},
|
1015
|
-
|
1016
|
-
move: function() {
|
1017
|
-
var parentOffset = { top: 0, left: 0 },
|
1018
|
-
containerTop;
|
1019
|
-
var parentRightEdge = $(window).width();
|
1020
|
-
if (!this.parentEl.is('body')) {
|
1021
|
-
parentOffset = {
|
1022
|
-
top: this.parentEl.offset().top - this.parentEl.scrollTop(),
|
1023
|
-
left: this.parentEl.offset().left - this.parentEl.scrollLeft()
|
1024
|
-
};
|
1025
|
-
parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
if (this.drops == 'up')
|
1029
|
-
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
|
1030
|
-
else
|
1031
|
-
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
|
1032
|
-
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');
|
1033
|
-
|
1034
|
-
if (this.opens == 'left') {
|
1035
|
-
this.container.css({
|
1036
|
-
top: containerTop,
|
1037
|
-
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
|
1038
|
-
left: 'auto'
|
1039
|
-
});
|
1040
|
-
if (this.container.offset().left < 0) {
|
1041
|
-
this.container.css({
|
1042
|
-
right: 'auto',
|
1043
|
-
left: 9
|
1044
|
-
});
|
1045
|
-
}
|
1046
|
-
} else if (this.opens == 'center') {
|
1047
|
-
this.container.css({
|
1048
|
-
top: containerTop,
|
1049
|
-
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
|
1050
|
-
- this.container.outerWidth() / 2,
|
1051
|
-
right: 'auto'
|
1052
|
-
});
|
1053
|
-
if (this.container.offset().left < 0) {
|
1054
|
-
this.container.css({
|
1055
|
-
right: 'auto',
|
1056
|
-
left: 9
|
1057
|
-
});
|
1058
|
-
}
|
1059
|
-
} else {
|
1060
|
-
this.container.css({
|
1061
|
-
top: containerTop,
|
1062
|
-
left: this.element.offset().left - parentOffset.left,
|
1063
|
-
right: 'auto'
|
1064
|
-
});
|
1065
|
-
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
|
1066
|
-
this.container.css({
|
1067
|
-
left: 'auto',
|
1068
|
-
right: 0
|
1069
|
-
});
|
1070
|
-
}
|
1071
|
-
}
|
1072
|
-
},
|
1073
|
-
|
1074
|
-
show: function(e) {
|
1075
|
-
if (this.isShowing) return;
|
1076
|
-
|
1077
|
-
// Create a click proxy that is private to this instance of datepicker, for unbinding
|
1078
|
-
this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
|
1079
|
-
|
1080
|
-
// Bind global datepicker mousedown for hiding and
|
1081
|
-
$(document)
|
1082
|
-
.on('mousedown.daterangepicker', this._outsideClickProxy)
|
1083
|
-
// also support mobile devices
|
1084
|
-
.on('touchend.daterangepicker', this._outsideClickProxy)
|
1085
|
-
// also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
|
1086
|
-
.on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
|
1087
|
-
// and also close when focus changes to outside the picker (eg. tabbing between controls)
|
1088
|
-
.on('focusin.daterangepicker', this._outsideClickProxy);
|
1089
|
-
|
1090
|
-
// Reposition the picker if the window is resized while it's open
|
1091
|
-
$(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
|
1092
|
-
|
1093
|
-
this.oldStartDate = this.startDate.clone();
|
1094
|
-
this.oldEndDate = this.endDate.clone();
|
1095
|
-
this.previousRightTime = this.endDate.clone();
|
1096
|
-
|
1097
|
-
this.updateView();
|
1098
|
-
this.container.show();
|
1099
|
-
this.move();
|
1100
|
-
this.element.trigger('show.daterangepicker', this);
|
1101
|
-
this.isShowing = true;
|
1102
|
-
},
|
1103
|
-
|
1104
|
-
hide: function(e) {
|
1105
|
-
if (!this.isShowing) return;
|
1106
|
-
|
1107
|
-
//incomplete date selection, revert to last values
|
1108
|
-
if (!this.endDate) {
|
1109
|
-
this.startDate = this.oldStartDate.clone();
|
1110
|
-
this.endDate = this.oldEndDate.clone();
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
//if a new date range was selected, invoke the user callback function
|
1114
|
-
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
|
1115
|
-
this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel);
|
1116
|
-
|
1117
|
-
//if picker is attached to a text input, update it
|
1118
|
-
this.updateElement();
|
1119
|
-
|
1120
|
-
$(document).off('.daterangepicker');
|
1121
|
-
$(window).off('.daterangepicker');
|
1122
|
-
this.container.hide();
|
1123
|
-
this.element.trigger('hide.daterangepicker', this);
|
1124
|
-
this.isShowing = false;
|
1125
|
-
},
|
1126
|
-
|
1127
|
-
toggle: function(e) {
|
1128
|
-
if (this.isShowing) {
|
1129
|
-
this.hide();
|
1130
|
-
} else {
|
1131
|
-
this.show();
|
1132
|
-
}
|
1133
|
-
},
|
1134
|
-
|
1135
|
-
outsideClick: function(e) {
|
1136
|
-
var target = $(e.target);
|
1137
|
-
// if the page is clicked anywhere except within the daterangerpicker/button
|
1138
|
-
// itself then call this.hide()
|
1139
|
-
if (
|
1140
|
-
// ie modal dialog fix
|
1141
|
-
e.type == "focusin" ||
|
1142
|
-
target.closest(this.element).length ||
|
1143
|
-
target.closest(this.container).length ||
|
1144
|
-
target.closest('.calendar-table').length
|
1145
|
-
) return;
|
1146
|
-
this.hide();
|
1147
|
-
this.element.trigger('outsideClick.daterangepicker', this);
|
1148
|
-
},
|
1149
|
-
|
1150
|
-
showCalendars: function() {
|
1151
|
-
this.container.addClass('show-calendar');
|
1152
|
-
this.move();
|
1153
|
-
this.element.trigger('showCalendar.daterangepicker', this);
|
1154
|
-
},
|
1155
|
-
|
1156
|
-
hideCalendars: function() {
|
1157
|
-
this.container.removeClass('show-calendar');
|
1158
|
-
this.element.trigger('hideCalendar.daterangepicker', this);
|
1159
|
-
},
|
1160
|
-
|
1161
|
-
clickRange: function(e) {
|
1162
|
-
var label = e.target.getAttribute('data-range-key');
|
1163
|
-
this.chosenLabel = label;
|
1164
|
-
if (label == this.locale.customRangeLabel) {
|
1165
|
-
this.showCalendars();
|
1166
|
-
} else {
|
1167
|
-
var dates = this.ranges[label];
|
1168
|
-
this.startDate = dates[0];
|
1169
|
-
this.endDate = dates[1];
|
1170
|
-
|
1171
|
-
if (!this.timePicker) {
|
1172
|
-
this.startDate.startOf('day');
|
1173
|
-
this.endDate.endOf('day');
|
1174
|
-
}
|
1175
|
-
|
1176
|
-
if (!this.alwaysShowCalendars)
|
1177
|
-
this.hideCalendars();
|
1178
|
-
this.clickApply();
|
1179
|
-
}
|
1180
|
-
},
|
1181
|
-
|
1182
|
-
clickPrev: function(e) {
|
1183
|
-
var cal = $(e.target).parents('.drp-calendar');
|
1184
|
-
if (cal.hasClass('left')) {
|
1185
|
-
this.leftCalendar.month.subtract(1, 'month');
|
1186
|
-
if (this.linkedCalendars)
|
1187
|
-
this.rightCalendar.month.subtract(1, 'month');
|
1188
|
-
} else {
|
1189
|
-
this.rightCalendar.month.subtract(1, 'month');
|
1190
|
-
}
|
1191
|
-
this.updateCalendars();
|
1192
|
-
},
|
1193
|
-
|
1194
|
-
clickNext: function(e) {
|
1195
|
-
var cal = $(e.target).parents('.drp-calendar');
|
1196
|
-
if (cal.hasClass('left')) {
|
1197
|
-
this.leftCalendar.month.add(1, 'month');
|
1198
|
-
} else {
|
1199
|
-
this.rightCalendar.month.add(1, 'month');
|
1200
|
-
if (this.linkedCalendars)
|
1201
|
-
this.leftCalendar.month.add(1, 'month');
|
1202
|
-
}
|
1203
|
-
this.updateCalendars();
|
1204
|
-
},
|
1205
|
-
|
1206
|
-
hoverDate: function(e) {
|
1207
|
-
|
1208
|
-
//ignore mouse movements while an above-calendar text input has focus
|
1209
|
-
//if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
1210
|
-
// return;
|
1211
|
-
|
1212
|
-
//ignore dates that can't be selected
|
1213
|
-
if (!$(e.target).hasClass('available')) return;
|
1214
|
-
|
1215
|
-
//have the text inputs above calendars reflect the date being hovered over
|
1216
|
-
var title = $(e.target).attr('data-title');
|
1217
|
-
var row = title.substr(1, 1);
|
1218
|
-
var col = title.substr(3, 1);
|
1219
|
-
var cal = $(e.target).parents('.drp-calendar');
|
1220
|
-
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
1221
|
-
|
1222
|
-
//highlight the dates between the start date and the date being hovered as a potential end date
|
1223
|
-
var leftCalendar = this.leftCalendar;
|
1224
|
-
var rightCalendar = this.rightCalendar;
|
1225
|
-
var startDate = this.startDate;
|
1226
|
-
if (!this.endDate) {
|
1227
|
-
this.container.find('.drp-calendar tbody td').each(function(index, el) {
|
1228
|
-
|
1229
|
-
//skip week numbers, only look at dates
|
1230
|
-
if ($(el).hasClass('week')) return;
|
1231
|
-
|
1232
|
-
var title = $(el).attr('data-title');
|
1233
|
-
var row = title.substr(1, 1);
|
1234
|
-
var col = title.substr(3, 1);
|
1235
|
-
var cal = $(el).parents('.drp-calendar');
|
1236
|
-
var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
|
1237
|
-
|
1238
|
-
if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
|
1239
|
-
$(el).addClass('in-range');
|
1240
|
-
} else {
|
1241
|
-
$(el).removeClass('in-range');
|
1242
|
-
}
|
1243
|
-
|
1244
|
-
});
|
1245
|
-
}
|
1246
|
-
|
1247
|
-
},
|
1248
|
-
|
1249
|
-
clickDate: function(e) {
|
1250
|
-
|
1251
|
-
if (!$(e.target).hasClass('available')) return;
|
1252
|
-
|
1253
|
-
var title = $(e.target).attr('data-title');
|
1254
|
-
var row = title.substr(1, 1);
|
1255
|
-
var col = title.substr(3, 1);
|
1256
|
-
var cal = $(e.target).parents('.drp-calendar');
|
1257
|
-
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
1258
|
-
|
1259
|
-
//
|
1260
|
-
// this function needs to do a few things:
|
1261
|
-
// * alternate between selecting a start and end date for the range,
|
1262
|
-
// * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
|
1263
|
-
// * if autoapply is enabled, and an end date was chosen, apply the selection
|
1264
|
-
// * if single date picker mode, and time picker isn't enabled, apply the selection immediately
|
1265
|
-
// * if one of the inputs above the calendars was focused, cancel that manual input
|
1266
|
-
//
|
1267
|
-
|
1268
|
-
if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
|
1269
|
-
if (this.timePicker) {
|
1270
|
-
var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
|
1271
|
-
if (!this.timePicker24Hour) {
|
1272
|
-
var ampm = this.container.find('.left .ampmselect').val();
|
1273
|
-
if (ampm === 'PM' && hour < 12)
|
1274
|
-
hour += 12;
|
1275
|
-
if (ampm === 'AM' && hour === 12)
|
1276
|
-
hour = 0;
|
1277
|
-
}
|
1278
|
-
var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
|
1279
|
-
var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
|
1280
|
-
date = date.clone().hour(hour).minute(minute).second(second);
|
1281
|
-
}
|
1282
|
-
this.endDate = null;
|
1283
|
-
this.setStartDate(date.clone());
|
1284
|
-
} else if (!this.endDate && date.isBefore(this.startDate)) {
|
1285
|
-
//special case: clicking the same date for start/end,
|
1286
|
-
//but the time of the end date is before the start date
|
1287
|
-
this.setEndDate(this.startDate.clone());
|
1288
|
-
} else { // picking end
|
1289
|
-
if (this.timePicker) {
|
1290
|
-
var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
|
1291
|
-
if (!this.timePicker24Hour) {
|
1292
|
-
var ampm = this.container.find('.right .ampmselect').val();
|
1293
|
-
if (ampm === 'PM' && hour < 12)
|
1294
|
-
hour += 12;
|
1295
|
-
if (ampm === 'AM' && hour === 12)
|
1296
|
-
hour = 0;
|
1297
|
-
}
|
1298
|
-
var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
|
1299
|
-
var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
|
1300
|
-
date = date.clone().hour(hour).minute(minute).second(second);
|
1301
|
-
}
|
1302
|
-
this.setEndDate(date.clone());
|
1303
|
-
if (this.autoApply) {
|
1304
|
-
this.calculateChosenLabel();
|
1305
|
-
this.clickApply();
|
1306
|
-
}
|
1307
|
-
}
|
1308
|
-
|
1309
|
-
if (this.singleDatePicker) {
|
1310
|
-
this.setEndDate(this.startDate);
|
1311
|
-
if (!this.timePicker)
|
1312
|
-
this.clickApply();
|
1313
|
-
}
|
1314
|
-
|
1315
|
-
this.updateView();
|
1316
|
-
|
1317
|
-
//This is to cancel the blur event handler if the mouse was in one of the inputs
|
1318
|
-
e.stopPropagation();
|
1319
|
-
|
1320
|
-
},
|
1321
|
-
|
1322
|
-
calculateChosenLabel: function () {
|
1323
|
-
var customRange = true;
|
1324
|
-
var i = 0;
|
1325
|
-
for (var range in this.ranges) {
|
1326
|
-
if (this.timePicker) {
|
1327
|
-
var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
|
1328
|
-
//ignore times when comparing dates if time picker seconds is not enabled
|
1329
|
-
if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
|
1330
|
-
customRange = false;
|
1331
|
-
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
|
1332
|
-
break;
|
1333
|
-
}
|
1334
|
-
} else {
|
1335
|
-
//ignore times when comparing dates if time picker is not enabled
|
1336
|
-
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
|
1337
|
-
customRange = false;
|
1338
|
-
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
|
1339
|
-
break;
|
1340
|
-
}
|
1341
|
-
}
|
1342
|
-
i++;
|
1343
|
-
}
|
1344
|
-
if (customRange) {
|
1345
|
-
if (this.showCustomRangeLabel) {
|
1346
|
-
this.chosenLabel = this.container.find('.ranges li:last').addClass('active').attr('data-range-key');
|
1347
|
-
} else {
|
1348
|
-
this.chosenLabel = null;
|
1349
|
-
}
|
1350
|
-
this.showCalendars();
|
1351
|
-
}
|
1352
|
-
},
|
1353
|
-
|
1354
|
-
clickApply: function(e) {
|
1355
|
-
this.hide();
|
1356
|
-
this.element.trigger('apply.daterangepicker', this);
|
1357
|
-
},
|
1358
|
-
|
1359
|
-
clickCancel: function(e) {
|
1360
|
-
this.startDate = this.oldStartDate;
|
1361
|
-
this.endDate = this.oldEndDate;
|
1362
|
-
this.hide();
|
1363
|
-
this.element.trigger('cancel.daterangepicker', this);
|
1364
|
-
},
|
1365
|
-
|
1366
|
-
monthOrYearChanged: function(e) {
|
1367
|
-
var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'),
|
1368
|
-
leftOrRight = isLeft ? 'left' : 'right',
|
1369
|
-
cal = this.container.find('.drp-calendar.'+leftOrRight);
|
1370
|
-
|
1371
|
-
// Month must be Number for new moment versions
|
1372
|
-
var month = parseInt(cal.find('.monthselect').val(), 10);
|
1373
|
-
var year = cal.find('.yearselect').val();
|
1374
|
-
|
1375
|
-
if (!isLeft) {
|
1376
|
-
if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
|
1377
|
-
month = this.startDate.month();
|
1378
|
-
year = this.startDate.year();
|
1379
|
-
}
|
1380
|
-
}
|
1381
|
-
|
1382
|
-
if (this.minDate) {
|
1383
|
-
if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
|
1384
|
-
month = this.minDate.month();
|
1385
|
-
year = this.minDate.year();
|
1386
|
-
}
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
if (this.maxDate) {
|
1390
|
-
if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
|
1391
|
-
month = this.maxDate.month();
|
1392
|
-
year = this.maxDate.year();
|
1393
|
-
}
|
1394
|
-
}
|
1395
|
-
|
1396
|
-
if (isLeft) {
|
1397
|
-
this.leftCalendar.month.month(month).year(year);
|
1398
|
-
if (this.linkedCalendars)
|
1399
|
-
this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
|
1400
|
-
} else {
|
1401
|
-
this.rightCalendar.month.month(month).year(year);
|
1402
|
-
if (this.linkedCalendars)
|
1403
|
-
this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
|
1404
|
-
}
|
1405
|
-
this.updateCalendars();
|
1406
|
-
},
|
1407
|
-
|
1408
|
-
timeChanged: function(e) {
|
1409
|
-
|
1410
|
-
var cal = $(e.target).closest('.drp-calendar'),
|
1411
|
-
isLeft = cal.hasClass('left');
|
1412
|
-
|
1413
|
-
var hour = parseInt(cal.find('.hourselect').val(), 10);
|
1414
|
-
var minute = parseInt(cal.find('.minuteselect').val(), 10);
|
1415
|
-
var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
|
1416
|
-
|
1417
|
-
if (!this.timePicker24Hour) {
|
1418
|
-
var ampm = cal.find('.ampmselect').val();
|
1419
|
-
if (ampm === 'PM' && hour < 12)
|
1420
|
-
hour += 12;
|
1421
|
-
if (ampm === 'AM' && hour === 12)
|
1422
|
-
hour = 0;
|
1423
|
-
}
|
1424
|
-
|
1425
|
-
if (isLeft) {
|
1426
|
-
var start = this.startDate.clone();
|
1427
|
-
start.hour(hour);
|
1428
|
-
start.minute(minute);
|
1429
|
-
start.second(second);
|
1430
|
-
this.setStartDate(start);
|
1431
|
-
if (this.singleDatePicker) {
|
1432
|
-
this.endDate = this.startDate.clone();
|
1433
|
-
} else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
|
1434
|
-
this.setEndDate(start.clone());
|
1435
|
-
}
|
1436
|
-
} else if (this.endDate) {
|
1437
|
-
var end = this.endDate.clone();
|
1438
|
-
end.hour(hour);
|
1439
|
-
end.minute(minute);
|
1440
|
-
end.second(second);
|
1441
|
-
this.setEndDate(end);
|
1442
|
-
}
|
1443
|
-
|
1444
|
-
//update the calendars so all clickable dates reflect the new time component
|
1445
|
-
this.updateCalendars();
|
1446
|
-
|
1447
|
-
//update the form inputs above the calendars with the new time
|
1448
|
-
this.updateFormInputs();
|
1449
|
-
|
1450
|
-
//re-render the time pickers because changing one selection can affect what's enabled in another
|
1451
|
-
this.renderTimePicker('left');
|
1452
|
-
this.renderTimePicker('right');
|
1453
|
-
|
1454
|
-
},
|
1455
|
-
|
1456
|
-
elementChanged: function() {
|
1457
|
-
if (!this.element.is('input')) return;
|
1458
|
-
if (!this.element.val().length) return;
|
1459
|
-
|
1460
|
-
var dateString = this.element.val().split(this.locale.separator),
|
1461
|
-
start = null,
|
1462
|
-
end = null;
|
1463
|
-
|
1464
|
-
if (dateString.length === 2) {
|
1465
|
-
start = moment(dateString[0], this.locale.format);
|
1466
|
-
end = moment(dateString[1], this.locale.format);
|
1467
|
-
}
|
1468
|
-
|
1469
|
-
if (this.singleDatePicker || start === null || end === null) {
|
1470
|
-
start = moment(this.element.val(), this.locale.format);
|
1471
|
-
end = start;
|
1472
|
-
}
|
1473
|
-
|
1474
|
-
if (!start.isValid() || !end.isValid()) return;
|
1475
|
-
|
1476
|
-
this.setStartDate(start);
|
1477
|
-
this.setEndDate(end);
|
1478
|
-
this.updateView();
|
1479
|
-
},
|
1480
|
-
|
1481
|
-
keydown: function(e) {
|
1482
|
-
//hide on tab or enter
|
1483
|
-
if ((e.keyCode === 9) || (e.keyCode === 13)) {
|
1484
|
-
this.hide();
|
1485
|
-
}
|
1486
|
-
|
1487
|
-
//hide on esc and prevent propagation
|
1488
|
-
if (e.keyCode === 27) {
|
1489
|
-
e.preventDefault();
|
1490
|
-
e.stopPropagation();
|
1491
|
-
|
1492
|
-
this.hide();
|
1493
|
-
}
|
1494
|
-
},
|
1495
|
-
|
1496
|
-
updateElement: function() {
|
1497
|
-
if (this.element.is('input') && this.autoUpdateInput) {
|
1498
|
-
var newValue = this.startDate.format(this.locale.format);
|
1499
|
-
if (!this.singleDatePicker) {
|
1500
|
-
newValue += this.locale.separator + this.endDate.format(this.locale.format);
|
1501
|
-
}
|
1502
|
-
if (newValue !== this.element.val()) {
|
1503
|
-
this.element.val(newValue).trigger('change');
|
1504
|
-
}
|
1505
|
-
}
|
1506
|
-
},
|
1507
|
-
|
1508
|
-
remove: function() {
|
1509
|
-
this.container.remove();
|
1510
|
-
this.element.off('.daterangepicker');
|
1511
|
-
this.element.removeData();
|
1512
|
-
}
|
1513
|
-
|
1514
|
-
};
|
1515
|
-
|
1516
|
-
$.fn.daterangepicker = function(options, callback) {
|
1517
|
-
var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
|
1518
|
-
this.each(function() {
|
1519
|
-
var el = $(this);
|
1520
|
-
if (el.data('daterangepicker'))
|
1521
|
-
el.data('daterangepicker').remove();
|
1522
|
-
el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
|
1523
|
-
});
|
1524
|
-
return this;
|
1525
|
-
};
|
1526
|
-
|
1527
|
-
return DateRangePicker;
|
1528
|
-
|
1529
|
-
}));
|