tenon 1.1.8 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +768 -69
- data/Rakefile +7 -13
- data/app/assets/javascripts/tenon/application.js +4 -0
- data/app/controllers/tenon/assets_controller.rb +22 -23
- data/app/controllers/tenon/base_controller.rb +22 -13
- data/app/controllers/tenon/index_controller.rb +0 -4
- data/app/controllers/tenon/item_versions_controller.rb +20 -8
- data/app/controllers/tenon/resources_controller.rb +100 -30
- data/app/controllers/tenon/simple_resources_controller.rb +7 -7
- data/app/controllers/tenon/styleguides_controller.rb +10 -0
- data/app/decorators/tenon/application_decorator.rb +4 -8
- data/app/decorators/tenon/asset_decorator.rb +0 -25
- data/app/filterers/tenon/generic_filterer.rb +24 -0
- data/app/form_builders/tenon/form_builder.rb +189 -19
- data/app/helpers/tenon/active_link_to_helper.rb +9 -0
- data/app/helpers/tenon/application_helper.rb +4 -23
- data/app/helpers/tenon/asset_helper.rb +2 -2
- data/app/helpers/tenon/back_to_index_path_helper.rb +13 -0
- data/app/helpers/tenon/breadcrumbs_helper.rb +33 -0
- data/app/helpers/tenon/flash_helper.rb +14 -0
- data/app/helpers/tenon/icon_helper.rb +7 -0
- data/app/helpers/tenon/input_block_helper.rb +25 -0
- data/app/helpers/tenon/item_version_helper.rb +22 -9
- data/app/helpers/tenon/nav_helper.rb +21 -17
- data/app/helpers/tenon/piece_helper.rb +2 -7
- data/app/helpers/tenon/platform_hints_helper.rb +3 -5
- data/app/helpers/tenon/styleguide_helper.rb +15 -0
- data/app/helpers/tenon/tenon_content_helper.rb +11 -6
- data/app/helpers/tenon/tenon_helper.rb +19 -9
- data/app/models/tenon/application_record.rb +5 -0
- data/app/models/tenon/asset.rb +2 -2
- data/app/models/tenon/item_asset.rb +1 -1
- data/app/models/tenon/item_version.rb +1 -1
- data/app/models/tenon/styleguide.rb +11 -0
- data/app/models/tenon/tenon_content/piece.rb +13 -13
- data/app/models/tenon/tenon_content/row.rb +1 -1
- data/app/models/tenon/tenon_content/row_types/four_column_image.rb +4 -4
- data/app/models/tenon/tenon_content/row_types/four_column_image_and_text.rb +8 -8
- data/app/models/tenon/tenon_content/row_types/four_column_text.rb +4 -4
- data/app/models/tenon/tenon_content/row_types/full_width_embedded_content.rb +1 -1
- data/app/models/tenon/tenon_content/row_types/full_width_image.rb +1 -1
- data/app/models/tenon/tenon_content/row_types/full_width_text.rb +1 -1
- data/app/models/tenon/tenon_content/row_types/left_image_right_text.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/left_text_right_image.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/left_wrapped_image_with_text.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/right_wrapped_image_with_text.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/six_column_image.rb +6 -6
- data/app/models/tenon/tenon_content/row_types/six_column_image_and_text.rb +12 -12
- data/app/models/tenon/tenon_content/row_types/three_column_image.rb +3 -3
- data/app/models/tenon/tenon_content/row_types/three_column_image_and_text.rb +6 -6
- data/app/models/tenon/tenon_content/row_types/three_column_text.rb +3 -3
- data/app/models/tenon/tenon_content/row_types/two_column_image.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/two_column_image_and_text.rb +4 -4
- data/app/models/tenon/tenon_content/row_types/two_column_text.rb +2 -2
- data/app/models/tenon/tenon_content/row_types/two_column_with_background_image.rb +3 -3
- data/app/models/tenon/tenon_content/row_types.rb +17 -17
- data/app/policies/my_settings_policy.rb +2 -0
- data/app/policies/tenon/application_policy.rb +63 -0
- data/app/policies/tenon/asset_policy.rb +4 -0
- data/app/policies/tenon/item_version_policy.rb +4 -0
- data/app/serializers/item_version_serializer.rb +23 -0
- data/app/serializers/tenon/application_serializer.rb +37 -0
- data/app/serializers/tenon/asset_serializer.rb +5 -0
- data/app/serializers/tenon/paginating_serializer.rb +18 -0
- data/app/views/layouts/tenon/application.html.haml +28 -18
- data/app/views/tenon/assets/_form.html.haml +29 -12
- data/app/views/tenon/assets/crop.html.haml +13 -13
- data/app/views/tenon/assets/edit.html.haml +1 -12
- data/app/views/tenon/assets/index.html.haml +5 -19
- data/app/views/tenon/assets/new.html.haml +1 -0
- data/app/views/tenon/fields/_asset.html.haml +26 -27
- data/app/views/tenon/fields/_base.html.haml +7 -0
- data/app/views/tenon/fields/_base_inline.html.haml +4 -0
- data/app/views/tenon/fields/_check_box.html.haml +9 -0
- data/app/views/tenon/fields/_collection_select.html.haml +4 -0
- data/app/views/tenon/fields/_color_field.html.haml +3 -0
- data/app/views/tenon/fields/_date_picker.html.haml +2 -0
- data/app/views/tenon/fields/_date_time_picker.html.haml +6 -0
- data/app/views/tenon/fields/_email_field.html.haml +2 -0
- data/app/views/tenon/fields/_inline_check_box.html.haml +5 -0
- data/app/views/tenon/fields/_inline_radio_button.html.haml +5 -0
- data/app/views/tenon/fields/_number_field.html.haml +2 -0
- data/app/views/tenon/fields/_password_field.html.haml +2 -0
- data/app/views/tenon/fields/_phone_field.html.haml +2 -0
- data/app/views/tenon/fields/_radio_button.html.haml +9 -0
- data/app/views/tenon/fields/_rich_text.html.haml +3 -6
- data/app/views/tenon/fields/_select.html.haml +3 -0
- data/app/views/tenon/fields/_text_area.html.haml +2 -0
- data/app/views/tenon/fields/_text_field.html.haml +2 -0
- data/app/views/tenon/fields/_title_text_field.html.haml +2 -0
- data/app/views/tenon/fields/_url_field.html.haml +2 -0
- data/app/views/tenon/index/index.html.haml +8 -29
- data/app/views/tenon/item_assets/new.html.haml +20 -22
- data/app/views/tenon/item_versions/_item_version.json.jbuilder +4 -4
- data/app/views/tenon/item_versions/index.html.haml +14 -6
- data/app/views/tenon/item_versions/new.html.haml +8 -10
- data/app/views/tenon/settings/_contact.html.haml +14 -19
- data/app/views/tenon/settings/_general.html.haml +15 -11
- data/app/views/tenon/settings/_seo.html.haml +10 -9
- data/app/views/tenon/settings/show.html.haml +12 -31
- data/app/views/tenon/shared/_account_dropdown.html.haml +6 -0
- data/app/views/tenon/shared/_app_info.html.haml +5 -0
- data/app/views/tenon/shared/_breadcrumbs.html.haml +1 -0
- data/app/views/tenon/shared/_burger.html.haml +5 -0
- data/app/views/tenon/shared/_default_form_toolbar.html.haml +26 -0
- data/app/views/tenon/shared/_draft_controls.html.haml +18 -0
- data/app/views/tenon/shared/_i18n_language_nav.html.haml +2 -2
- data/app/views/tenon/shared/_main_nav.html.haml +3 -14
- data/app/views/tenon/shared/_platform_hints.html.haml +15 -15
- data/app/views/tenon/shared/_seo_fields.html.haml +8 -6
- data/app/views/tenon/shared/_site_title.html.haml +6 -0
- data/app/views/tenon/shared/_util_nav.html.haml +4 -27
- data/app/views/tenon/shared/_version_warning.html.haml +11 -11
- data/app/views/tenon/styleguides/_buttons.html.haml +118 -0
- data/app/views/tenon/styleguides/_colors.html.haml +59 -0
- data/app/views/tenon/styleguides/_forms.html.haml +4 -0
- data/app/views/tenon/styleguides/_icons.html.haml +21 -0
- data/app/views/tenon/styleguides/_typography.html.haml +27 -0
- data/app/views/tenon/styleguides/buttons/_colors.html.haml +43 -0
- data/app/views/tenon/styleguides/buttons/_styles.html.haml +59 -0
- data/app/views/tenon/styleguides/colors/_helpers.html.haml +48 -0
- data/app/views/tenon/styleguides/colors/_variables.html.haml +31 -0
- data/app/views/tenon/styleguides/forms/_default.html.haml +92 -0
- data/app/views/tenon/styleguides/forms/_html5.html.haml +31 -0
- data/app/views/tenon/styleguides/forms/_tenon_content.html.haml +15 -0
- data/app/views/tenon/styleguides/index.html.haml +52 -0
- data/app/views/tenon/styleguides/typography/_blockquote.html.haml +7 -0
- data/app/views/tenon/styleguides/typography/_inline.html.haml +8 -0
- data/app/views/tenon/styleguides/typography/_lists.html.haml +40 -0
- data/app/views/tenon/styleguides/typography/_paragraphs.html.haml +17 -0
- data/app/views/tenon/styleguides/typography/_small.html.haml +18 -0
- data/app/views/tenon/styleguides/typography/_styles.html.haml +14 -0
- data/app/views/tenon/styleguides/typography/_variables.html.haml +43 -0
- data/app/views/tenon/tenon_content/_display.html.haml +2 -2
- data/app/views/tenon/tenon_content/_embed_modal.html.haml +3 -3
- data/app/views/tenon/tenon_content/_fields.html.haml +21 -35
- data/app/views/tenon/tenon_content/_row.html.haml +14 -13
- data/app/views/tenon/tenon_content/{_builder.html.haml → _tenon_content.html.haml} +2 -2
- data/app/views/tenon/tenon_content/piece_types/form/_background_image.html.haml +6 -6
- data/app/views/tenon/tenon_content/piece_types/form/_embedded_content.html.haml +2 -1
- data/app/views/tenon/tenon_content/piece_types/form/_image.html.haml +37 -29
- data/app/views/tenon/tenon_content/row_types/display/_four_column_image.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_four_column_image_and_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_four_column_text.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_full_width_embedded_content.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_full_width_image.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_full_width_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_left_image_right_text.html.haml +8 -8
- data/app/views/tenon/tenon_content/row_types/display/_left_text_right_image.html.haml +7 -7
- data/app/views/tenon/tenon_content/row_types/display/_left_wrapped_image_with_text.html.haml +6 -6
- data/app/views/tenon/tenon_content/row_types/display/_right_wrapped_image_with_text.html.haml +7 -7
- data/app/views/tenon/tenon_content/row_types/display/_six_column_image.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_six_column_image_and_text.html.haml +5 -5
- data/app/views/tenon/tenon_content/row_types/display/_three_column_image.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_three_column_image_and_text.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_three_column_text.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_two_column_image.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_two_column_image_and_text.html.haml +4 -4
- data/app/views/tenon/tenon_content/row_types/display/_two_column_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/display/_two_column_with_background_image.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_four_column_image.html.haml +2 -2
- data/app/views/tenon/tenon_content/row_types/form/_four_column_image_and_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_four_column_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_full_width_embedded_content.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_full_width_image.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_full_width_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_left_image_right_text.html.haml +9 -8
- data/app/views/tenon/tenon_content/row_types/form/_left_text_right_image.html.haml +6 -6
- data/app/views/tenon/tenon_content/row_types/form/_left_wrapped_image_with_text.html.haml +7 -7
- data/app/views/tenon/tenon_content/row_types/form/_right_wrapped_image_with_text.html.haml +7 -7
- data/app/views/tenon/tenon_content/row_types/form/_six_column_image.html.haml +2 -2
- data/app/views/tenon/tenon_content/row_types/form/_six_column_image_and_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_three_column_image.html.haml +2 -2
- data/app/views/tenon/tenon_content/row_types/form/_three_column_image_and_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_three_column_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_two_column_image.html.haml +2 -2
- data/app/views/tenon/tenon_content/row_types/form/_two_column_image_and_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_two_column_text.html.haml +3 -3
- data/app/views/tenon/tenon_content/row_types/form/_two_column_with_background_image.html.haml +2 -2
- data/config/initializers/class_extensions/hash.rb +1 -1
- data/config/initializers/client_side_validations.rb +27 -0
- data/config/initializers/tenon.rb +0 -14
- data/config/routes.rb +10 -46
- data/db/migrate/20151117171000_drop_default_tenon_resources.rb +15 -0
- data/db/migrate/20160119185645_remove_tenon_users.rb +7 -0
- data/db/migrate/20160126123154_remove_tenon_callouts_subscribers.rb +8 -0
- data/db/migrate/20160126194219_convert_piece_size_to_int.rb +6 -0
- data/lib/ckeditor/plugins/pastefromword/filter/default.js +1 -1
- data/lib/generators/tenon/scaffold/scaffold_generator.rb +52 -27
- data/lib/generators/tenon/scaffold/templates/controller.rb +7 -4
- data/lib/generators/tenon/scaffold/templates/policy.rb +2 -0
- data/lib/generators/tenon/scaffold/templates/serializer.rb +2 -0
- data/lib/generators/tenon/scaffold/templates/view__form.html.haml +49 -54
- data/lib/generators/tenon/scaffold/templates/view_edit.html.haml +1 -8
- data/lib/generators/tenon/scaffold/templates/view_index.html.haml +8 -24
- data/lib/generators/tenon/scaffold/templates/view_new.html.haml +1 -8
- data/lib/tasks/tenon_tasks.rake +2 -2
- data/lib/templates/active_record/model/model.rb +12 -13
- data/lib/templates/migration/templates/create_table_migration.rb +1 -1
- data/lib/tenon/can_be_foreign.rb +1 -1
- data/lib/tenon/engine.rb +26 -32
- data/lib/tenon/filterers/base_filterer.rb +64 -0
- data/lib/tenon/has_history/attr_serializer.rb +6 -6
- data/lib/tenon/proxy_attachment.rb +2 -2
- data/lib/tenon/version.rb +1 -1
- data/lib/tenon.rb +1 -3
- data/vendor/assets/javascripts/bootstrap.modal.js +1 -1
- data/vendor/assets/javascripts/date_picker/picker.date.js +1429 -0
- data/vendor/assets/javascripts/date_picker/picker.js +1122 -0
- data/vendor/assets/javascripts/number-to-words.es6 +35 -0
- data/vendor/assets/stylesheets/bootstrap.scss +1 -1
- metadata +206 -972
- data/app/assets/images/tenon/icons/delete.png +0 -0
- data/app/assets/images/tenon/icons/edit.png +0 -0
- data/app/assets/images/tenon/icons/thumbdown.png +0 -0
- data/app/assets/images/tenon/icons/thumbup.png +0 -0
- data/app/assets/images/tenon/select2-spinner.gif +0 -0
- data/app/assets/images/tenon/select2.png +0 -0
- data/app/assets/images/tenon/select2x2.png +0 -0
- data/app/assets/javascripts/tenon/controllers/assets.js.coffee +0 -3
- data/app/assets/javascripts/tenon/controllers/index.js.coffee +0 -6
- data/app/assets/javascripts/tenon/controllers/tenon.js.coffee +0 -1
- data/app/assets/javascripts/tenon/features/asset_attachment.js.coffee +0 -37
- data/app/assets/javascripts/tenon/features/asset_cropping.js.coffee +0 -49
- data/app/assets/javascripts/tenon/features/asset_detachment.js.coffee +0 -11
- data/app/assets/javascripts/tenon/features/asset_list_post_crop_handler.js.coffee +0 -15
- data/app/assets/javascripts/tenon/features/asset_uploader.js.coffee +0 -88
- data/app/assets/javascripts/tenon/features/box_toggles.js.coffee +0 -17
- data/app/assets/javascripts/tenon/features/cocoon_hooks.js.coffee +0 -12
- data/app/assets/javascripts/tenon/features/date_time_picker.js.coffee +0 -25
- data/app/assets/javascripts/tenon/features/editor.js.coffee +0 -24
- data/app/assets/javascripts/tenon/features/file_select_widget.js.erb +0 -39
- data/app/assets/javascripts/tenon/features/flash.js.coffee +0 -13
- data/app/assets/javascripts/tenon/features/focus_first_field.js.coffee +0 -8
- data/app/assets/javascripts/tenon/features/hamburger_navigation.js.coffee +0 -26
- data/app/assets/javascripts/tenon/features/header_menu.js.coffee +0 -20
- data/app/assets/javascripts/tenon/features/i18n_fields.js.coffee +0 -23
- data/app/assets/javascripts/tenon/features/infinite_loading.js.coffee +0 -12
- data/app/assets/javascripts/tenon/features/item_version_autosave.js.coffee +0 -35
- data/app/assets/javascripts/tenon/features/item_version_index_handler.js.coffee +0 -3
- data/app/assets/javascripts/tenon/features/main_menu.js.coffee +0 -11
- data/app/assets/javascripts/tenon/features/modal_forms.js.coffee +0 -44
- data/app/assets/javascripts/tenon/features/modal_windows.js.coffee +0 -104
- data/app/assets/javascripts/tenon/features/multiple_asset_attachment.js.coffee +0 -8
- data/app/assets/javascripts/tenon/features/nested_fields.js +0 -95
- data/app/assets/javascripts/tenon/features/nested_lists.js +0 -10
- data/app/assets/javascripts/tenon/features/nested_set_writer.js.coffee +0 -65
- data/app/assets/javascripts/tenon/features/new_item_version_handler.js.coffee +0 -32
- data/app/assets/javascripts/tenon/features/pagination.js.coffee +0 -21
- data/app/assets/javascripts/tenon/features/protect_changes.js.coffee +0 -25
- data/app/assets/javascripts/tenon/features/quick_search.js.coffee +0 -41
- data/app/assets/javascripts/tenon/features/record_approval.js.coffee +0 -33
- data/app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee +0 -37
- data/app/assets/javascripts/tenon/features/record_deletion.js.coffee +0 -24
- data/app/assets/javascripts/tenon/features/record_list.js.coffee +0 -86
- data/app/assets/javascripts/tenon/features/record_list_updater.js.coffee +0 -56
- data/app/assets/javascripts/tenon/features/s3_direct_upload.js.coffee +0 -43
- data/app/assets/javascripts/tenon/features/sidebar_active_links.js.coffee +0 -20
- data/app/assets/javascripts/tenon/features/sortable_nested_fields.js.coffee +0 -17
- data/app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee +0 -31
- data/app/assets/javascripts/tenon/features/tenon_content/asset_attachment.js.coffee +0 -15
- data/app/assets/javascripts/tenon/features/tenon_content/asset_link.js.coffee +0 -11
- data/app/assets/javascripts/tenon/features/tenon_content/base.js.coffee +0 -16
- data/app/assets/javascripts/tenon/features/tenon_content/bottombar_toggler.js.coffee +0 -15
- data/app/assets/javascripts/tenon/features/tenon_content/caption_toggler.js.coffee +0 -11
- data/app/assets/javascripts/tenon/features/tenon_content/column_sizing.js.coffee +0 -53
- data/app/assets/javascripts/tenon/features/tenon_content/column_swap.js.coffee +0 -44
- data/app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee +0 -34
- data/app/assets/javascripts/tenon/features/tenon_content/embedded_content_modal_handler.js.coffee +0 -12
- data/app/assets/javascripts/tenon/features/tenon_content/image_asset_link.js.coffee +0 -5
- data/app/assets/javascripts/tenon/features/tenon_content/image_controls.js.coffee +0 -63
- data/app/assets/javascripts/tenon/features/tenon_content/image_links.js.coffee +0 -54
- data/app/assets/javascripts/tenon/features/tenon_content/library.js.coffee +0 -39
- data/app/assets/javascripts/tenon/features/tenon_content/library_filter.js.coffee +0 -17
- data/app/assets/javascripts/tenon/features/tenon_content/pop_out.js.coffee +0 -46
- data/app/assets/javascripts/tenon/features/tenon_content/post_crop_handler.js.coffee +0 -22
- data/app/assets/javascripts/tenon/features/tenon_content/sidebar_navigation.js.coffee +0 -26
- data/app/assets/javascripts/tenon/features/tenon_content/sortable.js.coffee +0 -18
- data/app/assets/javascripts/tenon/features/tenon_content/stretch_to_fill.js.coffee +0 -50
- data/app/assets/javascripts/tenon/features/tenon_content/wrapped_sizing.js.coffee +0 -48
- data/app/assets/javascripts/tenon/features/tenon_content.js.coffee +0 -1
- data/app/assets/javascripts/tenon/features/video_feeds.js.coffee +0 -4
- data/app/assets/javascripts/tenon/manifest.json +0 -44
- data/app/assets/javascripts/tenon/medium-on-tenon.js +0 -1465
- data/app/assets/javascripts/tenon/templates/assets/asset_field.jst.eco +0 -17
- data/app/assets/javascripts/tenon/templates/assets/asset_progress.jst.eco +0 -8
- data/app/assets/javascripts/tenon/templates/assets/asset_row.jst.eco +0 -21
- data/app/assets/javascripts/tenon/templates/assets/asset_select.jst.eco +0 -1
- data/app/assets/javascripts/tenon/templates/comments/comment_row.jst.eco +0 -23
- data/app/assets/javascripts/tenon/templates/contacts/contact_row.jst.eco +0 -56
- data/app/assets/javascripts/tenon/templates/errors.jst.eco +0 -13
- data/app/assets/javascripts/tenon/templates/events/event_row.jst.eco +0 -22
- data/app/assets/javascripts/tenon/templates/galleries/gallery_row.jst.eco +0 -12
- data/app/assets/javascripts/tenon/templates/item_versions/item_version_row.jst.eco +0 -22
- data/app/assets/javascripts/tenon/templates/modal.jst.eco +0 -14
- data/app/assets/javascripts/tenon/templates/pages/page_row.jst.eco +0 -21
- data/app/assets/javascripts/tenon/templates/post_categories/post_category_row.jst.eco +0 -12
- data/app/assets/javascripts/tenon/templates/posts/post_row.jst.eco +0 -30
- data/app/assets/javascripts/tenon/templates/redirects/redirect_row.jst.eco +0 -18
- data/app/assets/javascripts/tenon/templates/tenon_callouts/tenon_callout_row.jst.eco +0 -19
- data/app/assets/javascripts/tenon/templates/tenon_content/popped_out.jst.eco +0 -6
- data/app/assets/javascripts/tenon/templates/users/user_row.jst.eco +0 -21
- data/app/assets/javascripts/tenon/tenon.js +0 -68
- data/app/assets/javascripts/tenon/tenon_dispatcher.js.coffee +0 -25
- data/app/assets/javascripts/tenon/tenon_manifest.js +0 -45
- data/app/assets/stylesheets/tenon/colors-custom.scss +0 -25
- data/app/assets/stylesheets/tenon/colors-named.scss +0 -22
- data/app/assets/stylesheets/tenon/helpers.scss +0 -28
- data/app/assets/stylesheets/tenon/layout/assets.scss +0 -49
- data/app/assets/stylesheets/tenon/layout/breakpoints.scss +0 -48
- data/app/assets/stylesheets/tenon/layout/global.scss +0 -36
- data/app/assets/stylesheets/tenon/layout/grid.scss +0 -145
- data/app/assets/stylesheets/tenon/layout/main-nav.scss +0 -149
- data/app/assets/stylesheets/tenon/layout/margins.scss +0 -3
- data/app/assets/stylesheets/tenon/layout/mobile.scss +0 -5
- data/app/assets/stylesheets/tenon/layout/sidebar.scss +0 -102
- data/app/assets/stylesheets/tenon/layout/util-nav.scss +0 -51
- data/app/assets/stylesheets/tenon/mixins.scss +0 -81
- data/app/assets/stylesheets/tenon/styleguide.scss +0 -6
- data/app/assets/stylesheets/tenon/tenon.scss +0 -71
- data/app/assets/stylesheets/tenon/typography.scss +0 -65
- data/app/assets/stylesheets/tenon/ui/alerts.scss +0 -65
- data/app/assets/stylesheets/tenon/ui/asset-attachment.scss +0 -136
- data/app/assets/stylesheets/tenon/ui/asset-cropping.scss +0 -51
- data/app/assets/stylesheets/tenon/ui/asset-uploads.scss +0 -26
- data/app/assets/stylesheets/tenon/ui/buttons.scss +0 -65
- data/app/assets/stylesheets/tenon/ui/callouts.scss +0 -26
- data/app/assets/stylesheets/tenon/ui/comments.scss +0 -57
- data/app/assets/stylesheets/tenon/ui/forms.scss +0 -204
- data/app/assets/stylesheets/tenon/ui/generic-loader.scss +0 -21
- data/app/assets/stylesheets/tenon/ui/header-tools.scss +0 -116
- data/app/assets/stylesheets/tenon/ui/i18n.scss +0 -18
- data/app/assets/stylesheets/tenon/ui/list-style-toggle.scss +0 -39
- data/app/assets/stylesheets/tenon/ui/login.scss +0 -97
- data/app/assets/stylesheets/tenon/ui/medium-editor.scss +0 -114
- data/app/assets/stylesheets/tenon/ui/modals.scss +0 -179
- data/app/assets/stylesheets/tenon/ui/pagination.scss +0 -113
- data/app/assets/stylesheets/tenon/ui/progress-bars.scss +0 -131
- data/app/assets/stylesheets/tenon/ui/quick-search.scss +0 -20
- data/app/assets/stylesheets/tenon/ui/record-grids.scss +0 -95
- data/app/assets/stylesheets/tenon/ui/record-lists.scss +0 -154
- data/app/assets/stylesheets/tenon/ui/section-headers.scss +0 -30
- data/app/assets/stylesheets/tenon/ui/select2-custom.scss +0 -70
- data/app/assets/stylesheets/tenon/ui/tables.scss +0 -19
- data/app/assets/stylesheets/tenon/ui/tabs.scss +0 -7
- data/app/assets/stylesheets/tenon/ui/tenon-content-library.scss +0 -80
- data/app/assets/stylesheets/tenon/ui/tenon-content-popped-out.scss +0 -92
- data/app/assets/stylesheets/tenon/ui/tenon-content.scss +0 -318
- data/app/assets/stylesheets/tenon/ui/thinking.scss +0 -3
- data/app/assets/stylesheets/tenon/ui/toolbox.scss +0 -31
- data/app/assets/stylesheets/tenon/z-indexes.scss +0 -35
- data/app/assets/stylesheets/tenon_addons.scss +0 -1
- data/app/controllers/tenon/comments_controller.rb +0 -51
- data/app/controllers/tenon/contacts_controller.rb +0 -65
- data/app/controllers/tenon/events_controller.rb +0 -9
- data/app/controllers/tenon/galleries_controller.rb +0 -9
- data/app/controllers/tenon/pages_controller.rb +0 -51
- data/app/controllers/tenon/post_categories_controller.rb +0 -9
- data/app/controllers/tenon/posts_controller.rb +0 -28
- data/app/controllers/tenon/redirects_controller.rb +0 -25
- data/app/controllers/tenon/tenon_callouts_controller.rb +0 -7
- data/app/controllers/tenon/users_controller.rb +0 -64
- data/app/decorators/tenon/comment_decorator.rb +0 -22
- data/app/decorators/tenon/contact_decorator.rb +0 -13
- data/app/decorators/tenon/event_decorator.rb +0 -11
- data/app/decorators/tenon/gallery_decorator.rb +0 -4
- data/app/decorators/tenon/page_decorator.rb +0 -11
- data/app/decorators/tenon/post_category_decorator.rb +0 -4
- data/app/decorators/tenon/post_decorator.rb +0 -4
- data/app/decorators/tenon/redirect_decorator.rb +0 -2
- data/app/decorators/tenon/tenon_callout_decorator.rb +0 -4
- data/app/decorators/tenon/user_decorator.rb +0 -4
- data/app/mailers/tenon/comment_mailer.rb +0 -16
- data/app/mailers/tenon/contact_mailer.rb +0 -15
- data/app/models/ability.rb +0 -32
- data/app/models/tenon/comment.rb +0 -47
- data/app/models/tenon/comment_subscriber.rb +0 -7
- data/app/models/tenon/contact.rb +0 -46
- data/app/models/tenon/event.rb +0 -45
- data/app/models/tenon/gallery.rb +0 -15
- data/app/models/tenon/page.rb +0 -105
- data/app/models/tenon/photo.rb +0 -10
- data/app/models/tenon/post.rb +0 -35
- data/app/models/tenon/post_category.rb +0 -7
- data/app/models/tenon/redirect.rb +0 -17
- data/app/models/tenon/role.rb +0 -8
- data/app/models/tenon/role_assignment.rb +0 -6
- data/app/models/tenon/s3_direct_upload.rb +0 -75
- data/app/models/tenon/tenon_callout.rb +0 -16
- data/app/models/tenon/user.rb +0 -60
- data/app/views/devise/confirmations/new.html.erb +0 -12
- data/app/views/devise/confirmations/new.html.haml +0 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +0 -7
- data/app/views/devise/mailer/reset_password_instructions.html.haml +0 -15
- data/app/views/devise/mailer/unlock_instructions.html.haml +0 -9
- data/app/views/devise/passwords/edit.html.haml +0 -22
- data/app/views/devise/passwords/new.html.haml +0 -17
- data/app/views/devise/registrations/edit.html.haml +0 -0
- data/app/views/devise/registrations/new.html.haml +0 -22
- data/app/views/devise/sessions/new.html.haml +0 -28
- data/app/views/devise/shared/_links.erb +0 -19
- data/app/views/devise/shared/_links.haml +0 -0
- data/app/views/devise/unlocks/new.html.erb +0 -12
- data/app/views/devise/unlocks/new.html.haml +0 -0
- data/app/views/layouts/tenon/login.html.haml +0 -19
- data/app/views/tenon/assets/_asset.json.jbuilder +0 -7
- data/app/views/tenon/assets/_sidebar_index.html.haml +0 -18
- data/app/views/tenon/assets/create.json.jbuilder +0 -1
- data/app/views/tenon/assets/index.json.jbuilder +0 -5
- data/app/views/tenon/assets/update.json.jbuilder +0 -1
- data/app/views/tenon/comment_mailer/comment_notification.html.haml +0 -7
- data/app/views/tenon/comments/_sidebar_index.html.haml +0 -22
- data/app/views/tenon/comments/index.html.haml +0 -19
- data/app/views/tenon/comments/index.json.jbuilder +0 -22
- data/app/views/tenon/contact_mailer/contact_notification.html.haml +0 -15
- data/app/views/tenon/contacts/_sidebar_index.html.haml +0 -32
- data/app/views/tenon/contacts/index.html.haml +0 -19
- data/app/views/tenon/contacts/index.json.jbuilder +0 -15
- data/app/views/tenon/events/_form.html.haml +0 -44
- data/app/views/tenon/events/edit.html.haml +0 -8
- data/app/views/tenon/events/index.html.haml +0 -23
- data/app/views/tenon/events/index.json.jbuilder +0 -16
- data/app/views/tenon/events/new.html.haml +0 -8
- data/app/views/tenon/galleries/_form.html.haml +0 -38
- data/app/views/tenon/galleries/_photo_fields.html.haml +0 -3
- data/app/views/tenon/galleries/edit.html.haml +0 -8
- data/app/views/tenon/galleries/index.html.haml +0 -22
- data/app/views/tenon/galleries/index.json.jbuilder +0 -15
- data/app/views/tenon/galleries/new.html.haml +0 -8
- data/app/views/tenon/pages/_form.html.haml +0 -58
- data/app/views/tenon/pages/edit.html.haml +0 -8
- data/app/views/tenon/pages/index.html.haml +0 -23
- data/app/views/tenon/pages/index.json.jbuilder +0 -22
- data/app/views/tenon/pages/new.html.haml +0 -8
- data/app/views/tenon/post_categories/_form.html.haml +0 -11
- data/app/views/tenon/post_categories/_post_category.json.jbuilder +0 -2
- data/app/views/tenon/post_categories/create.json.jbuilder +0 -1
- data/app/views/tenon/post_categories/edit.html.haml +0 -1
- data/app/views/tenon/post_categories/index.html.haml +0 -30
- data/app/views/tenon/post_categories/index.json.jbuilder +0 -5
- data/app/views/tenon/post_categories/update.json.jbuilder +0 -1
- data/app/views/tenon/posts/_form.html.haml +0 -65
- data/app/views/tenon/posts/edit.html.haml +0 -8
- data/app/views/tenon/posts/index.html.haml +0 -27
- data/app/views/tenon/posts/index.json.jbuilder +0 -20
- data/app/views/tenon/posts/new.html.haml +0 -8
- data/app/views/tenon/redirects/_form.html.haml +0 -42
- data/app/views/tenon/redirects/_redirect.json.jbuilder +0 -3
- data/app/views/tenon/redirects/edit.html.haml +0 -8
- data/app/views/tenon/redirects/index.html.haml +0 -29
- data/app/views/tenon/redirects/index.json.jbuilder +0 -5
- data/app/views/tenon/redirects/new.html.haml +0 -8
- data/app/views/tenon/shared/_posts_nav.html.haml +0 -8
- data/app/views/tenon/shared/menu_items/_assets.html.haml +0 -3
- data/app/views/tenon/shared/menu_items/_comments.html.haml +0 -2
- data/app/views/tenon/shared/menu_items/_events.html.haml +0 -6
- data/app/views/tenon/shared/menu_items/_galleries.html.haml +0 -6
- data/app/views/tenon/shared/menu_items/_pages.html.haml +0 -6
- data/app/views/tenon/shared/menu_items/_posts.html.haml +0 -7
- data/app/views/tenon/shared/menu_items/_settings.html.haml +0 -2
- data/app/views/tenon/shared/menu_items/_users.html.haml +0 -2
- data/app/views/tenon/shared/section_header/_quick_search.html.haml +0 -3
- data/app/views/tenon/shared/section_header/_sidebar_toggle.html.haml +0 -1
- data/app/views/tenon/tenon_callouts/_form.html.haml +0 -45
- data/app/views/tenon/tenon_callouts/_tenon_callout.json.jbuilder +0 -1
- data/app/views/tenon/tenon_callouts/edit.html.haml +0 -8
- data/app/views/tenon/tenon_callouts/index.html.haml +0 -24
- data/app/views/tenon/tenon_callouts/index.json.jbuilder +0 -5
- data/app/views/tenon/tenon_callouts/new.html.haml +0 -8
- data/app/views/tenon/users/_form.html.haml +0 -50
- data/app/views/tenon/users/edit.html.haml +0 -8
- data/app/views/tenon/users/index.html.haml +0 -23
- data/app/views/tenon/users/index.json.jbuilder +0 -28
- data/app/views/tenon/users/new.html.haml +0 -8
- data/config/initializers/devise.rb +0 -258
- data/config/locales/devise.en.yml +0 -60
- data/config/locales/tenon.en.yml +0 -313
- data/db/seeds.rb +0 -47
- data/lib/generators/tenon/scaffold/templates/view__item.json.jbuilder +0 -1
- data/lib/generators/tenon/scaffold/templates/view_index.json.jbuilder +0 -5
- data/lib/generators/tenon/scaffold/templates/view_item_row.jst.eco +0 -13
- data/lib/generators/tenon/scaffold_small/scaffold_small_generator.rb +0 -8
- data/lib/generators/tenon/scaffold_small/templates/controller.rb +0 -19
- data/lib/generators/tenon/scaffold_small/templates/decorator.rb +0 -2
- data/lib/generators/tenon/scaffold_small/templates/view__form.html.haml +0 -26
- data/lib/generators/tenon/scaffold_small/templates/view__item.json.jbuilder +0 -2
- data/lib/generators/tenon/scaffold_small/templates/view_create.json.jbuilder +0 -1
- data/lib/generators/tenon/scaffold_small/templates/view_index.html.haml +0 -27
- data/lib/generators/tenon/scaffold_small/templates/view_index.json.jbuilder +0 -5
- data/lib/generators/tenon/scaffold_small/templates/view_item_row.jst.eco +0 -12
- data/lib/generators/tenon/scaffold_small/templates/view_update.json.jbuilder +0 -1
- data/lib/tenon/can_have_comments.rb +0 -16
- data/lib/tenon/config/events.rb +0 -29
- data/lib/tenon/factories/comments.rb +0 -10
- data/lib/tenon/factories/contacts.rb +0 -9
- data/lib/tenon/factories/events.rb +0 -7
- data/lib/tenon/factories/galleries.rb +0 -5
- data/lib/tenon/factories/pages.rb +0 -5
- data/lib/tenon/factories/posts.rb +0 -10
- data/lib/tenon/factories/redirects.rb +0 -9
- data/lib/tenon/factories/tenon_callouts.rb +0 -9
- data/lib/tenon/factories/users.rb +0 -26
- data/lib/tenon/warning_generator.rb +0 -29
- data/spec/controllers/tenon/assets_controller_spec.rb +0 -262
- data/spec/controllers/tenon/comments_controller_spec.rb +0 -173
- data/spec/controllers/tenon/contacts_controller_spec.rb +0 -174
- data/spec/controllers/tenon/index_controller_spec.rb +0 -31
- data/spec/controllers/tenon/item_assets_controller_spec.rb +0 -29
- data/spec/controllers/tenon/pages_controller_spec.rb +0 -67
- data/spec/controllers/tenon/posts_controller_spec.rb +0 -31
- data/spec/controllers/tenon/resources_controller_spec.rb +0 -352
- data/spec/controllers/tenon/settings_controller_spec.rb +0 -65
- data/spec/controllers/tenon/simple_resources_controller_spec.rb +0 -42
- data/spec/controllers/tenon/users_controller_spec.rb +0 -112
- data/spec/decorators/tenon/application_decorator_spec.rb +0 -75
- data/spec/decorators/tenon/asset_decorator_spec.rb +0 -101
- data/spec/decorators/tenon/comment_decorator_spec.rb +0 -43
- data/spec/decorators/tenon/contact_decorator_spec.rb +0 -24
- data/spec/decorators/tenon/event_decorator_spec.rb +0 -26
- data/spec/decorators/tenon/page_decorator_spec.rb +0 -23
- data/spec/decorators/tenon/tenon_content/row_type_decorator_spec.rb +0 -20
- data/spec/features/settings_spec.rb +0 -75
- data/spec/features/tenon/assets_spec.rb +0 -88
- data/spec/features/tenon/comments_spec.rb +0 -51
- data/spec/features/tenon/contacts_spec.rb +0 -51
- data/spec/features/tenon/events_spec.rb +0 -104
- data/spec/features/tenon/galleries_spec.rb +0 -107
- data/spec/features/tenon/i18n_spec.rb +0 -106
- data/spec/features/tenon/pages_spec.rb +0 -97
- data/spec/features/tenon/post_categories_spec.rb +0 -91
- data/spec/features/tenon/posts_spec.rb +0 -93
- data/spec/features/tenon/tenon_callouts_spec.rb +0 -101
- data/spec/features/tenon/users_spec.rb +0 -98
- data/spec/fixtures/files/test.png +0 -0
- data/spec/lib/tenon/asset_style_generator_spec.rb +0 -84
- data/spec/lib/tenon/can_be_foreign_spec.rb +0 -20
- data/spec/lib/tenon/can_have_comments_spec.rb +0 -22
- data/spec/lib/tenon/has_asset_spec.rb +0 -46
- data/spec/lib/tenon/has_history/attr_serializer_spec.rb +0 -63
- data/spec/lib/tenon/i18n_lookup_spec.rb +0 -88
- data/spec/lib/tenon/proxy_attachment_spec.rb +0 -96
- data/spec/lib/tenon/reorderable_spec.rb +0 -25
- data/spec/lib/tenon/tenon_content_spec.rb +0 -22
- data/spec/lib/tenon/warning_generator_spec.rb +0 -153
- data/spec/models/tenon/asset_spec.rb +0 -98
- data/spec/models/tenon/comment_spec.rb +0 -81
- data/spec/models/tenon/contact_spec.rb +0 -62
- data/spec/models/tenon/event_spec.rb +0 -79
- data/spec/models/tenon/gallery_spec.rb +0 -12
- data/spec/models/tenon/item_asset_spec.rb +0 -19
- data/spec/models/tenon/my_settings_spec.rb +0 -27
- data/spec/models/tenon/page_spec.rb +0 -60
- data/spec/models/tenon/post_spec.rb +0 -48
- data/spec/models/tenon/redirect_spec.rb +0 -31
- data/spec/models/tenon/tenon_callout_spec.rb +0 -10
- data/spec/models/tenon/tenon_content/row_spec.rb +0 -34
- data/spec/models/tenon/user_spec.rb +0 -59
- data/spec/services/tenon/redirector_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -79
- data/spec/support/integration_example_group.rb +0 -35
- data/spec/support/request_helpers.rb +0 -10
- data/vendor/assets/javascripts/backstretch.js +0 -4
- data/vendor/assets/javascripts/bootstrap.collapse.js +0 -179
- data/vendor/assets/javascripts/bootstrap.datetimepicker.js +0 -954
- data/vendor/assets/javascripts/bootstrap.tabs.js +0 -135
- data/vendor/assets/javascripts/cufon/Aller_400.font.js +0 -7
- data/vendor/assets/javascripts/cufon/Aller_700.font.js +0 -7
- data/vendor/assets/javascripts/cufon/cufon.js +0 -7
- data/vendor/assets/javascripts/jquery.corner.js +0 -249
- data/vendor/assets/javascripts/jquery.hoverIntent.js +0 -115
- data/vendor/assets/javascripts/jquery.radioSlider.js +0 -55
- data/vendor/assets/javascripts/jscrollpane.js +0 -1435
- data/vendor/assets/javascripts/select2.js +0 -3
- data/vendor/assets/javascripts/underscore.inflection.js +0 -177
- data/vendor/assets/stylesheets/bootstrap.datetimepicker.css +0 -152
- data/vendor/assets/stylesheets/bootstrap.tables.scss +0 -201
- data/vendor/assets/stylesheets/jscrollpane.scss +0 -20
- data/vendor/assets/stylesheets/select2.css +0 -1
@@ -0,0 +1,1429 @@
|
|
1
|
+
/*!
|
2
|
+
* Date picker for pickadate.js v3.5.0
|
3
|
+
* http://amsul.github.io/pickadate.js/date.htm
|
4
|
+
*/
|
5
|
+
|
6
|
+
(function ( factory ) {
|
7
|
+
|
8
|
+
// AMD.
|
9
|
+
if ( typeof define == 'function' && define.amd )
|
10
|
+
define( ['picker', 'jquery'], factory )
|
11
|
+
|
12
|
+
// Node.js/browserify.
|
13
|
+
else if ( typeof exports == 'object' )
|
14
|
+
module.exports = factory( require('./picker.js'), require('jquery') )
|
15
|
+
|
16
|
+
// Browser globals.
|
17
|
+
else factory( Picker, jQuery )
|
18
|
+
|
19
|
+
}(function( Picker, $ ) {
|
20
|
+
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Globals and constants
|
24
|
+
*/
|
25
|
+
var DAYS_IN_WEEK = 7,
|
26
|
+
WEEKS_IN_CALENDAR = 6,
|
27
|
+
_ = Picker._
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* The date picker constructor
|
33
|
+
*/
|
34
|
+
function DatePicker( picker, settings ) {
|
35
|
+
|
36
|
+
var calendar = this,
|
37
|
+
element = picker.$node[ 0 ],
|
38
|
+
elementValue = element.value,
|
39
|
+
elementDataValue = picker.$node.data( 'value' ),
|
40
|
+
valueString = elementDataValue || elementValue,
|
41
|
+
formatString = elementDataValue ? settings.formatSubmit : settings.format,
|
42
|
+
isRTL = function() {
|
43
|
+
|
44
|
+
return element.currentStyle ?
|
45
|
+
|
46
|
+
// For IE.
|
47
|
+
element.currentStyle.direction == 'rtl' :
|
48
|
+
|
49
|
+
// For normal browsers.
|
50
|
+
getComputedStyle( picker.$root[0] ).direction == 'rtl'
|
51
|
+
}
|
52
|
+
|
53
|
+
calendar.settings = settings
|
54
|
+
calendar.$node = picker.$node
|
55
|
+
|
56
|
+
// The queue of methods that will be used to build item objects.
|
57
|
+
calendar.queue = {
|
58
|
+
min: 'measure create',
|
59
|
+
max: 'measure create',
|
60
|
+
now: 'now create',
|
61
|
+
select: 'parse create validate',
|
62
|
+
highlight: 'parse navigate create validate',
|
63
|
+
view: 'parse create validate viewset',
|
64
|
+
disable: 'deactivate',
|
65
|
+
enable: 'activate'
|
66
|
+
}
|
67
|
+
|
68
|
+
// The component's item object.
|
69
|
+
calendar.item = {}
|
70
|
+
|
71
|
+
calendar.item.clear = null
|
72
|
+
calendar.item.disable = ( settings.disable || [] ).slice( 0 )
|
73
|
+
calendar.item.enable = -(function( collectionDisabled ) {
|
74
|
+
return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
|
75
|
+
})( calendar.item.disable )
|
76
|
+
|
77
|
+
calendar.
|
78
|
+
set( 'min', settings.min ).
|
79
|
+
set( 'max', settings.max ).
|
80
|
+
set( 'now' )
|
81
|
+
|
82
|
+
// When there’s a value, set the `select`, which in turn
|
83
|
+
// also sets the `highlight` and `view`.
|
84
|
+
if ( valueString ) {
|
85
|
+
calendar.set( 'select', valueString, { format: formatString })
|
86
|
+
}
|
87
|
+
|
88
|
+
// If there’s no value, default to highlighting “today”.
|
89
|
+
else {
|
90
|
+
calendar.
|
91
|
+
set( 'select', null ).
|
92
|
+
set( 'highlight', calendar.item.now )
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
// The keycode to movement mapping.
|
97
|
+
calendar.key = {
|
98
|
+
40: 7, // Down
|
99
|
+
38: -7, // Up
|
100
|
+
39: function() { return isRTL() ? -1 : 1 }, // Right
|
101
|
+
37: function() { return isRTL() ? 1 : -1 }, // Left
|
102
|
+
go: function( timeChange ) {
|
103
|
+
var highlightedObject = calendar.item.highlight,
|
104
|
+
targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange )
|
105
|
+
calendar.set(
|
106
|
+
'highlight',
|
107
|
+
targetDate,
|
108
|
+
{ interval: timeChange }
|
109
|
+
)
|
110
|
+
this.render()
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
// Bind some picker events.
|
116
|
+
picker.
|
117
|
+
on( 'render', function() {
|
118
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
|
119
|
+
var value = this.value
|
120
|
+
if ( value ) {
|
121
|
+
picker.set( 'highlight', [ picker.get( 'view' ).year, value, picker.get( 'highlight' ).date ] )
|
122
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' )
|
123
|
+
}
|
124
|
+
})
|
125
|
+
picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
|
126
|
+
var value = this.value
|
127
|
+
if ( value ) {
|
128
|
+
picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
|
129
|
+
picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' )
|
130
|
+
}
|
131
|
+
})
|
132
|
+
}, 1 ).
|
133
|
+
on( 'open', function() {
|
134
|
+
var includeToday = ''
|
135
|
+
if ( calendar.disabled( calendar.get('now') ) ) {
|
136
|
+
includeToday = ':not(.' + settings.klass.buttonToday + ')'
|
137
|
+
}
|
138
|
+
picker.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false )
|
139
|
+
}, 1 ).
|
140
|
+
on( 'close', function() {
|
141
|
+
picker.$root.find( 'button, select' ).attr( 'disabled', true )
|
142
|
+
}, 1 )
|
143
|
+
|
144
|
+
} //DatePicker
|
145
|
+
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Set a datepicker item object.
|
149
|
+
*/
|
150
|
+
DatePicker.prototype.set = function( type, value, options ) {
|
151
|
+
|
152
|
+
var calendar = this,
|
153
|
+
calendarItem = calendar.item
|
154
|
+
|
155
|
+
// If the value is `null` just set it immediately.
|
156
|
+
if ( value === null ) {
|
157
|
+
if ( type == 'clear' ) type = 'select'
|
158
|
+
calendarItem[ type ] = value
|
159
|
+
return calendar
|
160
|
+
}
|
161
|
+
|
162
|
+
// Otherwise go through the queue of methods, and invoke the functions.
|
163
|
+
// Update this as the time unit, and set the final value as this item.
|
164
|
+
// * In the case of `enable`, keep the queue but set `disable` instead.
|
165
|
+
// And in the case of `flip`, keep the queue but set `enable` instead.
|
166
|
+
calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
|
167
|
+
value = calendar[ method ]( type, value, options )
|
168
|
+
return value
|
169
|
+
}).pop()
|
170
|
+
|
171
|
+
// Check if we need to cascade through more updates.
|
172
|
+
if ( type == 'select' ) {
|
173
|
+
calendar.set( 'highlight', calendarItem.select, options )
|
174
|
+
}
|
175
|
+
else if ( type == 'highlight' ) {
|
176
|
+
calendar.set( 'view', calendarItem.highlight, options )
|
177
|
+
}
|
178
|
+
else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
|
179
|
+
if ( calendarItem.select && calendar.disabled( calendarItem.select ) ) {
|
180
|
+
calendar.set( 'select', calendarItem.select, options )
|
181
|
+
}
|
182
|
+
if ( calendarItem.highlight && calendar.disabled( calendarItem.highlight ) ) {
|
183
|
+
calendar.set( 'highlight', calendarItem.highlight, options )
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
return calendar
|
188
|
+
} //DatePicker.prototype.set
|
189
|
+
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Get a datepicker item object.
|
193
|
+
*/
|
194
|
+
DatePicker.prototype.get = function( type ) {
|
195
|
+
return this.item[ type ]
|
196
|
+
} //DatePicker.prototype.get
|
197
|
+
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Create a picker date object.
|
201
|
+
*/
|
202
|
+
DatePicker.prototype.create = function( type, value, options ) {
|
203
|
+
|
204
|
+
var isInfiniteValue,
|
205
|
+
calendar = this
|
206
|
+
|
207
|
+
// If there’s no value, use the type as the value.
|
208
|
+
value = value === undefined ? type : value
|
209
|
+
|
210
|
+
|
211
|
+
// If it’s infinity, update the value.
|
212
|
+
if ( value == -Infinity || value == Infinity ) {
|
213
|
+
isInfiniteValue = value
|
214
|
+
}
|
215
|
+
|
216
|
+
// If it’s an object, use the native date object.
|
217
|
+
else if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
|
218
|
+
value = value.obj
|
219
|
+
}
|
220
|
+
|
221
|
+
// If it’s an array, convert it into a date and make sure
|
222
|
+
// that it’s a valid date – otherwise default to today.
|
223
|
+
else if ( $.isArray( value ) ) {
|
224
|
+
value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
|
225
|
+
value = _.isDate( value ) ? value : calendar.create().obj
|
226
|
+
}
|
227
|
+
|
228
|
+
// If it’s a number or date object, make a normalized date.
|
229
|
+
else if ( _.isInteger( value ) || _.isDate( value ) ) {
|
230
|
+
value = calendar.normalize( new Date( value ), options )
|
231
|
+
}
|
232
|
+
|
233
|
+
// If it’s a literal true or any other case, set it to now.
|
234
|
+
else /*if ( value === true )*/ {
|
235
|
+
value = calendar.now( type, value, options )
|
236
|
+
}
|
237
|
+
|
238
|
+
// Return the compiled object.
|
239
|
+
return {
|
240
|
+
year: isInfiniteValue || value.getFullYear(),
|
241
|
+
month: isInfiniteValue || value.getMonth(),
|
242
|
+
date: isInfiniteValue || value.getDate(),
|
243
|
+
day: isInfiniteValue || value.getDay(),
|
244
|
+
obj: isInfiniteValue || value,
|
245
|
+
pick: isInfiniteValue || value.getTime()
|
246
|
+
}
|
247
|
+
} //DatePicker.prototype.create
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Create a range limit object using an array, date object,
|
252
|
+
* literal “true”, or integer relative to another time.
|
253
|
+
*/
|
254
|
+
DatePicker.prototype.createRange = function( from, to ) {
|
255
|
+
|
256
|
+
var calendar = this,
|
257
|
+
createDate = function( date ) {
|
258
|
+
if ( date === true || $.isArray( date ) || _.isDate( date ) ) {
|
259
|
+
return calendar.create( date )
|
260
|
+
}
|
261
|
+
return date
|
262
|
+
}
|
263
|
+
|
264
|
+
// Create objects if possible.
|
265
|
+
if ( !_.isInteger( from ) ) {
|
266
|
+
from = createDate( from )
|
267
|
+
}
|
268
|
+
if ( !_.isInteger( to ) ) {
|
269
|
+
to = createDate( to )
|
270
|
+
}
|
271
|
+
|
272
|
+
// Create relative dates.
|
273
|
+
if ( _.isInteger( from ) && $.isPlainObject( to ) ) {
|
274
|
+
from = [ to.year, to.month, to.date + from ];
|
275
|
+
}
|
276
|
+
else if ( _.isInteger( to ) && $.isPlainObject( from ) ) {
|
277
|
+
to = [ from.year, from.month, from.date + to ];
|
278
|
+
}
|
279
|
+
|
280
|
+
return {
|
281
|
+
from: createDate( from ),
|
282
|
+
to: createDate( to )
|
283
|
+
}
|
284
|
+
} //DatePicker.prototype.createRange
|
285
|
+
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Check if a date unit falls within a date range object.
|
289
|
+
*/
|
290
|
+
DatePicker.prototype.withinRange = function( range, dateUnit ) {
|
291
|
+
range = this.createRange(range.from, range.to)
|
292
|
+
return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Check if two date range objects overlap.
|
298
|
+
*/
|
299
|
+
DatePicker.prototype.overlapRanges = function( one, two ) {
|
300
|
+
|
301
|
+
var calendar = this
|
302
|
+
|
303
|
+
// Convert the ranges into comparable dates.
|
304
|
+
one = calendar.createRange( one.from, one.to )
|
305
|
+
two = calendar.createRange( two.from, two.to )
|
306
|
+
|
307
|
+
return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) ||
|
308
|
+
calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to )
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Get the date today.
|
314
|
+
*/
|
315
|
+
DatePicker.prototype.now = function( type, value, options ) {
|
316
|
+
value = new Date()
|
317
|
+
if ( options && options.rel ) {
|
318
|
+
value.setDate( value.getDate() + options.rel )
|
319
|
+
}
|
320
|
+
return this.normalize( value, options )
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Navigate to next/prev month.
|
326
|
+
*/
|
327
|
+
DatePicker.prototype.navigate = function( type, value, options ) {
|
328
|
+
|
329
|
+
var targetDateObject,
|
330
|
+
targetYear,
|
331
|
+
targetMonth,
|
332
|
+
targetDate,
|
333
|
+
isTargetArray = $.isArray( value ),
|
334
|
+
isTargetObject = $.isPlainObject( value ),
|
335
|
+
viewsetObject = this.item.view/*,
|
336
|
+
safety = 100*/
|
337
|
+
|
338
|
+
|
339
|
+
if ( isTargetArray || isTargetObject ) {
|
340
|
+
|
341
|
+
if ( isTargetObject ) {
|
342
|
+
targetYear = value.year
|
343
|
+
targetMonth = value.month
|
344
|
+
targetDate = value.date
|
345
|
+
}
|
346
|
+
else {
|
347
|
+
targetYear = +value[0]
|
348
|
+
targetMonth = +value[1]
|
349
|
+
targetDate = +value[2]
|
350
|
+
}
|
351
|
+
|
352
|
+
// If we’re navigating months but the view is in a different
|
353
|
+
// month, navigate to the view’s year and month.
|
354
|
+
if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) {
|
355
|
+
targetYear = viewsetObject.year
|
356
|
+
targetMonth = viewsetObject.month
|
357
|
+
}
|
358
|
+
|
359
|
+
// Figure out the expected target year and month.
|
360
|
+
targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 )
|
361
|
+
targetYear = targetDateObject.getFullYear()
|
362
|
+
targetMonth = targetDateObject.getMonth()
|
363
|
+
|
364
|
+
// If the month we’re going to doesn’t have enough days,
|
365
|
+
// keep decreasing the date until we reach the month’s last date.
|
366
|
+
while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) {
|
367
|
+
targetDate -= 1
|
368
|
+
/*safety -= 1
|
369
|
+
if ( !safety ) {
|
370
|
+
throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
|
371
|
+
}*/
|
372
|
+
}
|
373
|
+
|
374
|
+
value = [ targetYear, targetMonth, targetDate ]
|
375
|
+
}
|
376
|
+
|
377
|
+
return value
|
378
|
+
} //DatePicker.prototype.navigate
|
379
|
+
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Normalize a date by setting the hours to midnight.
|
383
|
+
*/
|
384
|
+
DatePicker.prototype.normalize = function( value/*, options*/ ) {
|
385
|
+
value.setHours( 0, 0, 0, 0 )
|
386
|
+
return value
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Measure the range of dates.
|
392
|
+
*/
|
393
|
+
DatePicker.prototype.measure = function( type, value/*, options*/ ) {
|
394
|
+
|
395
|
+
var calendar = this
|
396
|
+
|
397
|
+
// If it’s anything false-y, remove the limits.
|
398
|
+
if ( !value ) {
|
399
|
+
value = type == 'min' ? -Infinity : Infinity
|
400
|
+
}
|
401
|
+
|
402
|
+
// If it’s a string, parse it.
|
403
|
+
else if ( typeof value == 'string' ) {
|
404
|
+
value = calendar.parse( type, value )
|
405
|
+
}
|
406
|
+
|
407
|
+
// If it's an integer, get a date relative to today.
|
408
|
+
else if ( _.isInteger( value ) ) {
|
409
|
+
value = calendar.now( type, value, { rel: value } )
|
410
|
+
}
|
411
|
+
|
412
|
+
return value
|
413
|
+
} ///DatePicker.prototype.measure
|
414
|
+
|
415
|
+
|
416
|
+
/**
|
417
|
+
* Create a viewset object based on navigation.
|
418
|
+
*/
|
419
|
+
DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
|
420
|
+
return this.create([ dateObject.year, dateObject.month, 1 ])
|
421
|
+
}
|
422
|
+
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Validate a date as enabled and shift if needed.
|
426
|
+
*/
|
427
|
+
DatePicker.prototype.validate = function( type, dateObject, options ) {
|
428
|
+
|
429
|
+
var calendar = this,
|
430
|
+
|
431
|
+
// Keep a reference to the original date.
|
432
|
+
originalDateObject = dateObject,
|
433
|
+
|
434
|
+
// Make sure we have an interval.
|
435
|
+
interval = options && options.interval ? options.interval : 1,
|
436
|
+
|
437
|
+
// Check if the calendar enabled dates are inverted.
|
438
|
+
isFlippedBase = calendar.item.enable === -1,
|
439
|
+
|
440
|
+
// Check if we have any enabled dates after/before now.
|
441
|
+
hasEnabledBeforeTarget, hasEnabledAfterTarget,
|
442
|
+
|
443
|
+
// The min & max limits.
|
444
|
+
minLimitObject = calendar.item.min,
|
445
|
+
maxLimitObject = calendar.item.max,
|
446
|
+
|
447
|
+
// Check if we’ve reached the limit during shifting.
|
448
|
+
reachedMin, reachedMax,
|
449
|
+
|
450
|
+
// Check if the calendar is inverted and at least one weekday is enabled.
|
451
|
+
hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter( function( value ) {
|
452
|
+
|
453
|
+
// If there’s a date, check where it is relative to the target.
|
454
|
+
if ( $.isArray( value ) ) {
|
455
|
+
var dateTime = calendar.create( value ).pick
|
456
|
+
if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
|
457
|
+
else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
|
458
|
+
}
|
459
|
+
|
460
|
+
// Return only integers for enabled weekdays.
|
461
|
+
return _.isInteger( value )
|
462
|
+
}).length/*,
|
463
|
+
|
464
|
+
safety = 100*/
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
// Cases to validate for:
|
469
|
+
// [1] Not inverted and date disabled.
|
470
|
+
// [2] Inverted and some dates enabled.
|
471
|
+
// [3] Not inverted and out of range.
|
472
|
+
//
|
473
|
+
// Cases to **not** validate for:
|
474
|
+
// • Navigating months.
|
475
|
+
// • Not inverted and date enabled.
|
476
|
+
// • Inverted and all dates disabled.
|
477
|
+
// • ..and anything else.
|
478
|
+
if ( !options || !options.nav ) if (
|
479
|
+
/* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
|
480
|
+
/* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
|
481
|
+
/* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
|
482
|
+
) {
|
483
|
+
|
484
|
+
|
485
|
+
// When inverted, flip the direction if there aren’t any enabled weekdays
|
486
|
+
// and there are no enabled dates in the direction of the interval.
|
487
|
+
if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
|
488
|
+
interval *= -1
|
489
|
+
}
|
490
|
+
|
491
|
+
|
492
|
+
// Keep looping until we reach an enabled date.
|
493
|
+
while ( /*safety &&*/ calendar.disabled( dateObject ) ) {
|
494
|
+
|
495
|
+
/*safety -= 1
|
496
|
+
if ( !safety ) {
|
497
|
+
throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
|
498
|
+
}*/
|
499
|
+
|
500
|
+
|
501
|
+
// If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
|
502
|
+
if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
|
503
|
+
dateObject = originalDateObject
|
504
|
+
interval = interval > 0 ? 1 : -1
|
505
|
+
}
|
506
|
+
|
507
|
+
|
508
|
+
// If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
|
509
|
+
if ( dateObject.pick <= minLimitObject.pick ) {
|
510
|
+
reachedMin = true
|
511
|
+
interval = 1
|
512
|
+
dateObject = calendar.create([
|
513
|
+
minLimitObject.year,
|
514
|
+
minLimitObject.month,
|
515
|
+
minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)
|
516
|
+
])
|
517
|
+
}
|
518
|
+
else if ( dateObject.pick >= maxLimitObject.pick ) {
|
519
|
+
reachedMax = true
|
520
|
+
interval = -1
|
521
|
+
dateObject = calendar.create([
|
522
|
+
maxLimitObject.year,
|
523
|
+
maxLimitObject.month,
|
524
|
+
maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)
|
525
|
+
])
|
526
|
+
}
|
527
|
+
|
528
|
+
|
529
|
+
// If we’ve reached both limits, just break out of the loop.
|
530
|
+
if ( reachedMin && reachedMax ) {
|
531
|
+
break
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
// Finally, create the shifted date using the interval and keep looping.
|
536
|
+
dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
|
537
|
+
}
|
538
|
+
|
539
|
+
} //endif
|
540
|
+
|
541
|
+
|
542
|
+
// Return the date object settled on.
|
543
|
+
return dateObject
|
544
|
+
} //DatePicker.prototype.validate
|
545
|
+
|
546
|
+
|
547
|
+
/**
|
548
|
+
* Check if a date is disabled.
|
549
|
+
*/
|
550
|
+
DatePicker.prototype.disabled = function( dateToVerify ) {
|
551
|
+
|
552
|
+
var
|
553
|
+
calendar = this,
|
554
|
+
|
555
|
+
// Filter through the disabled dates to check if this is one.
|
556
|
+
isDisabledMatch = calendar.item.disable.filter( function( dateToDisable ) {
|
557
|
+
|
558
|
+
// If the date is a number, match the weekday with 0index and `firstDay` check.
|
559
|
+
if ( _.isInteger( dateToDisable ) ) {
|
560
|
+
return dateToVerify.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
|
561
|
+
}
|
562
|
+
|
563
|
+
// If it’s an array or a native JS date, create and match the exact date.
|
564
|
+
if ( $.isArray( dateToDisable ) || _.isDate( dateToDisable ) ) {
|
565
|
+
return dateToVerify.pick === calendar.create( dateToDisable ).pick
|
566
|
+
}
|
567
|
+
|
568
|
+
// If it’s an object, match a date within the “from” and “to” range.
|
569
|
+
if ( $.isPlainObject( dateToDisable ) ) {
|
570
|
+
return calendar.withinRange( dateToDisable, dateToVerify )
|
571
|
+
}
|
572
|
+
})
|
573
|
+
|
574
|
+
// If this date matches a disabled date, confirm it’s not inverted.
|
575
|
+
isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) {
|
576
|
+
return $.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' ||
|
577
|
+
$.isPlainObject( dateToDisable ) && dateToDisable.inverted
|
578
|
+
}).length
|
579
|
+
|
580
|
+
// Check the calendar “enabled” flag and respectively flip the
|
581
|
+
// disabled state. Then also check if it’s beyond the min/max limits.
|
582
|
+
return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch ||
|
583
|
+
dateToVerify.pick < calendar.item.min.pick ||
|
584
|
+
dateToVerify.pick > calendar.item.max.pick
|
585
|
+
|
586
|
+
} //DatePicker.prototype.disabled
|
587
|
+
|
588
|
+
|
589
|
+
/**
|
590
|
+
* Parse a string into a usable type.
|
591
|
+
*/
|
592
|
+
DatePicker.prototype.parse = function( type, value, options ) {
|
593
|
+
|
594
|
+
var calendar = this,
|
595
|
+
parsingObject = {}
|
596
|
+
|
597
|
+
// If it’s already parsed, we’re good.
|
598
|
+
if ( !value || typeof value != 'string' ) {
|
599
|
+
return value
|
600
|
+
}
|
601
|
+
|
602
|
+
// We need a `.format` to parse the value with.
|
603
|
+
if ( !( options && options.format ) ) {
|
604
|
+
options = options || {}
|
605
|
+
options.format = calendar.settings.format
|
606
|
+
}
|
607
|
+
|
608
|
+
// Convert the format into an array and then map through it.
|
609
|
+
calendar.formats.toArray( options.format ).map( function( label ) {
|
610
|
+
|
611
|
+
var
|
612
|
+
// Grab the formatting label.
|
613
|
+
formattingLabel = calendar.formats[ label ],
|
614
|
+
|
615
|
+
// The format length is from the formatting label function or the
|
616
|
+
// label length without the escaping exclamation (!) mark.
|
617
|
+
formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
|
618
|
+
|
619
|
+
// If there's a format label, split the value up to the format length.
|
620
|
+
// Then add it to the parsing object with appropriate label.
|
621
|
+
if ( formattingLabel ) {
|
622
|
+
parsingObject[ label ] = value.substr( 0, formatLength )
|
623
|
+
}
|
624
|
+
|
625
|
+
// Update the value as the substring from format length to end.
|
626
|
+
value = value.substr( formatLength )
|
627
|
+
})
|
628
|
+
|
629
|
+
// Compensate for month 0index.
|
630
|
+
return [
|
631
|
+
parsingObject.yyyy || parsingObject.yy,
|
632
|
+
+( parsingObject.mm || parsingObject.m ) - 1,
|
633
|
+
parsingObject.dd || parsingObject.d
|
634
|
+
]
|
635
|
+
} //DatePicker.prototype.parse
|
636
|
+
|
637
|
+
|
638
|
+
/**
|
639
|
+
* Various formats to display the object in.
|
640
|
+
*/
|
641
|
+
DatePicker.prototype.formats = (function() {
|
642
|
+
|
643
|
+
// Return the length of the first word in a collection.
|
644
|
+
function getWordLengthFromCollection( string, collection, dateObject ) {
|
645
|
+
|
646
|
+
// Grab the first word from the string.
|
647
|
+
var word = string.match( /\w+/ )[ 0 ]
|
648
|
+
|
649
|
+
// If there's no month index, add it to the date object
|
650
|
+
if ( !dateObject.mm && !dateObject.m ) {
|
651
|
+
dateObject.m = collection.indexOf( word ) + 1
|
652
|
+
}
|
653
|
+
|
654
|
+
// Return the length of the word.
|
655
|
+
return word.length
|
656
|
+
}
|
657
|
+
|
658
|
+
// Get the length of the first word in a string.
|
659
|
+
function getFirstWordLength( string ) {
|
660
|
+
return string.match( /\w+/ )[ 0 ].length
|
661
|
+
}
|
662
|
+
|
663
|
+
return {
|
664
|
+
|
665
|
+
d: function( string, dateObject ) {
|
666
|
+
|
667
|
+
// If there's string, then get the digits length.
|
668
|
+
// Otherwise return the selected date.
|
669
|
+
return string ? _.digits( string ) : dateObject.date
|
670
|
+
},
|
671
|
+
dd: function( string, dateObject ) {
|
672
|
+
|
673
|
+
// If there's a string, then the length is always 2.
|
674
|
+
// Otherwise return the selected date with a leading zero.
|
675
|
+
return string ? 2 : _.lead( dateObject.date )
|
676
|
+
},
|
677
|
+
ddd: function( string, dateObject ) {
|
678
|
+
|
679
|
+
// If there's a string, then get the length of the first word.
|
680
|
+
// Otherwise return the short selected weekday.
|
681
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
|
682
|
+
},
|
683
|
+
dddd: function( string, dateObject ) {
|
684
|
+
|
685
|
+
// If there's a string, then get the length of the first word.
|
686
|
+
// Otherwise return the full selected weekday.
|
687
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
|
688
|
+
},
|
689
|
+
m: function( string, dateObject ) {
|
690
|
+
|
691
|
+
// If there's a string, then get the length of the digits
|
692
|
+
// Otherwise return the selected month with 0index compensation.
|
693
|
+
return string ? _.digits( string ) : dateObject.month + 1
|
694
|
+
},
|
695
|
+
mm: function( string, dateObject ) {
|
696
|
+
|
697
|
+
// If there's a string, then the length is always 2.
|
698
|
+
// Otherwise return the selected month with 0index and leading zero.
|
699
|
+
return string ? 2 : _.lead( dateObject.month + 1 )
|
700
|
+
},
|
701
|
+
mmm: function( string, dateObject ) {
|
702
|
+
|
703
|
+
var collection = this.settings.monthsShort
|
704
|
+
|
705
|
+
// If there's a string, get length of the relevant month from the short
|
706
|
+
// months collection. Otherwise return the selected month from that collection.
|
707
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
708
|
+
},
|
709
|
+
mmmm: function( string, dateObject ) {
|
710
|
+
|
711
|
+
var collection = this.settings.monthsFull
|
712
|
+
|
713
|
+
// If there's a string, get length of the relevant month from the full
|
714
|
+
// months collection. Otherwise return the selected month from that collection.
|
715
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
716
|
+
},
|
717
|
+
yy: function( string, dateObject ) {
|
718
|
+
|
719
|
+
// If there's a string, then the length is always 2.
|
720
|
+
// Otherwise return the selected year by slicing out the first 2 digits.
|
721
|
+
return string ? 2 : ( '' + dateObject.year ).slice( 2 )
|
722
|
+
},
|
723
|
+
yyyy: function( string, dateObject ) {
|
724
|
+
|
725
|
+
// If there's a string, then the length is always 4.
|
726
|
+
// Otherwise return the selected year.
|
727
|
+
return string ? 4 : dateObject.year
|
728
|
+
},
|
729
|
+
|
730
|
+
// Create an array by splitting the formatting string passed.
|
731
|
+
toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
|
732
|
+
|
733
|
+
// Format an object into a string using the formatting options.
|
734
|
+
toString: function ( formatString, itemObject ) {
|
735
|
+
var calendar = this
|
736
|
+
return calendar.formats.toArray( formatString ).map( function( label ) {
|
737
|
+
return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
|
738
|
+
}).join( '' )
|
739
|
+
}
|
740
|
+
}
|
741
|
+
})() //DatePicker.prototype.formats
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
/**
|
747
|
+
* Check if two date units are the exact.
|
748
|
+
*/
|
749
|
+
DatePicker.prototype.isDateExact = function( one, two ) {
|
750
|
+
|
751
|
+
var calendar = this
|
752
|
+
|
753
|
+
// When we’re working with weekdays, do a direct comparison.
|
754
|
+
if (
|
755
|
+
( _.isInteger( one ) && _.isInteger( two ) ) ||
|
756
|
+
( typeof one == 'boolean' && typeof two == 'boolean' )
|
757
|
+
) {
|
758
|
+
return one === two
|
759
|
+
}
|
760
|
+
|
761
|
+
// When we’re working with date representations, compare the “pick” value.
|
762
|
+
if (
|
763
|
+
( _.isDate( one ) || $.isArray( one ) ) &&
|
764
|
+
( _.isDate( two ) || $.isArray( two ) )
|
765
|
+
) {
|
766
|
+
return calendar.create( one ).pick === calendar.create( two ).pick
|
767
|
+
}
|
768
|
+
|
769
|
+
// When we’re working with range objects, compare the “from” and “to”.
|
770
|
+
if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
|
771
|
+
return calendar.isDateExact( one.from, two.from ) && calendar.isDateExact( one.to, two.to )
|
772
|
+
}
|
773
|
+
|
774
|
+
return false
|
775
|
+
}
|
776
|
+
|
777
|
+
|
778
|
+
/**
|
779
|
+
* Check if two date units overlap.
|
780
|
+
*/
|
781
|
+
DatePicker.prototype.isDateOverlap = function( one, two ) {
|
782
|
+
|
783
|
+
var calendar = this,
|
784
|
+
firstDay = calendar.settings.firstDay ? 1 : 0
|
785
|
+
|
786
|
+
// When we’re working with a weekday index, compare the days.
|
787
|
+
if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) {
|
788
|
+
one = one % 7 + firstDay
|
789
|
+
return one === calendar.create( two ).day + 1
|
790
|
+
}
|
791
|
+
if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) {
|
792
|
+
two = two % 7 + firstDay
|
793
|
+
return two === calendar.create( one ).day + 1
|
794
|
+
}
|
795
|
+
|
796
|
+
// When we’re working with range objects, check if the ranges overlap.
|
797
|
+
if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
|
798
|
+
return calendar.overlapRanges( one, two )
|
799
|
+
}
|
800
|
+
|
801
|
+
return false
|
802
|
+
}
|
803
|
+
|
804
|
+
|
805
|
+
/**
|
806
|
+
* Flip the “enabled” state.
|
807
|
+
*/
|
808
|
+
DatePicker.prototype.flipEnable = function(val) {
|
809
|
+
var itemObject = this.item
|
810
|
+
itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1)
|
811
|
+
}
|
812
|
+
|
813
|
+
|
814
|
+
/**
|
815
|
+
* Mark a collection of dates as “disabled”.
|
816
|
+
*/
|
817
|
+
DatePicker.prototype.deactivate = function( type, datesToDisable ) {
|
818
|
+
|
819
|
+
var calendar = this,
|
820
|
+
disabledItems = calendar.item.disable.slice(0)
|
821
|
+
|
822
|
+
|
823
|
+
// If we’re flipping, that’s all we need to do.
|
824
|
+
if ( datesToDisable == 'flip' ) {
|
825
|
+
calendar.flipEnable()
|
826
|
+
}
|
827
|
+
|
828
|
+
else if ( datesToDisable === false ) {
|
829
|
+
calendar.flipEnable(1)
|
830
|
+
disabledItems = []
|
831
|
+
}
|
832
|
+
|
833
|
+
else if ( datesToDisable === true ) {
|
834
|
+
calendar.flipEnable(-1)
|
835
|
+
disabledItems = []
|
836
|
+
}
|
837
|
+
|
838
|
+
// Otherwise go through the dates to disable.
|
839
|
+
else {
|
840
|
+
|
841
|
+
datesToDisable.map(function( unitToDisable ) {
|
842
|
+
|
843
|
+
var matchFound
|
844
|
+
|
845
|
+
// When we have disabled items, check for matches.
|
846
|
+
// If something is matched, immediately break out.
|
847
|
+
for ( var index = 0; index < disabledItems.length; index += 1 ) {
|
848
|
+
if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) {
|
849
|
+
matchFound = true
|
850
|
+
break
|
851
|
+
}
|
852
|
+
}
|
853
|
+
|
854
|
+
// If nothing was found, add the validated unit to the collection.
|
855
|
+
if ( !matchFound ) {
|
856
|
+
if (
|
857
|
+
_.isInteger( unitToDisable ) ||
|
858
|
+
_.isDate( unitToDisable ) ||
|
859
|
+
$.isArray( unitToDisable ) ||
|
860
|
+
( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
|
861
|
+
) {
|
862
|
+
disabledItems.push( unitToDisable )
|
863
|
+
}
|
864
|
+
}
|
865
|
+
})
|
866
|
+
}
|
867
|
+
|
868
|
+
// Return the updated collection.
|
869
|
+
return disabledItems
|
870
|
+
} //DatePicker.prototype.deactivate
|
871
|
+
|
872
|
+
|
873
|
+
/**
|
874
|
+
* Mark a collection of dates as “enabled”.
|
875
|
+
*/
|
876
|
+
DatePicker.prototype.activate = function( type, datesToEnable ) {
|
877
|
+
|
878
|
+
var calendar = this,
|
879
|
+
disabledItems = calendar.item.disable,
|
880
|
+
disabledItemsCount = disabledItems.length
|
881
|
+
|
882
|
+
// If we’re flipping, that’s all we need to do.
|
883
|
+
if ( datesToEnable == 'flip' ) {
|
884
|
+
calendar.flipEnable()
|
885
|
+
}
|
886
|
+
|
887
|
+
else if ( datesToEnable === true ) {
|
888
|
+
calendar.flipEnable(1)
|
889
|
+
disabledItems = []
|
890
|
+
}
|
891
|
+
|
892
|
+
else if ( datesToEnable === false ) {
|
893
|
+
calendar.flipEnable(-1)
|
894
|
+
disabledItems = []
|
895
|
+
}
|
896
|
+
|
897
|
+
// Otherwise go through the disabled dates.
|
898
|
+
else {
|
899
|
+
|
900
|
+
datesToEnable.map(function( unitToEnable ) {
|
901
|
+
|
902
|
+
var matchFound,
|
903
|
+
disabledUnit,
|
904
|
+
index,
|
905
|
+
isExactRange
|
906
|
+
|
907
|
+
// Go through the disabled items and try to find a match.
|
908
|
+
for ( index = 0; index < disabledItemsCount; index += 1 ) {
|
909
|
+
|
910
|
+
disabledUnit = disabledItems[index]
|
911
|
+
|
912
|
+
// When an exact match is found, remove it from the collection.
|
913
|
+
if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) {
|
914
|
+
matchFound = disabledItems[index] = null
|
915
|
+
isExactRange = true
|
916
|
+
break
|
917
|
+
}
|
918
|
+
|
919
|
+
// When an overlapped match is found, add the “inverted” state to it.
|
920
|
+
else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) {
|
921
|
+
if ( $.isPlainObject( unitToEnable ) ) {
|
922
|
+
unitToEnable.inverted = true
|
923
|
+
matchFound = unitToEnable
|
924
|
+
}
|
925
|
+
else if ( $.isArray( unitToEnable ) ) {
|
926
|
+
matchFound = unitToEnable
|
927
|
+
if ( !matchFound[3] ) matchFound.push( 'inverted' )
|
928
|
+
}
|
929
|
+
else if ( _.isDate( unitToEnable ) ) {
|
930
|
+
matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
|
931
|
+
}
|
932
|
+
break
|
933
|
+
}
|
934
|
+
}
|
935
|
+
|
936
|
+
// If a match was found, remove a previous duplicate entry.
|
937
|
+
if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
|
938
|
+
if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) {
|
939
|
+
disabledItems[index] = null
|
940
|
+
break
|
941
|
+
}
|
942
|
+
}
|
943
|
+
|
944
|
+
// In the event that we’re dealing with an exact range of dates,
|
945
|
+
// make sure there are no “inverted” dates because of it.
|
946
|
+
if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
|
947
|
+
if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) {
|
948
|
+
disabledItems[index] = null
|
949
|
+
break
|
950
|
+
}
|
951
|
+
}
|
952
|
+
|
953
|
+
// If something is still matched, add it into the collection.
|
954
|
+
if ( matchFound ) {
|
955
|
+
disabledItems.push( matchFound )
|
956
|
+
}
|
957
|
+
})
|
958
|
+
}
|
959
|
+
|
960
|
+
// Return the updated collection.
|
961
|
+
return disabledItems.filter(function( val ) { return val != null })
|
962
|
+
} //DatePicker.prototype.activate
|
963
|
+
|
964
|
+
|
965
|
+
/**
|
966
|
+
* Create a string for the nodes in the picker.
|
967
|
+
*/
|
968
|
+
DatePicker.prototype.nodes = function( isOpen ) {
|
969
|
+
|
970
|
+
var
|
971
|
+
calendar = this,
|
972
|
+
settings = calendar.settings,
|
973
|
+
calendarItem = calendar.item,
|
974
|
+
nowObject = calendarItem.now,
|
975
|
+
selectedObject = calendarItem.select,
|
976
|
+
highlightedObject = calendarItem.highlight,
|
977
|
+
viewsetObject = calendarItem.view,
|
978
|
+
disabledCollection = calendarItem.disable,
|
979
|
+
minLimitObject = calendarItem.min,
|
980
|
+
maxLimitObject = calendarItem.max,
|
981
|
+
|
982
|
+
|
983
|
+
// Create the calendar table head using a copy of weekday labels collection.
|
984
|
+
// * We do a copy so we don't mutate the original array.
|
985
|
+
tableHead = (function( collection, fullCollection ) {
|
986
|
+
|
987
|
+
// If the first day should be Monday, move Sunday to the end.
|
988
|
+
if ( settings.firstDay ) {
|
989
|
+
collection.push( collection.shift() )
|
990
|
+
fullCollection.push( fullCollection.shift() )
|
991
|
+
}
|
992
|
+
|
993
|
+
// Create and return the table head group.
|
994
|
+
return _.node(
|
995
|
+
'thead',
|
996
|
+
_.node(
|
997
|
+
'tr',
|
998
|
+
_.group({
|
999
|
+
min: 0,
|
1000
|
+
max: DAYS_IN_WEEK - 1,
|
1001
|
+
i: 1,
|
1002
|
+
node: 'th',
|
1003
|
+
item: function( counter ) {
|
1004
|
+
return [
|
1005
|
+
collection[ counter ],
|
1006
|
+
settings.klass.weekdays,
|
1007
|
+
'scope=col title="' + fullCollection[ counter ] + '"'
|
1008
|
+
]
|
1009
|
+
}
|
1010
|
+
})
|
1011
|
+
)
|
1012
|
+
) //endreturn
|
1013
|
+
|
1014
|
+
// Materialize modified
|
1015
|
+
})( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter ).slice( 0 ), settings.weekdaysFull.slice( 0 ) ), //tableHead
|
1016
|
+
|
1017
|
+
|
1018
|
+
// Create the nav for next/prev month.
|
1019
|
+
createMonthNav = function( next ) {
|
1020
|
+
|
1021
|
+
// Otherwise, return the created month tag.
|
1022
|
+
return _.node(
|
1023
|
+
'div',
|
1024
|
+
' ',
|
1025
|
+
settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
|
1026
|
+
|
1027
|
+
// If the focused month is outside the range, disabled the button.
|
1028
|
+
( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
|
1029
|
+
( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
|
1030
|
+
' ' + settings.klass.navDisabled : ''
|
1031
|
+
),
|
1032
|
+
'data-nav=' + ( next || -1 ) + ' ' +
|
1033
|
+
_.ariaAttr({
|
1034
|
+
role: 'button',
|
1035
|
+
controls: calendar.$node[0].id + '_table'
|
1036
|
+
}) + ' ' +
|
1037
|
+
'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev ) + '"'
|
1038
|
+
) //endreturn
|
1039
|
+
}, //createMonthNav
|
1040
|
+
|
1041
|
+
|
1042
|
+
// Create the month label.
|
1043
|
+
//Materialize modified
|
1044
|
+
createMonthLabel = function(override) {
|
1045
|
+
|
1046
|
+
var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull
|
1047
|
+
|
1048
|
+
// Materialize modified
|
1049
|
+
if (override == "short_months") {
|
1050
|
+
monthsCollection = settings.monthsShort;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
// If there are months to select, add a dropdown menu.
|
1054
|
+
if ( settings.selectMonths && override == undefined) {
|
1055
|
+
|
1056
|
+
return _.node( 'select',
|
1057
|
+
_.group({
|
1058
|
+
min: 0,
|
1059
|
+
max: 11,
|
1060
|
+
i: 1,
|
1061
|
+
node: 'option',
|
1062
|
+
item: function( loopedMonth ) {
|
1063
|
+
|
1064
|
+
return [
|
1065
|
+
|
1066
|
+
// The looped month and no classes.
|
1067
|
+
monthsCollection[ loopedMonth ], 0,
|
1068
|
+
|
1069
|
+
// Set the value and selected index.
|
1070
|
+
'value=' + loopedMonth +
|
1071
|
+
( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
|
1072
|
+
(
|
1073
|
+
(
|
1074
|
+
( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
|
1075
|
+
( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
|
1076
|
+
) ?
|
1077
|
+
' disabled' : ''
|
1078
|
+
)
|
1079
|
+
]
|
1080
|
+
}
|
1081
|
+
}),
|
1082
|
+
settings.klass.selectMonth + ' browser-default',
|
1083
|
+
( isOpen ? '' : 'disabled' ) + ' ' +
|
1084
|
+
_.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
|
1085
|
+
'title="' + settings.labelMonthSelect + '"'
|
1086
|
+
)
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
// Materialize modified
|
1090
|
+
if (override == "short_months")
|
1091
|
+
if (selectedObject != null)
|
1092
|
+
return _.node( 'div', monthsCollection[ selectedObject.month ] );
|
1093
|
+
else return _.node( 'div', monthsCollection[ viewsetObject.month ] );
|
1094
|
+
|
1095
|
+
// If there's a need for a month selector
|
1096
|
+
return _.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
|
1097
|
+
}, //createMonthLabel
|
1098
|
+
|
1099
|
+
|
1100
|
+
// Create the year label.
|
1101
|
+
// Materialize modified
|
1102
|
+
createYearLabel = function(override) {
|
1103
|
+
|
1104
|
+
var focusedYear = viewsetObject.year,
|
1105
|
+
|
1106
|
+
// If years selector is set to a literal "true", set it to 5. Otherwise
|
1107
|
+
// divide in half to get half before and half after focused year.
|
1108
|
+
numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
|
1109
|
+
|
1110
|
+
// If there are years to select, add a dropdown menu.
|
1111
|
+
if ( numberYears ) {
|
1112
|
+
|
1113
|
+
var
|
1114
|
+
minYear = minLimitObject.year,
|
1115
|
+
maxYear = maxLimitObject.year,
|
1116
|
+
lowestYear = focusedYear - numberYears,
|
1117
|
+
highestYear = focusedYear + numberYears
|
1118
|
+
|
1119
|
+
// If the min year is greater than the lowest year, increase the highest year
|
1120
|
+
// by the difference and set the lowest year to the min year.
|
1121
|
+
if ( minYear > lowestYear ) {
|
1122
|
+
highestYear += minYear - lowestYear
|
1123
|
+
lowestYear = minYear
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
// If the max year is less than the highest year, decrease the lowest year
|
1127
|
+
// by the lower of the two: available and needed years. Then set the
|
1128
|
+
// highest year to the max year.
|
1129
|
+
if ( maxYear < highestYear ) {
|
1130
|
+
|
1131
|
+
var availableYears = lowestYear - minYear,
|
1132
|
+
neededYears = highestYear - maxYear
|
1133
|
+
|
1134
|
+
lowestYear -= availableYears > neededYears ? neededYears : availableYears
|
1135
|
+
highestYear = maxYear
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
if ( settings.selectYears && override == undefined ) {
|
1139
|
+
return _.node( 'select',
|
1140
|
+
_.group({
|
1141
|
+
min: lowestYear,
|
1142
|
+
max: highestYear,
|
1143
|
+
i: 1,
|
1144
|
+
node: 'option',
|
1145
|
+
item: function( loopedYear ) {
|
1146
|
+
return [
|
1147
|
+
|
1148
|
+
// The looped year and no classes.
|
1149
|
+
loopedYear, 0,
|
1150
|
+
|
1151
|
+
// Set the value and selected index.
|
1152
|
+
'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
|
1153
|
+
]
|
1154
|
+
}
|
1155
|
+
}),
|
1156
|
+
settings.klass.selectYear + ' browser-default',
|
1157
|
+
( isOpen ? '' : 'disabled' ) + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
|
1158
|
+
'title="' + settings.labelYearSelect + '"'
|
1159
|
+
)
|
1160
|
+
}
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
// Materialize modified
|
1164
|
+
if (override == "raw")
|
1165
|
+
return _.node( 'div', focusedYear )
|
1166
|
+
|
1167
|
+
// Otherwise just return the year focused
|
1168
|
+
return _.node( 'div', focusedYear, settings.klass.year )
|
1169
|
+
} //createYearLabel
|
1170
|
+
|
1171
|
+
|
1172
|
+
// Materialize modified
|
1173
|
+
createDayLabel = function() {
|
1174
|
+
if (selectedObject != null)
|
1175
|
+
return _.node( 'div', selectedObject.date)
|
1176
|
+
else return _.node( 'div', nowObject.date)
|
1177
|
+
}
|
1178
|
+
createWeekdayLabel = function() {
|
1179
|
+
var display_day;
|
1180
|
+
|
1181
|
+
if (selectedObject != null)
|
1182
|
+
display_day = selectedObject.day;
|
1183
|
+
else
|
1184
|
+
display_day = nowObject.day;
|
1185
|
+
var weekday = settings.weekdaysFull[ display_day ]
|
1186
|
+
return weekday
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
|
1190
|
+
// Create and return the entire calendar.
|
1191
|
+
return _.node(
|
1192
|
+
// Date presentation View
|
1193
|
+
'div',
|
1194
|
+
_.node(
|
1195
|
+
'div',
|
1196
|
+
createWeekdayLabel(),
|
1197
|
+
"picker__weekday-display"
|
1198
|
+
)+
|
1199
|
+
_.node(
|
1200
|
+
// Div for short Month
|
1201
|
+
'div',
|
1202
|
+
createMonthLabel("short_months"),
|
1203
|
+
settings.klass.month_display
|
1204
|
+
)+
|
1205
|
+
_.node(
|
1206
|
+
// Div for Day
|
1207
|
+
'div',
|
1208
|
+
createDayLabel() ,
|
1209
|
+
settings.klass.day_display
|
1210
|
+
)+
|
1211
|
+
_.node(
|
1212
|
+
// Div for Year
|
1213
|
+
'div',
|
1214
|
+
createYearLabel("raw") ,
|
1215
|
+
settings.klass.year_display
|
1216
|
+
),
|
1217
|
+
settings.klass.date_display
|
1218
|
+
)+
|
1219
|
+
// Calendar container
|
1220
|
+
_.node('div',
|
1221
|
+
_.node('div',
|
1222
|
+
( settings.selectYears ? createMonthLabel() + createYearLabel() : createMonthLabel() + createYearLabel() ) +
|
1223
|
+
createMonthNav() + createMonthNav( 1 ),
|
1224
|
+
settings.klass.header
|
1225
|
+
) + _.node(
|
1226
|
+
'table',
|
1227
|
+
tableHead +
|
1228
|
+
_.node(
|
1229
|
+
'tbody',
|
1230
|
+
_.group({
|
1231
|
+
min: 0,
|
1232
|
+
max: WEEKS_IN_CALENDAR - 1,
|
1233
|
+
i: 1,
|
1234
|
+
node: 'tr',
|
1235
|
+
item: function( rowCounter ) {
|
1236
|
+
|
1237
|
+
// If Monday is the first day and the month starts on Sunday, shift the date back a week.
|
1238
|
+
var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
|
1239
|
+
|
1240
|
+
return [
|
1241
|
+
_.group({
|
1242
|
+
min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
|
1243
|
+
max: function() {
|
1244
|
+
return this.min + DAYS_IN_WEEK - 1
|
1245
|
+
},
|
1246
|
+
i: 1,
|
1247
|
+
node: 'td',
|
1248
|
+
item: function( targetDate ) {
|
1249
|
+
|
1250
|
+
// Convert the time date from a relative date to a target date.
|
1251
|
+
targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
|
1252
|
+
|
1253
|
+
var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
|
1254
|
+
isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
|
1255
|
+
isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
|
1256
|
+
formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] )
|
1257
|
+
|
1258
|
+
return [
|
1259
|
+
_.node(
|
1260
|
+
'div',
|
1261
|
+
targetDate.date,
|
1262
|
+
(function( klasses ) {
|
1263
|
+
|
1264
|
+
// Add the `infocus` or `outfocus` classes based on month in view.
|
1265
|
+
klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
|
1266
|
+
|
1267
|
+
// Add the `today` class if needed.
|
1268
|
+
if ( nowObject.pick == targetDate.pick ) {
|
1269
|
+
klasses.push( settings.klass.now )
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
// Add the `selected` class if something's selected and the time matches.
|
1273
|
+
if ( isSelected ) {
|
1274
|
+
klasses.push( settings.klass.selected )
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
// Add the `highlighted` class if something's highlighted and the time matches.
|
1278
|
+
if ( isHighlighted ) {
|
1279
|
+
klasses.push( settings.klass.highlighted )
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
// Add the `disabled` class if something's disabled and the object matches.
|
1283
|
+
if ( isDisabled ) {
|
1284
|
+
klasses.push( settings.klass.disabled )
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
return klasses.join( ' ' )
|
1288
|
+
})([ settings.klass.day ]),
|
1289
|
+
'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
|
1290
|
+
role: 'gridcell',
|
1291
|
+
label: formattedDate,
|
1292
|
+
selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
|
1293
|
+
activedescendant: isHighlighted ? true : null,
|
1294
|
+
disabled: isDisabled ? true : null
|
1295
|
+
})
|
1296
|
+
),
|
1297
|
+
'',
|
1298
|
+
_.ariaAttr({ role: 'presentation' })
|
1299
|
+
] //endreturn
|
1300
|
+
}
|
1301
|
+
})
|
1302
|
+
] //endreturn
|
1303
|
+
}
|
1304
|
+
})
|
1305
|
+
),
|
1306
|
+
settings.klass.table,
|
1307
|
+
'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
|
1308
|
+
role: 'grid',
|
1309
|
+
controls: calendar.$node[0].id,
|
1310
|
+
readonly: true
|
1311
|
+
})
|
1312
|
+
)
|
1313
|
+
, settings.klass.calendar_container) // end calendar
|
1314
|
+
|
1315
|
+
+
|
1316
|
+
|
1317
|
+
// * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
|
1318
|
+
_.node(
|
1319
|
+
'div',
|
1320
|
+
_.node( 'button', settings.today, "btn-flat picker__today",
|
1321
|
+
'type=button data-pick=' + nowObject.pick +
|
1322
|
+
( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
|
1323
|
+
_.ariaAttr({ controls: calendar.$node[0].id }) ) +
|
1324
|
+
_.node( 'button', settings.clear, "btn-flat picker__clear",
|
1325
|
+
'type=button data-clear=1' +
|
1326
|
+
( isOpen ? '' : ' disabled' ) + ' ' +
|
1327
|
+
_.ariaAttr({ controls: calendar.$node[0].id }) ) +
|
1328
|
+
_.node('button', settings.close, "btn-flat picker__close",
|
1329
|
+
'type=button data-close=true ' +
|
1330
|
+
( isOpen ? '' : ' disabled' ) + ' ' +
|
1331
|
+
_.ariaAttr({ controls: calendar.$node[0].id }) ),
|
1332
|
+
settings.klass.footer
|
1333
|
+
) //endreturn
|
1334
|
+
} //DatePicker.prototype.nodes
|
1335
|
+
|
1336
|
+
|
1337
|
+
|
1338
|
+
|
1339
|
+
/**
|
1340
|
+
* The date picker defaults.
|
1341
|
+
*/
|
1342
|
+
DatePicker.defaults = (function( prefix ) {
|
1343
|
+
|
1344
|
+
return {
|
1345
|
+
|
1346
|
+
// The title label to use for the month nav buttons
|
1347
|
+
labelMonthNext: 'Next month',
|
1348
|
+
labelMonthPrev: 'Previous month',
|
1349
|
+
|
1350
|
+
// The title label to use for the dropdown selectors
|
1351
|
+
labelMonthSelect: 'Select a month',
|
1352
|
+
labelYearSelect: 'Select a year',
|
1353
|
+
|
1354
|
+
// Months and weekdays
|
1355
|
+
monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
|
1356
|
+
monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
|
1357
|
+
weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
|
1358
|
+
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
|
1359
|
+
|
1360
|
+
// Materialize modified
|
1361
|
+
weekdaysLetter: [ 'S', 'M', 'T', 'W', 'T', 'F', 'S' ],
|
1362
|
+
|
1363
|
+
// Today and clear
|
1364
|
+
today: 'Today',
|
1365
|
+
clear: 'Clear',
|
1366
|
+
close: 'Close',
|
1367
|
+
|
1368
|
+
// The format to show on the `input` element
|
1369
|
+
format: 'd mmmm, yyyy',
|
1370
|
+
|
1371
|
+
// Classes
|
1372
|
+
klass: {
|
1373
|
+
|
1374
|
+
table: prefix + 'table',
|
1375
|
+
|
1376
|
+
header: prefix + 'header',
|
1377
|
+
|
1378
|
+
|
1379
|
+
// Materialize Added klasses
|
1380
|
+
date_display: prefix + 'date-display',
|
1381
|
+
day_display: prefix + 'day-display',
|
1382
|
+
month_display: prefix + 'month-display',
|
1383
|
+
year_display: prefix + 'year-display',
|
1384
|
+
calendar_container: prefix + 'calendar-container',
|
1385
|
+
// end
|
1386
|
+
|
1387
|
+
|
1388
|
+
|
1389
|
+
navPrev: prefix + 'nav--prev',
|
1390
|
+
navNext: prefix + 'nav--next',
|
1391
|
+
navDisabled: prefix + 'nav--disabled',
|
1392
|
+
|
1393
|
+
month: prefix + 'month',
|
1394
|
+
year: prefix + 'year',
|
1395
|
+
|
1396
|
+
selectMonth: prefix + 'select--month',
|
1397
|
+
selectYear: prefix + 'select--year',
|
1398
|
+
|
1399
|
+
weekdays: prefix + 'weekday',
|
1400
|
+
|
1401
|
+
day: prefix + 'day',
|
1402
|
+
disabled: prefix + 'day--disabled',
|
1403
|
+
selected: prefix + 'day--selected',
|
1404
|
+
highlighted: prefix + 'day--highlighted',
|
1405
|
+
now: prefix + 'day--today',
|
1406
|
+
infocus: prefix + 'day--infocus',
|
1407
|
+
outfocus: prefix + 'day--outfocus',
|
1408
|
+
|
1409
|
+
footer: prefix + 'footer',
|
1410
|
+
|
1411
|
+
buttonClear: prefix + 'button--clear',
|
1412
|
+
buttonToday: prefix + 'button--today',
|
1413
|
+
buttonClose: prefix + 'button--close'
|
1414
|
+
}
|
1415
|
+
}
|
1416
|
+
})( Picker.klasses().picker + '__' )
|
1417
|
+
|
1418
|
+
|
1419
|
+
|
1420
|
+
|
1421
|
+
|
1422
|
+
/**
|
1423
|
+
* Extend the picker to add the date picker.
|
1424
|
+
*/
|
1425
|
+
Picker.extend( 'pickadate', DatePicker )
|
1426
|
+
|
1427
|
+
|
1428
|
+
}));
|
1429
|
+
|