pageflow 17.0.5 → 17.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +342 -41
- data/README.md +3 -5
- data/admins/pageflow/accounts.rb +22 -20
- data/admins/pageflow/entry.rb +76 -26
- data/admins/pageflow/entry_templates.rb +10 -9
- data/admins/pageflow/folder.rb +1 -1
- data/admins/pageflow/membership.rb +15 -15
- data/admins/pageflow/revisions.rb +5 -5
- data/admins/pageflow/site_root_entry.rb +64 -0
- data/admins/pageflow/sites.rb +12 -3
- data/admins/pageflow/translations.rb +75 -0
- data/admins/pageflow/user.rb +21 -35
- data/app/assets/images/pageflow/admin/icons/comment.svg +1 -0
- data/app/assets/javascripts/pageflow/admin/entries.js +30 -5
- data/app/assets/javascripts/pageflow/dist/ui.js +4228 -900
- data/app/assets/javascripts/pageflow/editor/vendor.js +0 -1
- data/app/assets/javascripts/pageflow/ui.js +0 -1
- data/app/assets/stylesheets/pageflow/admin/entries/index_table.scss +2 -1
- data/app/assets/stylesheets/pageflow/admin/entry_comments_indicator.scss +45 -0
- data/app/assets/stylesheets/pageflow/admin/permalink_input.scss +8 -0
- data/app/assets/stylesheets/pageflow/admin.scss +1 -0
- data/app/assets/stylesheets/pageflow/animations/spin.scss +9 -0
- data/app/assets/stylesheets/pageflow/animations.scss +1 -0
- data/app/assets/stylesheets/pageflow/editor/background_positioning.scss +27 -5
- data/app/assets/stylesheets/pageflow/editor/base.scss +11 -1
- data/app/assets/stylesheets/pageflow/editor/drop_down_button.scss +20 -2
- data/app/assets/stylesheets/pageflow/editor/edit_configuration_view.scss +5 -0
- data/app/assets/stylesheets/pageflow/editor/file_folders.scss +127 -0
- data/app/assets/stylesheets/pageflow/editor/file_meta_data.scss +5 -2
- data/app/assets/stylesheets/pageflow/editor/file_meta_data_overlay.scss +45 -0
- data/app/assets/stylesheets/pageflow/editor/file_preview.scss +138 -0
- data/app/assets/stylesheets/pageflow/editor/file_references.scss +68 -0
- data/app/assets/stylesheets/pageflow/editor/file_settings_dialog.scss +1 -1
- data/app/assets/stylesheets/pageflow/editor/file_stage_icons.scss +17 -0
- data/app/assets/stylesheets/pageflow/editor/file_stages.scss +25 -32
- data/app/assets/stylesheets/pageflow/editor/file_thumbnails.scss +31 -48
- data/app/assets/stylesheets/pageflow/editor/file_type_pills.scss +73 -0
- data/app/assets/stylesheets/pageflow/editor/files.scss +242 -50
- data/app/assets/stylesheets/pageflow/editor/filtered_files.scss +161 -9
- data/app/assets/stylesheets/pageflow/editor/folder_breadcrumb.scss +40 -0
- data/app/assets/stylesheets/pageflow/editor/info_box.scss +23 -3
- data/app/assets/stylesheets/pageflow/editor/inputs/edit_defaults_button.scss +15 -0
- data/app/assets/stylesheets/pageflow/editor/inputs.scss +1 -0
- data/app/assets/stylesheets/pageflow/editor/list.scss +89 -37
- data/app/assets/stylesheets/pageflow/editor/list_search_field.scss +52 -0
- data/app/assets/stylesheets/pageflow/editor/manage_files.scss +9 -0
- data/app/assets/stylesheets/pageflow/editor/menu.scss +14 -0
- data/app/assets/stylesheets/pageflow/editor/move_to_folder_dialog.scss +83 -0
- data/app/assets/stylesheets/pageflow/editor/outline.scss +0 -13
- data/app/assets/stylesheets/pageflow/editor/sortable.scss +12 -0
- data/app/assets/stylesheets/pageflow/mixins/buttons.scss +4 -4
- data/app/assets/stylesheets/pageflow/mixins/pageflow.scss +9 -5
- data/app/assets/stylesheets/pageflow/ui/color_picker.scss +230 -0
- data/app/assets/stylesheets/pageflow/ui/forms.scss +38 -4
- data/app/assets/stylesheets/pageflow/ui/functions.scss +12 -2
- data/app/assets/stylesheets/pageflow/ui/input/color_input.scss +9 -8
- data/app/assets/stylesheets/pageflow/ui/input/file_name_input.scss +37 -0
- data/app/assets/stylesheets/pageflow/ui/input/text_area_input.scss +15 -0
- data/app/assets/stylesheets/pageflow/ui/overrides.scss +8 -0
- data/app/assets/stylesheets/pageflow/ui/properties.scss +34 -0
- data/app/assets/stylesheets/pageflow/ui/tabs_view.scss +8 -3
- data/app/assets/stylesheets/pageflow/ui.scss +4 -1
- data/app/controllers/concerns/pageflow/controller_delegation.rb +1 -1
- data/app/controllers/concerns/pageflow/edit_locking.rb +17 -10
- data/app/controllers/concerns/pageflow/entry_password_protection.rb +1 -0
- data/app/controllers/concerns/pageflow/public_https_mode.rb +2 -1
- data/app/controllers/concerns/pageflow/quota_verification.rb +5 -4
- data/app/controllers/pageflow/admin/initial_passwords_controller.rb +1 -0
- data/app/controllers/pageflow/application_controller.rb +19 -19
- data/app/controllers/pageflow/chapters_controller.rb +3 -2
- data/app/controllers/pageflow/edit_locks_controller.rb +3 -2
- data/app/controllers/pageflow/editor/encoding_confirmations_controller.rb +1 -0
- data/app/controllers/pageflow/editor/entries_controller.rb +3 -1
- data/app/controllers/pageflow/editor/entry_publications_controller.rb +1 -0
- data/app/controllers/pageflow/editor/file_folders_controller.rb +80 -0
- data/app/controllers/pageflow/editor/file_import_controller.rb +4 -3
- data/app/controllers/pageflow/editor/files_controller.rb +20 -10
- data/app/controllers/pageflow/editor/oembeds_controller.rb +21 -0
- data/app/controllers/pageflow/editor/widgets_controller.rb +1 -0
- data/app/controllers/pageflow/entries_controller.rb +85 -21
- data/app/controllers/pageflow/feeds_controller.rb +1 -1
- data/app/controllers/pageflow/files_controller.rb +1 -0
- data/app/controllers/pageflow/pages_controller.rb +4 -2
- data/app/controllers/pageflow/review/comment_thread_reads_controller.rb +30 -0
- data/app/controllers/pageflow/review/comment_threads_controller.rb +60 -0
- data/app/controllers/pageflow/review/comments_controller.rb +53 -0
- data/app/controllers/pageflow/revisions_controller.rb +5 -1
- data/app/controllers/pageflow/sitemaps_controller.rb +1 -1
- data/app/controllers/pageflow/storylines_controller.rb +1 -0
- data/app/helpers/pageflow/admin/cutoff_modes_helper.rb +12 -0
- data/app/helpers/pageflow/admin/entries_helper.rb +41 -1
- data/app/helpers/pageflow/admin/entry_translations_helper.rb +18 -0
- data/app/helpers/pageflow/admin/features_helper.rb +1 -1
- data/app/helpers/pageflow/admin/form_helper.rb +3 -3
- data/app/helpers/pageflow/admin/locales_helper.rb +10 -2
- data/app/helpers/pageflow/admin/memberships_helper.rb +32 -32
- data/app/helpers/pageflow/admin/revisions_helper.rb +1 -1
- data/app/helpers/pageflow/admin/sites_helper.rb +22 -0
- data/app/helpers/pageflow/admin/users_helper.rb +7 -5
- data/app/helpers/pageflow/admin/widgets_helper.rb +5 -5
- data/app/helpers/pageflow/asset_urls_helper.rb +1 -1
- data/app/helpers/pageflow/audio_files_helper.rb +5 -2
- data/app/helpers/pageflow/background_image_helper.rb +7 -6
- data/app/helpers/pageflow/common_entry_seed_helper.rb +7 -7
- data/app/helpers/pageflow/editor/config_helper.rb +3 -1
- data/app/helpers/pageflow/editor/files_helper.rb +1 -1
- data/app/helpers/pageflow/embed_code_helper.rb +3 -3
- data/app/helpers/pageflow/entries_helper.rb +52 -46
- data/app/helpers/pageflow/entry_json_seed_helper.rb +7 -6
- data/app/helpers/pageflow/feeds_helper.rb +2 -2
- data/app/helpers/pageflow/file_background_images_helper.rb +2 -2
- data/app/helpers/pageflow/file_thumbnails_helper.rb +4 -3
- data/app/helpers/pageflow/files_helper.rb +5 -4
- data/app/helpers/pageflow/folders_helper.rb +8 -5
- data/app/helpers/pageflow/help_entries_helper.rb +2 -2
- data/app/helpers/pageflow/hreflang_links_helper.rb +37 -0
- data/app/helpers/pageflow/info_box_helper.rb +7 -11
- data/app/helpers/pageflow/media_query_helper.rb +3 -3
- data/app/helpers/pageflow/navigation_bar_helper.rb +1 -1
- data/app/helpers/pageflow/overview_helper.rb +1 -1
- data/app/helpers/pageflow/page_types_helper.rb +5 -5
- data/app/helpers/pageflow/pages_helper.rb +29 -15
- data/app/helpers/pageflow/public_i18n_helper.rb +10 -9
- data/app/helpers/pageflow/quota_helper.rb +4 -4
- data/app/helpers/pageflow/render_json_helper.rb +6 -3
- data/app/helpers/pageflow/revision_file_helper.rb +2 -1
- data/app/helpers/pageflow/sites_helper.rb +3 -3
- data/app/helpers/pageflow/social_share_helper.rb +24 -10
- data/app/helpers/pageflow/social_share_links_helper.rb +12 -9
- data/app/helpers/pageflow/structured_data_helper.rb +5 -2
- data/app/helpers/pageflow/stub_page_configuration.rb +7 -3
- data/app/helpers/pageflow/text_direction_helper.rb +1 -1
- data/app/helpers/pageflow/themes_helper.rb +2 -4
- data/app/helpers/pageflow/video_files_helper.rb +29 -13
- data/app/helpers/pageflow/widgets_helper.rb +8 -6
- data/app/inputs/pageflow_permalink_input.rb +8 -3
- data/app/jobs/pageflow/application_job.rb +1 -0
- data/app/jobs/pageflow/entry_export_import/upload_and_publish_file_job.rb +1 -1
- data/app/jobs/pageflow/poll_meta_data_from_zencoder_job.rb +1 -0
- data/app/jobs/pageflow/poll_zencoder_job.rb +3 -2
- data/app/jobs/pageflow/process_image_or_text_track_job.rb +1 -0
- data/app/jobs/pageflow/prune_auto_snapshots_job.rb +1 -0
- data/app/jobs/pageflow/request_meta_data_from_zencoder_job.rb +1 -0
- data/app/jobs/pageflow/submit_file_to_zencoder_job.rb +1 -0
- data/app/mailers/pageflow/user_mailer.rb +1 -0
- data/app/models/concerns/pageflow/auto_generated_perma_id.rb +20 -1
- data/app/models/concerns/pageflow/entry_publication_states.rb +7 -3
- data/app/models/concerns/pageflow/feature_target.rb +8 -4
- data/app/models/concerns/pageflow/output_source.rb +3 -3
- data/app/models/concerns/pageflow/permalinkable.rb +2 -1
- data/app/models/concerns/pageflow/reusable_file.rb +24 -24
- data/app/models/concerns/pageflow/serialization_blacklist.rb +3 -5
- data/app/models/concerns/pageflow/suspendable.rb +5 -3
- data/app/models/concerns/pageflow/theme_referencer.rb +1 -1
- data/app/models/concerns/pageflow/translatable.rb +62 -0
- data/app/models/concerns/pageflow/translated_attributes.rb +101 -0
- data/app/models/concerns/pageflow/uploadable_file.rb +6 -6
- data/app/models/pageflow/account.rb +6 -5
- data/app/models/pageflow/account_member_query.rb +1 -1
- data/app/models/pageflow/account_role_query.rb +1 -1
- data/app/models/pageflow/application_query.rb +1 -1
- data/app/models/pageflow/application_record.rb +1 -1
- data/app/models/pageflow/audio_file.rb +4 -4
- data/app/models/pageflow/audio_file_url_templates.rb +1 -1
- data/app/models/pageflow/authentication_token.rb +2 -2
- data/app/models/pageflow/chapter.rb +6 -1
- data/app/models/pageflow/chapter_scaffold.rb +2 -4
- data/app/models/pageflow/cname_site_request_scope.rb +1 -1
- data/app/models/pageflow/comment.rb +30 -0
- data/app/models/pageflow/comment_thread.rb +65 -0
- data/app/models/pageflow/comment_thread_read.rb +22 -0
- data/app/models/pageflow/customized_theme.rb +9 -8
- data/app/models/pageflow/draft_entry.rb +49 -9
- data/app/models/pageflow/edit_lock.rb +19 -21
- data/app/models/pageflow/encoding_confirmation.rb +2 -2
- data/app/models/pageflow/entries_feed.rb +2 -2
- data/app/models/pageflow/entry.rb +46 -30
- data/app/models/pageflow/entry_at_revision.rb +14 -2
- data/app/models/pageflow/entry_comment_summary.rb +114 -0
- data/app/models/pageflow/entry_duplicate.rb +8 -5
- data/app/models/pageflow/entry_publication.rb +2 -2
- data/app/models/pageflow/entry_role_query.rb +4 -4
- data/app/models/pageflow/entry_template.rb +4 -4
- data/app/models/pageflow/entry_title_or_account_name_query.rb +2 -2
- data/app/models/pageflow/entry_translation_group.rb +42 -0
- data/app/models/pageflow/file_folder.rb +74 -0
- data/app/models/pageflow/file_reuse.rb +5 -4
- data/app/models/pageflow/file_usage.rb +18 -3
- data/app/models/pageflow/folder.rb +2 -2
- data/app/models/pageflow/home_button.rb +7 -7
- data/app/models/pageflow/image_file.rb +44 -25
- data/app/models/pageflow/image_file_url_templates.rb +4 -4
- data/app/models/pageflow/invitation_form.rb +2 -1
- data/app/models/pageflow/legal_info.rb +38 -0
- data/app/models/pageflow/managed_user_query.rb +1 -1
- data/app/models/pageflow/membership.rb +5 -5
- data/app/models/pageflow/nested_revision_component_copy.rb +263 -0
- data/app/models/pageflow/null_user.rb +1 -1
- data/app/models/pageflow/overview_button.rb +1 -1
- data/app/models/pageflow/page.rb +7 -3
- data/app/models/pageflow/permalink.rb +24 -2
- data/app/models/pageflow/permalink_directory.rb +7 -0
- data/app/models/pageflow/permalink_redirect.rb +7 -0
- data/app/models/pageflow/positioned_file.rb +5 -5
- data/app/models/pageflow/potential_entry_translations.rb +55 -0
- data/app/models/pageflow/potential_memberships.rb +5 -4
- data/app/models/pageflow/published_entry.rb +62 -11
- data/app/models/pageflow/revision.rb +29 -16
- data/app/models/pageflow/roles.rb +14 -18
- data/app/models/pageflow/site.rb +46 -3
- data/app/models/pageflow/site_root_entry_form.rb +27 -0
- data/app/models/pageflow/sitemaps.rb +10 -1
- data/app/models/pageflow/storyline.rb +5 -2
- data/app/models/pageflow/storyline_scaffold.rb +1 -1
- data/app/models/pageflow/text_track_file.rb +1 -1
- data/app/models/pageflow/text_track_file_url_templates.rb +1 -1
- data/app/models/pageflow/theme_customization_file.rb +3 -2
- data/app/models/pageflow/thumbnail_file_resolver.rb +1 -1
- data/app/models/pageflow/url_template.rb +1 -1
- data/app/models/pageflow/used_file.rb +13 -3
- data/app/models/pageflow/user_name_query.rb +2 -2
- data/app/models/pageflow/video_file.rb +22 -15
- data/app/models/pageflow/video_file_url_templates.rb +6 -4
- data/app/models/pageflow/widget.rb +5 -4
- data/app/models/pageflow/with_file_usage_extension.rb +1 -1
- data/app/models/pageflow/zencoder_attachment.rb +8 -8
- data/app/policies/pageflow/account_policy.rb +3 -1
- data/app/policies/pageflow/admin/admin_only_tab_policy.rb +1 -0
- data/app/policies/pageflow/admin/entry_tab_policy.rb +1 -0
- data/app/policies/pageflow/application_policy.rb +2 -0
- data/app/policies/pageflow/entry_policy.rb +7 -1
- data/app/policies/pageflow/entry_template_policy.rb +2 -1
- data/app/policies/pageflow/file_policy.rb +4 -7
- data/app/policies/pageflow/folder_policy.rb +18 -8
- data/app/policies/pageflow/membership_policy.rb +6 -4
- data/app/policies/pageflow/site_policy.rb +10 -3
- data/app/policies/pageflow/user_policy.rb +6 -4
- data/app/state_machines/pageflow/image_and_text_track_processing_state_machine.rb +3 -2
- data/app/state_machines/pageflow/media_encoding_state_machine.rb +5 -4
- data/app/views/admin/accounts/_entry_template_details.html.arb +2 -2
- data/app/views/admin/entries/_attributes_table.html.arb +6 -5
- data/app/views/admin/entries/_form.html.erb +2 -1
- data/app/views/admin/entries/_permalink_inputs.html.erb +9 -2
- data/app/views/admin/entry_templates/_form.html.erb +1 -3
- data/app/views/admin/site_root_entry/choose.html.erb +19 -0
- data/app/views/admin/sites/_fields.html.erb +14 -1
- data/app/views/admin/translations/_form.html.erb +31 -0
- data/app/views/admin/users/_attributes_table.html.arb +13 -0
- data/app/views/components/pageflow/admin/add_membership_button.rb +13 -12
- data/app/views/components/pageflow/admin/custom_scopes_renderer.rb +1 -0
- data/app/views/components/pageflow/admin/embed_code_field.rb +1 -0
- data/app/views/components/pageflow/admin/embedded_index_table.rb +9 -10
- data/app/views/components/pageflow/admin/entries_tab.rb +1 -0
- data/app/views/components/pageflow/admin/entry_publication_state_indicator.rb +6 -5
- data/app/views/components/pageflow/admin/entry_templates_tab.rb +2 -1
- data/app/views/components/pageflow/admin/entry_translations_tab.rb +102 -0
- data/app/views/components/pageflow/admin/entry_user_badge_list.rb +1 -0
- data/app/views/components/pageflow/admin/extensible_attributes_table.rb +9 -8
- data/app/views/components/pageflow/admin/features_tab.rb +1 -0
- data/app/views/components/pageflow/admin/grouped_folder_list.rb +1 -0
- data/app/views/components/pageflow/admin/icon_link_to.rb +1 -0
- data/app/views/components/pageflow/admin/members_tab.rb +4 -3
- data/app/views/components/pageflow/admin/membership_role_with_tooltip.rb +3 -2
- data/app/views/components/pageflow/admin/revisions_tab.rb +14 -10
- data/app/views/components/pageflow/admin/sites_tab.rb +1 -0
- data/app/views/components/pageflow/admin/tabs_view.rb +1 -0
- data/app/views/components/pageflow/admin/timestamp.rb +6 -5
- data/app/views/components/pageflow/admin/user_account_badge_list.rb +2 -3
- data/app/views/components/pageflow/admin/user_accounts_tab.rb +1 -0
- data/app/views/components/pageflow/admin/user_entries_tab.rb +1 -0
- data/app/views/components/pageflow/admin/users_tab.rb +1 -0
- data/app/views/pageflow/audio_files/_audio_file.json.jbuilder +0 -1
- data/app/views/pageflow/editor/config/_seeds.json.jbuilder +5 -3
- data/app/views/pageflow/editor/entries/_entry.json.jbuilder +2 -1
- data/app/views/pageflow/editor/entries/index.json.jbuilder +1 -1
- data/app/views/pageflow/editor/entries/seed.json.erb +1 -0
- data/app/views/pageflow/editor/entries/show.json.jbuilder +1 -1
- data/app/views/pageflow/editor/entry_publications/check.json.jbuilder +2 -2
- data/app/views/pageflow/editor/file_folders/_file_folder.json.jbuilder +5 -0
- data/app/views/pageflow/editor/file_folders/create.json.jbuilder +1 -0
- data/app/views/pageflow/editor/file_folders/index.json.jbuilder +3 -0
- data/app/views/pageflow/editor/files/_file.json.jbuilder +7 -14
- data/app/views/pageflow/editor/files/create.json.jbuilder +1 -1
- data/app/views/pageflow/editor/files/index.json.jbuilder +1 -1
- data/app/views/pageflow/editor/image_files/_image_file.json.jbuilder +3 -0
- data/app/views/pageflow/editor/sites/_site.json.jbuilder +1 -0
- data/app/views/pageflow/editor/video_files/_video_file.json.jbuilder +4 -3
- data/app/views/pageflow/entries/share_menu/_bluesky_link.html.erb +8 -0
- data/app/views/pageflow/entries/share_menu/_threads_link.html.erb +8 -0
- data/app/views/pageflow/files/_file.json.jbuilder +5 -3
- data/app/views/pageflow/image_files/_image_file.json.jbuilder +0 -1
- data/app/views/pageflow/review/comment_threads/_comment_thread.json.jbuilder +20 -0
- data/app/views/pageflow/review/comment_threads/create.json.jbuilder +2 -0
- data/app/views/pageflow/review/comment_threads/index.json.jbuilder +13 -0
- data/app/views/pageflow/review/comments/_comment.json.jbuilder +13 -0
- data/app/views/pageflow/review/comments/create.json.jbuilder +1 -0
- data/app/views/pageflow/sitemaps/index.xml.builder +9 -1
- data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +1 -1
- data/app/views/pageflow/social_share/_page_meta_tags.html.erb +1 -1
- data/app/views/pageflow/structured_data/_entry.json.jbuilder +2 -3
- data/app/views/pageflow/video_files/_video_file.json.jbuilder +0 -1
- data/config/initializers/active_admin_patches.rb +3 -6
- data/config/initializers/admin_resource_tabs.rb +3 -0
- data/config/initializers/paperclip.rb +1 -0
- data/config/initializers/symmetric_encryption.rb +1 -1
- data/config/initializers/zencoder.rb +24 -13
- data/config/locales/de.yml +256 -12
- data/config/locales/en.yml +253 -15
- data/config/routes.rb +29 -13
- data/config/spring.rb +2 -1
- data/db/migrate/20140418225525_setup_schema.rb +2 -2
- data/db/migrate/20190306161431_copy_file_attributes_of_failed_uploads.rb +2 -2
- data/db/migrate/20190820152900_drop_accounts_themes.rb +2 -1
- data/db/migrate/20191202145757_create_pageflow_scrolled_sections.rb +11 -11
- data/db/migrate/20191202150657_create_pageflow_scrolled_chapters.rb +1 -1
- data/db/migrate/20191202154723_create_pageflow_scrolled_content_elements.rb +9 -9
- data/db/migrate/20191219143450_add_position_to_content_elements.rb +2 -1
- data/db/migrate/20200117133200_change_revision_appearance_option_default_and_null.rb +2 -1
- data/db/migrate/20200122115400_create_pageflow_entry_templates.rb +25 -25
- data/db/migrate/20200206134400_convert_legacy_scrolled_content_element_types.rb +3 -3
- data/db/migrate/20221215120856_associate_entry_templates_with_sites.rb +2 -2
- data/db/migrate/20230120092923_create_other_files.rb +2 -1
- data/db/migrate/20230419083307_create_pageflow_entry_translation_group.rb +9 -0
- data/db/migrate/20240612110434_add_cutoff_mode_name_to_sites.rb +5 -0
- data/db/migrate/20240918084059_create_pageflow_permalink_redirects.rb +14 -0
- data/db/migrate/20250508172234_ensure_scrolled_entries_have_main_storyline.rb +14 -0
- data/db/migrate/20250617090048_add_custom404_entry_to_sites.rb +5 -0
- data/db/migrate/20250617100000_add_perma_id_counter_to_entries.rb +28 -0
- data/db/migrate/20250722174123_add_perma_id_to_chapters.rb +10 -0
- data/db/migrate/20250725080603_add_perma_id_indexes_to_revision_components.rb +13 -0
- data/db/migrate/20250726000000_add_display_name_to_file_usages.rb +5 -0
- data/db/migrate/20251015000000_add_structured_data_type_name_to_revisions.rb +5 -0
- data/db/migrate/20251029142849_convert_legacy_social_embeds_to_unified_social_embed.rb +38 -0
- data/db/migrate/20251119083347_fix_main_storyline_positions.rb +16 -0
- data/db/migrate/20251119083348_ensure_scrolled_entries_have_excursion_storyline.rb +15 -0
- data/db/migrate/20260303000000_add_layout_version_to_revisions.rb +6 -0
- data/db/migrate/20260323000000_create_comment_threads_and_comments.rb +30 -0
- data/db/migrate/20260414000000_add_subject_range_to_comment_threads.rb +5 -0
- data/db/migrate/20260415000000_add_section_perma_id_to_comment_threads.rb +5 -0
- data/db/migrate/20260727000000_add_quote_to_comments.rb +5 -0
- data/db/migrate/20260728000000_create_file_folders.rb +17 -0
- data/db/migrate/20260805000000_add_attribute_translations_to_sites.rb +5 -0
- data/db/migrate/20260806000000_add_edited_at_to_comments.rb +5 -0
- data/db/migrate/20260810000000_create_pageflow_scrolled_lottie_files.rb +24 -0
- data/db/migrate/20260817000000_create_comment_thread_reads.rb +16 -0
- data/db/migrate/20260819000000_add_unread_comments_since_at_to_users.rb +18 -0
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +12599 -5398
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +1275 -4560
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-client.js +20204 -22
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-server.js +18657 -19
- data/entry_types/paged/app/controllers/pageflow_paged/entries_controller.rb +1 -0
- data/entry_types/paged/app/helpers/pageflow_paged/page_background_asset_helper.rb +1 -1
- data/entry_types/paged/app/helpers/pageflow_paged/third_party_embed_consent_helper.rb +7 -7
- data/entry_types/paged/app/views/pageflow_paged/editor/entries/_seed.json.jbuilder +1 -0
- data/entry_types/paged/app/views/pageflow_paged/entries/show.html.erb +1 -0
- data/entry_types/paged/lib/pageflow_paged/plugin.rb +4 -0
- data/entry_types/paged/lib/pageflow_paged/react/page_type.rb +1 -1
- data/entry_types/paged/lib/pageflow_paged/react/widget_type.rb +3 -3
- data/entry_types/paged/lib/pageflow_paged.rb +1 -1
- data/entry_types/scrolled/app/assets/stylesheets/pageflow_scrolled/ui.scss +2 -0
- data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +5 -3
- data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +35 -5
- data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +4 -5
- data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +23 -2
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/cache_helper.rb +3 -3
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/entry_json_seed_helper.rb +8 -5
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +7 -3
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +72 -10
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/i18n_helper.rb +28 -13
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/packs_helper.rb +41 -12
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +23 -25
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/sprockets_helper.rb +16 -0
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +189 -3
- data/entry_types/scrolled/app/models/pageflow_scrolled/chapter.rb +15 -14
- data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +61 -7
- data/entry_types/scrolled/app/models/pageflow_scrolled/lottie_file.rb +6 -0
- data/entry_types/scrolled/app/models/pageflow_scrolled/lottie_file_url_templates.rb +16 -0
- data/entry_types/scrolled/app/models/pageflow_scrolled/section.rb +12 -1
- data/entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb +20 -1
- data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +1 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/editor/sections/_section_with_content_elements.json.jbuilder +2 -2
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +15 -12
- data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +45 -17
- data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry_translations.json.jbuilder +14 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +34 -5
- data/entry_types/scrolled/app/views/pageflow_scrolled/favicons/_entry.html.erb +1 -1
- data/entry_types/scrolled/app/views/pageflow_scrolled/storylines/_storyline.json.jbuilder +7 -0
- data/entry_types/scrolled/config/configuration_schemas/pageflow-scrolled.json +414 -0
- data/entry_types/scrolled/config/locales/de.yml +1094 -78
- data/entry_types/scrolled/config/locales/en.yml +1083 -78
- data/entry_types/scrolled/config/routes.rb +18 -8
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +11 -11
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDarkVariantDesktop.svg +56 -0
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDarkVariantMobile.svg +22 -0
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/themes_plugin.rb.tt +26 -11
- data/entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb +27 -8
- data/entry_types/scrolled/lib/pageflow_scrolled/additional_seed_data.rb +2 -2
- data/entry_types/scrolled/lib/pageflow_scrolled/additional_theme_assets.rb +27 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/configuration.rb +67 -10
- data/entry_types/scrolled/lib/pageflow_scrolled/configuration_schemas.rb +91 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/content_element_consent_vendors.rb +1 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/engine.rb +2 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/entry_file_reference_locations.rb +71 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/entry_structured_data_types/faq_page.rb +58 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/file_reference_locations.rb +69 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +222 -19
- data/entry_types/scrolled/lib/pageflow_scrolled/react_widget_type.rb +2 -4
- data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +76 -54
- data/entry_types/scrolled/lib/pageflow_scrolled/theme_options_default_scale.rb +35 -0
- data/entry_types/scrolled/lib/pageflow_scrolled.rb +14 -1
- data/entry_types/scrolled/lib/tasks/pageflow_scrolled/storybook.rake +24 -5
- data/entry_types/scrolled/package/config/configurationSchemas.js +70 -0
- data/entry_types/scrolled/package/config/rollup/configurationSchemas.js +19 -0
- data/entry_types/scrolled/package/config/webpack.js +94 -0
- data/entry_types/scrolled/package/contentElements/hotspots-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/hotspots-frontend.js +1795 -0
- data/entry_types/scrolled/package/contentElements/inlineBeforeAfter-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/inlineBeforeAfter-frontend.js +219 -0
- data/entry_types/scrolled/package/contentElements/lottieAnimation-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/lottieAnimation-frontend.js +244 -0
- data/entry_types/scrolled/package/contentElements/socialEmbed-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/socialEmbed-frontend.js +823 -0
- data/entry_types/scrolled/package/contentElements/tikTokEmbed-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/tikTokEmbed-frontend.js +109 -0
- data/entry_types/scrolled/package/contentElements/twitterEmbed-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/twitterEmbed-frontend.js +277 -0
- data/entry_types/scrolled/package/contentElements/videoEmbed-frontend.css +1 -0
- data/entry_types/scrolled/package/contentElements/videoEmbed-frontend.js +244 -0
- data/entry_types/scrolled/package/contentElements-editor.js +3155 -583
- data/entry_types/scrolled/package/contentElements-frontend.css +1 -1
- data/entry_types/scrolled/package/contentElements-frontend.js +3375 -1585
- data/entry_types/scrolled/package/editor.css +1 -0
- data/entry_types/scrolled/package/editor.js +8452 -2867
- data/entry_types/scrolled/package/entryState.js +1600 -0
- data/entry_types/scrolled/package/frontend/FloatingPortalRootProvider-20c600de.js +1979 -0
- data/entry_types/scrolled/package/frontend/FloatingPortalRootProvider-58189220.js +2538 -0
- data/entry_types/scrolled/package/frontend/{PhonePlatformContext-4ec6b2de.js → PhonePlatformContext-035a99fa.js} +9 -15
- data/entry_types/scrolled/package/frontend/PhonePlatformContext-9da43797.js +33 -0
- data/entry_types/scrolled/package/frontend/Placeholder.module-bf0966b4.js +5267 -0
- data/entry_types/scrolled/package/frontend/Placeholder.module-d22a9335.js +4180 -0
- data/entry_types/scrolled/package/frontend/ThemeIcon-ab834849.js +754 -0
- data/entry_types/scrolled/package/frontend/ThemeIcon-f6cb3a8f.js +773 -0
- data/entry_types/scrolled/package/frontend/ToggleFullscreenCornerButton-30fd1124.js +39 -0
- data/entry_types/scrolled/package/frontend/ToggleFullscreenCornerButton-61c25224.js +72 -0
- data/entry_types/scrolled/package/frontend/Viewer-1074fd59.js +147 -0
- data/entry_types/scrolled/package/frontend/Viewer-1482ca34.js +480 -0
- data/entry_types/scrolled/package/frontend/Viewer-70504231.js +210 -0
- data/entry_types/scrolled/package/frontend/{Viewer-1bb5597c.js → Viewer-cc8d4072.js} +100 -135
- data/entry_types/scrolled/package/frontend/Wavesurfer-656e3c36.js +302 -0
- data/entry_types/scrolled/package/frontend/Wavesurfer-b753b838.js +385 -0
- data/entry_types/scrolled/package/frontend/commenting.css +1 -0
- data/entry_types/scrolled/package/frontend/extensions-167ae143.js +1455 -0
- data/entry_types/scrolled/package/frontend/extensions-2318f92b.js +5918 -0
- data/entry_types/scrolled/package/frontend/extensions-a461fd13.js +4890 -0
- data/entry_types/scrolled/package/frontend/extensions-c98269fd.js +1982 -0
- data/entry_types/scrolled/package/frontend/i18n-493cd2a6.js +93 -0
- data/entry_types/scrolled/package/frontend/i18n-e06cac14.js +100 -0
- data/entry_types/scrolled/package/frontend/{index-11f32f10.js → index-2e5546f7.js} +39 -54
- data/entry_types/scrolled/package/frontend/index-de2b418d.js +130 -0
- data/entry_types/scrolled/package/frontend/index.css +1 -1
- data/entry_types/scrolled/package/frontend/index.js +1976 -1367
- data/entry_types/scrolled/package/frontend/inlineEditing.css +1 -0
- data/entry_types/scrolled/package/frontend/useContentElementEditorState-a084912e.js +25 -0
- data/entry_types/scrolled/package/frontend/useDelayedBoolean-a387d85b.js +24 -0
- data/entry_types/scrolled/package/frontend/usePhonePlatform-4ecb96d4.js +8 -0
- data/entry_types/scrolled/package/frontend/usePhonePlatform-ce9ff08d.js +8 -0
- data/entry_types/scrolled/package/frontend-server.js +20 -210
- data/entry_types/scrolled/package/package.json +22 -12
- data/entry_types/scrolled/package/review.css +1 -0
- data/entry_types/scrolled/package/review.js +3306 -0
- data/entry_types/scrolled/package/testHelpers.js +952 -239
- data/entry_types/scrolled/package/values/widgets.module.css +18 -0
- data/entry_types/scrolled/package/widgets/consentBar.css +1 -1
- data/entry_types/scrolled/package/widgets/consentBar.js +275 -315
- data/entry_types/scrolled/package/widgets/defaultNavigation.css +2 -2
- data/entry_types/scrolled/package/widgets/defaultNavigation.js +961 -432
- data/entry_types/scrolled/package/widgets/excursionSheet.css +1 -0
- data/entry_types/scrolled/package/widgets/excursionSheet.js +225 -0
- data/entry_types/scrolled/package/widgets/iconInlineFileRights.css +1 -1
- data/entry_types/scrolled/package/widgets/iconInlineFileRights.js +62 -32
- data/entry_types/scrolled/package/widgets/iconScrollIndicator.css +1 -0
- data/entry_types/scrolled/package/widgets/iconScrollIndicator.js +67 -0
- data/entry_types/scrolled/package/widgets/mainStorylineSheet.css +1 -0
- data/entry_types/scrolled/package/widgets/mainStorylineSheet.js +100 -0
- data/entry_types/scrolled/package/widgets/textInlineFileRights.css +1 -1
- data/entry_types/scrolled/package/widgets/textInlineFileRights.js +48 -26
- data/entry_types/scrolled/package/widgets-server.js +2 -0
- data/entry_types/scrolled/spec/factories/chapters.rb +14 -1
- data/entry_types/scrolled/spec/factories/content_elements.rb +1 -1
- data/entry_types/scrolled/spec/factories/lottie_files.rb +29 -0
- data/entry_types/scrolled/spec/fixtures/animation.lottie +0 -0
- data/entry_types/scrolled/spec/fixtures/font.woff +0 -0
- data/entry_types/scrolled/spec/fixtures/font.woff2 +0 -0
- data/lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb +5 -3
- data/lib/generators/pageflow/assets/assets_generator.rb +7 -5
- data/lib/generators/pageflow/cancan/cancan_generator.rb +2 -1
- data/lib/generators/pageflow/cancan/templates/ability.rb +1 -1
- data/lib/generators/pageflow/error_pages/error_pages_generator.rb +2 -1
- data/lib/generators/pageflow/initializer/initializer_generator.rb +3 -2
- data/lib/generators/pageflow/install/install_generator.rb +2 -2
- data/lib/generators/pageflow/procfile/procfile_generator.rb +2 -1
- data/lib/generators/pageflow/resque/resque_generator.rb +4 -4
- data/lib/generators/pageflow/resque/templates/resque.rake +1 -1
- data/lib/generators/pageflow/routes/routes_generator.rb +4 -2
- data/lib/generators/pageflow/seeds/seeds_generator.rb +3 -2
- data/lib/generators/pageflow/seeds/templates/seeds.rb +6 -6
- data/lib/generators/pageflow/theme/theme_generator.rb +2 -1
- data/lib/generators/pageflow/user/user_generator.rb +2 -1
- data/lib/pageflow/ability_mixin.rb +25 -15
- data/lib/pageflow/active_admin_patches/views/attributes_table.rb +1 -0
- data/lib/pageflow/active_admin_patches/views/pages/base.rb +3 -2
- data/lib/pageflow/active_admin_patches/views/table_for.rb +1 -0
- data/lib/pageflow/additional_headers.rb +27 -0
- data/lib/pageflow/admin/attributes_table_rows.rb +3 -3
- data/lib/pageflow/admin/tabs.rb +1 -1
- data/lib/pageflow/built_in_file_type.rb +1 -1
- data/lib/pageflow/built_in_page_types_plugin.rb +1 -1
- data/lib/pageflow/built_in_widget_type.rb +2 -2
- data/lib/pageflow/built_in_widget_types_plugin.rb +2 -1
- data/lib/pageflow/configuration.rb +183 -18
- data/lib/pageflow/cutoff_modes.rb +39 -0
- data/lib/pageflow/deprecation.rb +19 -0
- data/lib/pageflow/editor_controller.rb +6 -10
- data/lib/pageflow/engine.rb +5 -6
- data/lib/pageflow/entries_controller_env_helper.rb +32 -2
- data/lib/pageflow/entry_export_import/attachment_files.rb +1 -1
- data/lib/pageflow/entry_export_import/entry_serialization.rb +9 -8
- data/lib/pageflow/entry_export_import/file_mappings.rb +1 -0
- data/lib/pageflow/entry_export_import/page_type_versions.rb +2 -2
- data/lib/pageflow/entry_export_import/revision_serialization/import.rb +11 -1
- data/lib/pageflow/entry_export_import/revision_serialization.rb +3 -0
- data/lib/pageflow/entry_export_import.rb +3 -3
- data/lib/pageflow/entry_structured_data_types.rb +43 -0
- data/lib/pageflow/entry_type_configuration.rb +1 -0
- data/lib/pageflow/entry_types.rb +2 -2
- data/lib/pageflow/feature.rb +1 -1
- data/lib/pageflow/features.rb +4 -6
- data/lib/pageflow/file_importers.rb +4 -4
- data/lib/pageflow/file_type.rb +5 -5
- data/lib/pageflow/file_types.rb +4 -4
- data/lib/pageflow/global_config_api.rb +5 -6
- data/lib/pageflow/help_entries.rb +7 -7
- data/lib/pageflow/help_entry.rb +1 -1
- data/lib/pageflow/hooks.rb +1 -1
- data/lib/pageflow/nested_revision_component.rb +9 -27
- data/lib/pageflow/news_item_api.rb +1 -1
- data/lib/pageflow/oembed_providers.rb +42 -0
- data/lib/pageflow/page_type.rb +2 -3
- data/lib/pageflow/page_types.rb +3 -3
- data/lib/pageflow/paperclip_interpolations/support.rb +1 -1
- data/lib/pageflow/paperclip_processors/vtt.rb +1 -0
- data/lib/pageflow/paperclip_processors/webp.rb +2 -2
- data/lib/pageflow/partial_editor_fragment_renderer.rb +2 -2
- data/lib/pageflow/plugin.rb +1 -2
- data/lib/pageflow/primary_domain_entry_redirect.rb +6 -0
- data/lib/pageflow/quota.rb +9 -5
- data/lib/pageflow/quotas.rb +1 -1
- data/lib/pageflow/rails_version.rb +14 -2
- data/lib/pageflow/react.rb +1 -1
- data/lib/pageflow/revision_component.rb +8 -40
- data/lib/pageflow/revision_components.rb +16 -6
- data/lib/pageflow/seeds.rb +12 -16
- data/lib/pageflow/theme.rb +1 -1
- data/lib/pageflow/theme_customizations.rb +10 -10
- data/lib/pageflow/themes.rb +44 -3
- data/lib/pageflow/user_mixin.rb +18 -6
- data/lib/pageflow/version.rb +1 -1
- data/lib/pageflow/widget_type.rb +4 -4
- data/lib/pageflow/widget_types.rb +9 -9
- data/lib/pageflow/zencoder_api.rb +32 -42
- data/lib/pageflow/zencoder_audio_output_definition.rb +14 -13
- data/lib/pageflow/zencoder_meta_data_output_definition.rb +3 -2
- data/lib/pageflow/zencoder_output_definition.rb +16 -14
- data/lib/pageflow/zencoder_video_output_definition.rb +140 -88
- data/lib/pageflow.rb +8 -2
- data/lib/tasks/pageflow_tasks.rake +1 -1
- data/package/config/eslint-rules/documented-in-toc.js +125 -0
- data/package/config/jest/index.js +0 -1
- data/package/config/webpack.js +0 -1
- data/package/config/webpack5.js +0 -1
- data/package/editor.js +4880 -2313
- data/package/frontend.js +710 -1223
- data/package/package.json +3 -1
- data/package/review.js +384 -0
- data/package/testHelpers.js +257 -243
- data/package/ui.js +1487 -813
- data/package/vendor/stubs/wysihtml5.js +2 -0
- data/spec/factories/accounts.rb +37 -22
- data/spec/factories/audio_files.rb +2 -2
- data/spec/factories/authentication_tokens.rb +4 -4
- data/spec/factories/chapters.rb +4 -4
- data/spec/factories/comment_thread_reads.rb +10 -0
- data/spec/factories/comment_threads.rb +10 -0
- data/spec/factories/comments.rb +9 -0
- data/spec/factories/draft_entries.rb +14 -6
- data/spec/factories/edit_locks.rb +1 -1
- data/spec/factories/entries.rb +28 -19
- data/spec/factories/entry_translation_groups.rb +6 -0
- data/spec/factories/file_folders.rb +8 -0
- data/spec/factories/file_usages.rb +2 -1
- data/spec/factories/folders.rb +1 -1
- data/spec/factories/image_files.rb +2 -2
- data/spec/factories/pages.rb +3 -3
- data/spec/factories/published_entries.rb +28 -8
- data/spec/factories/revisions.rb +1 -1
- data/spec/factories/sites.rb +6 -0
- data/spec/factories/test_multi_attachment_files.rb +1 -1
- data/spec/factories/text_track_files.rb +1 -1
- data/spec/factories/uploadable_files.rb +1 -1
- data/spec/factories/users.rb +6 -6
- data/spec/factories/video_files.rb +2 -2
- data/spec/factories/widgets.rb +1 -1
- data/spec/fixtures/7x15_rotated.jpg +0 -0
- data/vendor/assets/javascripts/wysihtml-toolbar.js +19288 -0
- metadata +266 -92
- data/app/assets/stylesheets/pageflow/editor/select_button.scss +0 -51
- data/config/initializers/revision_components.rb +0 -5
- data/config/locales/twitter_to_x.de.yml +0 -6
- data/config/locales/twitter_to_x.en.yml +0 -6
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/generated_media_queries_helper.rb +0 -55
- data/entry_types/scrolled/config/locales/twitter_to_x.de.yml +0 -12
- data/entry_types/scrolled/config/locales/twitter_to_x.en.yml +0 -12
- data/entry_types/scrolled/config/locales/vr_image_projection.de.yml +0 -24
- data/entry_types/scrolled/config/locales/vr_image_projection.en.yml +0 -24
- data/entry_types/scrolled/package/frontend/EditableInlineText.module-ebd22921.js +0 -5497
- data/entry_types/scrolled/package/frontend/ToggleFullscreenCornerButton-b79159cc.js +0 -107
- data/entry_types/scrolled/package/frontend/Viewer-1ecf3375.js +0 -154
- data/entry_types/scrolled/package/frontend/Wavesurfer-7d9cf1b7.js +0 -333
- data/entry_types/scrolled/package/frontend/arrowRight-62998af9.js +0 -77
- data/entry_types/scrolled/package/frontend/components-024a9893.js +0 -2853
- data/entry_types/scrolled/package/frontend/createSuper-d0f30da3.js +0 -115
- data/entry_types/scrolled/package/frontend/i18n-ce13a8bf.js +0 -1129
- data/entry_types/scrolled/package/frontend/useContentElementEditorState-4f4c3cf6.js +0 -52
- data/lib/generators/pageflow/resque/templates/resque_enqueue_after_commit_patch.rb +0 -25
- data/package/vendor/jquery.minicolors.js +0 -1108
data/package/frontend.js
CHANGED
|
@@ -1,257 +1,89 @@
|
|
|
1
|
-
import 'core-js/modules/es.array.from';
|
|
2
|
-
import 'core-js/modules/es.array.includes';
|
|
3
|
-
import 'core-js/modules/es.object.assign';
|
|
4
|
-
import 'core-js/modules/es.object.entries';
|
|
5
|
-
import 'core-js/modules/es.object.keys';
|
|
6
|
-
import 'core-js/modules/es.object.to-string';
|
|
7
|
-
import 'core-js/modules/es.promise';
|
|
8
|
-
import 'core-js/modules/es.promise.finally';
|
|
9
|
-
import 'core-js/modules/es.string.iterator';
|
|
10
|
-
import 'core-js/modules/esnext.aggregate-error';
|
|
11
|
-
import 'core-js/modules/esnext.promise.all-settled';
|
|
12
|
-
import 'core-js/modules/esnext.promise.any';
|
|
13
|
-
import 'core-js/modules/esnext.promise.try';
|
|
14
|
-
import 'core-js/modules/web.dom-collections.iterator';
|
|
15
|
-
import 'classlist.js';
|
|
16
1
|
import BackboneEvents from 'backbone-events-standalone';
|
|
17
2
|
import VideoJS from 'video.js';
|
|
18
3
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
obj[key] = value;
|
|
4
|
+
class Persistence {
|
|
5
|
+
constructor({
|
|
6
|
+
cookies
|
|
7
|
+
}) {
|
|
8
|
+
this.cookies = cookies;
|
|
29
9
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
10
|
+
store(vendors, signal) {
|
|
11
|
+
const vendorsByCookieName = vendors.reduce((sorted, vendor) => {
|
|
12
|
+
const cookieName = vendor.cookieName;
|
|
13
|
+
sorted[cookieName] = sorted[cookieName] || [];
|
|
14
|
+
sorted[cookieName].push(vendor);
|
|
15
|
+
return sorted;
|
|
16
|
+
}, {});
|
|
17
|
+
Object.entries(vendorsByCookieName).forEach(([cookieName, vendors]) => {
|
|
18
|
+
const cookieDomain = vendors[0].cookieDomain;
|
|
19
|
+
this.setCookie(cookieName, JSON.stringify(vendors.reduce((result, vendor) => {
|
|
20
|
+
result[vendor.cookieKey || vendor.name] = signal === 'accepted' ? true : signal === 'denied' ? false : signal[vendor.name];
|
|
21
|
+
return result;
|
|
22
|
+
}, {})), cookieDomain);
|
|
41
23
|
});
|
|
42
|
-
keys.push.apply(keys, symbols);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return keys;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _objectSpread2(target) {
|
|
49
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
50
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
51
|
-
|
|
52
|
-
if (i % 2) {
|
|
53
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
54
|
-
_defineProperty(target, key, source[key]);
|
|
55
|
-
});
|
|
56
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
57
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
58
|
-
} else {
|
|
59
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
60
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return target;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function _classCallCheck(instance, Constructor) {
|
|
69
|
-
if (!(instance instanceof Constructor)) {
|
|
70
|
-
throw new TypeError("Cannot call a class as a function");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function _defineProperties(target, props) {
|
|
75
|
-
for (var i = 0; i < props.length; i++) {
|
|
76
|
-
var descriptor = props[i];
|
|
77
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
78
|
-
descriptor.configurable = true;
|
|
79
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
80
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
81
24
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
_d = true;
|
|
109
|
-
_e = err;
|
|
110
|
-
} finally {
|
|
111
|
-
try {
|
|
112
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
113
|
-
} finally {
|
|
114
|
-
if (_d) throw _e;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return _arr;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function _arrayLikeToArray(arr, len) {
|
|
122
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
123
|
-
|
|
124
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
125
|
-
arr2[i] = arr[i];
|
|
25
|
+
update(vendor, signal) {
|
|
26
|
+
const content = this.cookies.getItem(vendor.cookieName);
|
|
27
|
+
const flags = content ? JSON.parse(content) : {};
|
|
28
|
+
this.setCookie(vendor.cookieName, JSON.stringify({
|
|
29
|
+
...flags,
|
|
30
|
+
[vendor.cookieKey || vendor.name]: signal
|
|
31
|
+
}), vendor.cookieDomain);
|
|
32
|
+
}
|
|
33
|
+
read(vendor) {
|
|
34
|
+
const content = this.cookies.getItem(vendor.cookieName);
|
|
35
|
+
const flags = content ? JSON.parse(content) : {};
|
|
36
|
+
const flag = flags[vendor.cookieKey || vendor.name];
|
|
37
|
+
return flag === true ? 'accepted' : flag === false ? 'denied' : 'undecided';
|
|
38
|
+
}
|
|
39
|
+
setCookie(name, value, domain) {
|
|
40
|
+
if (domain && !window.location.hostname.match(new RegExp(`${domain}$`))) {
|
|
41
|
+
domain = null;
|
|
42
|
+
}
|
|
43
|
+
this.cookies.setItem(name, value, {
|
|
44
|
+
path: '/',
|
|
45
|
+
domain,
|
|
46
|
+
expires: Infinity,
|
|
47
|
+
// Ensure cookie can be read iframe embed
|
|
48
|
+
sameSite: 'None',
|
|
49
|
+
secure: true
|
|
50
|
+
});
|
|
126
51
|
}
|
|
127
|
-
|
|
128
|
-
return arr2;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
132
|
-
if (!o) return;
|
|
133
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
134
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
135
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
136
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
137
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function _nonIterableRest() {
|
|
141
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
142
52
|
}
|
|
143
53
|
|
|
144
|
-
function _slicedToArray(arr, i) {
|
|
145
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
var Persistence = /*#__PURE__*/function () {
|
|
149
|
-
function Persistence(_ref) {
|
|
150
|
-
var cookies = _ref.cookies;
|
|
151
|
-
|
|
152
|
-
_classCallCheck(this, Persistence);
|
|
153
|
-
|
|
154
|
-
this.cookies = cookies;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
_createClass(Persistence, [{
|
|
158
|
-
key: "store",
|
|
159
|
-
value: function store(vendors, signal) {
|
|
160
|
-
var _this = this;
|
|
161
|
-
|
|
162
|
-
var vendorsByCookieName = vendors.reduce(function (sorted, vendor) {
|
|
163
|
-
var cookieName = vendor.cookieName;
|
|
164
|
-
sorted[cookieName] = sorted[cookieName] || [];
|
|
165
|
-
sorted[cookieName].push(vendor);
|
|
166
|
-
return sorted;
|
|
167
|
-
}, {});
|
|
168
|
-
Object.entries(vendorsByCookieName).forEach(function (_ref2) {
|
|
169
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
170
|
-
cookieName = _ref3[0],
|
|
171
|
-
vendors = _ref3[1];
|
|
172
|
-
|
|
173
|
-
var cookieDomain = vendors[0].cookieDomain;
|
|
174
|
-
|
|
175
|
-
_this.setCookie(cookieName, JSON.stringify(vendors.reduce(function (result, vendor) {
|
|
176
|
-
result[vendor.cookieKey || vendor.name] = signal === 'accepted' ? true : signal === 'denied' ? false : signal[vendor.name];
|
|
177
|
-
return result;
|
|
178
|
-
}, {})), cookieDomain);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "update",
|
|
183
|
-
value: function update(vendor, signal) {
|
|
184
|
-
var content = this.cookies.getItem(vendor.cookieName);
|
|
185
|
-
var flags = content ? JSON.parse(content) : {};
|
|
186
|
-
this.setCookie(vendor.cookieName, JSON.stringify(_objectSpread2(_objectSpread2({}, flags), {}, _defineProperty({}, vendor.cookieKey || vendor.name, signal))), vendor.cookieDomain);
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "read",
|
|
190
|
-
value: function read(vendor) {
|
|
191
|
-
var content = this.cookies.getItem(vendor.cookieName);
|
|
192
|
-
var flags = content ? JSON.parse(content) : {};
|
|
193
|
-
var flag = flags[vendor.cookieKey || vendor.name];
|
|
194
|
-
return flag === true ? 'accepted' : flag === false ? 'denied' : 'undecided';
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "setCookie",
|
|
198
|
-
value: function setCookie(name, value, domain) {
|
|
199
|
-
if (domain && !window.location.hostname.match(new RegExp("".concat(domain, "$")))) {
|
|
200
|
-
domain = null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
this.cookies.setItem(name, value, {
|
|
204
|
-
path: '/',
|
|
205
|
-
domain: domain,
|
|
206
|
-
expires: Infinity,
|
|
207
|
-
// Ensure cookie can be read iframe embed
|
|
208
|
-
sameSite: 'None',
|
|
209
|
-
secure: true
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}]);
|
|
213
|
-
|
|
214
|
-
return Persistence;
|
|
215
|
-
}();
|
|
216
|
-
|
|
217
54
|
// https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|
|
218
|
-
|
|
219
|
-
getItem: function
|
|
55
|
+
const cookies = {
|
|
56
|
+
getItem: function (sKey) {
|
|
220
57
|
if (!sKey) {
|
|
221
58
|
return null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line no-useless-escape
|
|
225
61
|
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
|
|
226
62
|
},
|
|
227
|
-
setItem
|
|
228
|
-
document.cookie = setItemCookieString
|
|
63
|
+
setItem(...args) {
|
|
64
|
+
document.cookie = setItemCookieString(...args);
|
|
229
65
|
return true;
|
|
230
66
|
},
|
|
231
|
-
removeItem: function
|
|
67
|
+
removeItem: function (sKey, sPath, sDomain) {
|
|
232
68
|
if (!this.hasItem(sKey)) {
|
|
233
69
|
return false;
|
|
234
70
|
}
|
|
235
|
-
|
|
236
71
|
document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
|
|
237
72
|
return true;
|
|
238
73
|
},
|
|
239
|
-
hasItem: function
|
|
74
|
+
hasItem: function (sKey) {
|
|
240
75
|
if (!sKey) {
|
|
241
76
|
return false;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
77
|
+
}
|
|
78
|
+
// eslint-disable-next-line no-useless-escape
|
|
245
79
|
return new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=").test(document.cookie);
|
|
246
80
|
},
|
|
247
|
-
keys: function
|
|
81
|
+
keys: function () {
|
|
248
82
|
// eslint-disable-next-line no-useless-escape
|
|
249
83
|
var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
|
|
250
|
-
|
|
251
84
|
for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) {
|
|
252
85
|
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);
|
|
253
86
|
}
|
|
254
|
-
|
|
255
87
|
return aKeys;
|
|
256
88
|
}
|
|
257
89
|
};
|
|
@@ -261,496 +93,403 @@ function setItemCookieString(key, value, expiresOrOptions, path, domain, secure)
|
|
|
261
93
|
} else {
|
|
262
94
|
return setItemCookieStringWithOptions(key, value, {
|
|
263
95
|
expires: expiresOrOptions,
|
|
264
|
-
path
|
|
265
|
-
domain
|
|
266
|
-
secure
|
|
96
|
+
path,
|
|
97
|
+
domain,
|
|
98
|
+
secure
|
|
267
99
|
});
|
|
268
100
|
}
|
|
269
101
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
102
|
+
function setItemCookieStringWithOptions(key, value, {
|
|
103
|
+
expires,
|
|
104
|
+
path,
|
|
105
|
+
domain,
|
|
106
|
+
secure,
|
|
107
|
+
sameSite
|
|
108
|
+
}) {
|
|
109
|
+
let expiresPart = "";
|
|
279
110
|
if (expires) {
|
|
280
111
|
switch (expires.constructor) {
|
|
281
112
|
case Number:
|
|
282
113
|
expiresPart = expires === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + expires;
|
|
283
114
|
break;
|
|
284
|
-
|
|
285
115
|
case String:
|
|
286
116
|
expiresPart = "; expires=" + expires;
|
|
287
117
|
break;
|
|
288
|
-
|
|
289
118
|
case Date:
|
|
290
119
|
expiresPart = "; expires=" + expires.toUTCString();
|
|
291
120
|
break;
|
|
292
121
|
}
|
|
293
122
|
}
|
|
294
|
-
|
|
295
123
|
return encodeURIComponent(key) + "=" + encodeURIComponent(value) + expiresPart + (domain ? "; domain=" + domain : "") + (path ? "; path=" + path : "") + (sameSite ? "; SameSite=" + sameSite : "") + (secure ? "; Secure" : "");
|
|
296
124
|
}
|
|
297
125
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
_classCallCheck(this, Consent);
|
|
307
|
-
|
|
308
|
-
this.requestedPromise = new Promise(function (resolve) {
|
|
309
|
-
_this.requestedPromiseResolve = resolve;
|
|
126
|
+
const supportedParadigms = ['external opt-out', 'opt-in', 'lazy opt-in', 'skip'];
|
|
127
|
+
class Consent {
|
|
128
|
+
constructor({
|
|
129
|
+
cookies,
|
|
130
|
+
inEditor
|
|
131
|
+
}) {
|
|
132
|
+
this.requestedPromise = new Promise(resolve => {
|
|
133
|
+
this.requestedPromiseResolve = resolve;
|
|
310
134
|
});
|
|
311
135
|
this.vendors = [];
|
|
312
136
|
this.persistence = new Persistence({
|
|
313
|
-
cookies
|
|
137
|
+
cookies
|
|
314
138
|
});
|
|
315
|
-
this.emitter =
|
|
139
|
+
this.emitter = {
|
|
140
|
+
...BackboneEvents
|
|
141
|
+
};
|
|
316
142
|
this.inEditor = inEditor;
|
|
317
143
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
144
|
+
registerVendor(name, {
|
|
145
|
+
displayName,
|
|
146
|
+
description,
|
|
147
|
+
paradigm,
|
|
148
|
+
cookieName,
|
|
149
|
+
cookieKey,
|
|
150
|
+
cookieDomain
|
|
151
|
+
}) {
|
|
152
|
+
if (this.vendorRegistrationClosed) {
|
|
153
|
+
throw new Error(`Vendor ${name} has been registered after ` + 'registration has been closed.');
|
|
154
|
+
}
|
|
155
|
+
if (!name.match(/^[a-z0-9-_]+$/i)) {
|
|
156
|
+
throw new Error(`Invalid vendor name '${name}'. ` + 'Only letters, numbers, hyphens and underscores are allowed.');
|
|
157
|
+
}
|
|
158
|
+
if (supportedParadigms.indexOf(paradigm) < 0) {
|
|
159
|
+
throw new Error(`unknown paradigm ${paradigm}`);
|
|
160
|
+
}
|
|
161
|
+
this.vendors.push({
|
|
162
|
+
displayName,
|
|
163
|
+
description,
|
|
164
|
+
name,
|
|
165
|
+
paradigm,
|
|
166
|
+
cookieName: cookieName || 'pageflow_consent',
|
|
167
|
+
cookieKey,
|
|
168
|
+
cookieDomain
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
closeVendorRegistration() {
|
|
172
|
+
this.vendorRegistrationClosed = true;
|
|
173
|
+
if (!this.getUndecidedOptInVendors().length) {
|
|
174
|
+
this.triggerDecisionEvents();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const vendors = this.getRequestedVendors();
|
|
178
|
+
this.requestedPromiseResolve({
|
|
179
|
+
vendors: this.withState(vendors),
|
|
180
|
+
acceptAll: () => {
|
|
181
|
+
this.persistence.store(vendors, 'accepted');
|
|
182
|
+
this.triggerDecisionEvents();
|
|
183
|
+
},
|
|
184
|
+
denyAll: () => {
|
|
185
|
+
this.persistence.store(vendors, 'denied');
|
|
186
|
+
this.triggerDecisionEvents();
|
|
187
|
+
},
|
|
188
|
+
save: vendorConsent => {
|
|
189
|
+
this.persistence.store(vendors, vendorConsent);
|
|
359
190
|
this.triggerDecisionEvents();
|
|
360
|
-
return;
|
|
361
191
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
relevantVendors({
|
|
195
|
+
include: additionalVendorNames
|
|
196
|
+
} = {}) {
|
|
197
|
+
return this.withState(this.vendors.filter(vendor => {
|
|
198
|
+
return (additionalVendorNames === null || additionalVendorNames === void 0 ? void 0 : additionalVendorNames.includes(vendor.name)) || vendor.paradigm === 'opt-in' || vendor.paradigm === 'external opt-out' || vendor.paradigm === 'lazy opt-in' && this.persistence.read(vendor) !== 'undecided';
|
|
199
|
+
}), {
|
|
200
|
+
applyDefaults: true
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
require(vendorName) {
|
|
204
|
+
if (this.inEditor) {
|
|
205
|
+
return Promise.resolve('fulfilled');
|
|
206
|
+
}
|
|
207
|
+
const vendor = this.findVendor(vendorName, 'require consent for');
|
|
208
|
+
switch (vendor.paradigm) {
|
|
209
|
+
case 'opt-in':
|
|
210
|
+
case 'lazy opt-in':
|
|
211
|
+
if (this.getUndecidedOptInVendors().length) {
|
|
212
|
+
return new Promise(resolve => {
|
|
213
|
+
this.emitter.once(`${vendor.name}:accepted`, () => resolve('fulfilled'));
|
|
214
|
+
this.emitter.once(`${vendor.name}:denied`, () => resolve('failed'));
|
|
215
|
+
});
|
|
380
216
|
}
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
}, {
|
|
384
|
-
key: "relevantVendors",
|
|
385
|
-
value: function relevantVendors() {
|
|
386
|
-
var _this3 = this;
|
|
387
|
-
|
|
388
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
389
|
-
additionalVendorNames = _ref3.include;
|
|
390
|
-
|
|
391
|
-
return this.withState(this.vendors.filter(function (vendor) {
|
|
392
|
-
return (additionalVendorNames === null || additionalVendorNames === void 0 ? void 0 : additionalVendorNames.includes(vendor.name)) || vendor.paradigm === 'opt-in' || vendor.paradigm === 'external opt-out' || vendor.paradigm === 'lazy opt-in' && _this3.persistence.read(vendor) !== 'undecided';
|
|
393
|
-
}), {
|
|
394
|
-
applyDefaults: true
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
}, {
|
|
398
|
-
key: "require",
|
|
399
|
-
value: function require(vendorName) {
|
|
400
|
-
var _this4 = this;
|
|
401
|
-
|
|
402
|
-
if (this.inEditor) {
|
|
403
|
-
return Promise.resolve('fulfilled');
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
var vendor = this.findVendor(vendorName, 'require consent for');
|
|
407
|
-
|
|
408
|
-
switch (vendor.paradigm) {
|
|
409
|
-
case 'opt-in':
|
|
410
|
-
case 'lazy opt-in':
|
|
411
|
-
if (this.getUndecidedOptInVendors().length) {
|
|
412
|
-
return new Promise(function (resolve) {
|
|
413
|
-
_this4.emitter.once("".concat(vendor.name, ":accepted"), function () {
|
|
414
|
-
return resolve('fulfilled');
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
_this4.emitter.once("".concat(vendor.name, ":denied"), function () {
|
|
418
|
-
return resolve('failed');
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (this.persistence.read(vendor) === 'accepted') {
|
|
424
|
-
return Promise.resolve('fulfilled');
|
|
425
|
-
} else {
|
|
426
|
-
return Promise.resolve('failed');
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
case 'external opt-out':
|
|
430
|
-
if (this.persistence.read(vendor) === 'denied') {
|
|
431
|
-
return Promise.resolve('failed');
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return Promise.resolve('fulfilled');
|
|
435
|
-
|
|
436
|
-
case 'skip':
|
|
217
|
+
if (this.persistence.read(vendor) === 'accepted') {
|
|
437
218
|
return Promise.resolve('fulfilled');
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}, {
|
|
445
|
-
key: "requireAccepted",
|
|
446
|
-
value: function requireAccepted(vendorName) {
|
|
447
|
-
var _this5 = this;
|
|
448
|
-
|
|
449
|
-
if (this.inEditor) {
|
|
450
|
-
return Promise.resolve('fulfilled');
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
var vendor = this.findVendor(vendorName, 'require consent for');
|
|
454
|
-
|
|
455
|
-
if (vendor.paradigm === 'opt-in' || vendor.paradigm === 'lazy opt-in') {
|
|
456
|
-
if (this.getUndecidedOptInVendors().length || this.persistence.read(vendor) !== 'accepted') {
|
|
457
|
-
return new Promise(function (resolve) {
|
|
458
|
-
_this5.emitter.once("".concat(vendor.name, ":accepted"), function () {
|
|
459
|
-
return resolve('fulfilled');
|
|
460
|
-
});
|
|
461
|
-
});
|
|
219
|
+
} else {
|
|
220
|
+
return Promise.resolve('failed');
|
|
221
|
+
}
|
|
222
|
+
case 'external opt-out':
|
|
223
|
+
if (this.persistence.read(vendor) === 'denied') {
|
|
224
|
+
return Promise.resolve('failed');
|
|
462
225
|
}
|
|
463
|
-
|
|
464
226
|
return Promise.resolve('fulfilled');
|
|
465
|
-
|
|
466
|
-
return
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
key: "requested",
|
|
471
|
-
value: function requested() {
|
|
472
|
-
return this.requestedPromise;
|
|
473
|
-
}
|
|
474
|
-
}, {
|
|
475
|
-
key: "accept",
|
|
476
|
-
value: function accept(vendorName) {
|
|
477
|
-
var vendor = this.findVendor(vendorName, 'accept');
|
|
478
|
-
this.persistence.update(vendor, true);
|
|
479
|
-
this.emitter.trigger("".concat(vendor.name, ":accepted"));
|
|
480
|
-
}
|
|
481
|
-
}, {
|
|
482
|
-
key: "deny",
|
|
483
|
-
value: function deny(vendorName) {
|
|
484
|
-
var vendor = this.findVendor(vendorName, 'deny');
|
|
485
|
-
this.persistence.update(vendor, false);
|
|
486
|
-
}
|
|
487
|
-
}, {
|
|
488
|
-
key: "getRequestedVendors",
|
|
489
|
-
value: function getRequestedVendors() {
|
|
490
|
-
return this.vendors.filter(function (vendor) {
|
|
491
|
-
return vendor.paradigm !== 'skip';
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}, {
|
|
495
|
-
key: "getUndecidedOptInVendors",
|
|
496
|
-
value: function getUndecidedOptInVendors() {
|
|
497
|
-
var _this6 = this;
|
|
498
|
-
|
|
499
|
-
return this.vendors.filter(function (vendor) {
|
|
500
|
-
return vendor.paradigm === 'opt-in' && _this6.persistence.read(vendor) === 'undecided';
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
}, {
|
|
504
|
-
key: "triggerDecisionEvents",
|
|
505
|
-
value: function triggerDecisionEvents() {
|
|
506
|
-
var _this7 = this;
|
|
507
|
-
|
|
508
|
-
this.vendors.filter(function (vendor) {
|
|
509
|
-
return vendor.paradigm !== 'skip';
|
|
510
|
-
}).forEach(function (vendor) {
|
|
511
|
-
_this7.emitter.trigger("".concat(vendor.name, ":").concat(_this7.persistence.read(vendor)));
|
|
512
|
-
});
|
|
227
|
+
case 'skip':
|
|
228
|
+
return Promise.resolve('fulfilled');
|
|
229
|
+
default:
|
|
230
|
+
// should not be used
|
|
231
|
+
return null;
|
|
513
232
|
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return vendor.name === vendorName;
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
if (!vendor) {
|
|
522
|
-
throw new Error("Cannot ".concat(actionForErrorMessage, " unknown vendor \"").concat(vendorName, "\". ") + 'Consider using consent.registerVendor.');
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return vendor;
|
|
233
|
+
}
|
|
234
|
+
requireAccepted(vendorName) {
|
|
235
|
+
if (this.inEditor) {
|
|
236
|
+
return Promise.resolve('fulfilled');
|
|
526
237
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
533
|
-
applyDefaults = _ref4.applyDefaults;
|
|
534
|
-
|
|
535
|
-
return vendors.map(function (vendor) {
|
|
536
|
-
var state = _this8.persistence.read(vendor);
|
|
537
|
-
|
|
538
|
-
return _objectSpread2(_objectSpread2({}, vendor), {}, {
|
|
539
|
-
state: state === 'undecided' && applyDefaults ? _this8.getDefaultState(vendor) : state
|
|
238
|
+
const vendor = this.findVendor(vendorName, 'require consent for');
|
|
239
|
+
if (vendor.paradigm === 'opt-in' || vendor.paradigm === 'lazy opt-in') {
|
|
240
|
+
if (this.getUndecidedOptInVendors().length || this.persistence.read(vendor) !== 'accepted') {
|
|
241
|
+
return new Promise(resolve => {
|
|
242
|
+
this.emitter.once(`${vendor.name}:accepted`, () => resolve('fulfilled'));
|
|
540
243
|
});
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
}, {
|
|
544
|
-
key: "getDefaultState",
|
|
545
|
-
value: function getDefaultState(vendor) {
|
|
546
|
-
if (vendor.paradigm === 'external opt-out') {
|
|
547
|
-
return 'accepted';
|
|
548
244
|
}
|
|
549
|
-
|
|
550
|
-
|
|
245
|
+
return Promise.resolve('fulfilled');
|
|
246
|
+
} else {
|
|
247
|
+
return this.require(vendorName);
|
|
551
248
|
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
249
|
+
}
|
|
250
|
+
requested() {
|
|
251
|
+
return this.requestedPromise;
|
|
252
|
+
}
|
|
253
|
+
accept(vendorName) {
|
|
254
|
+
const vendor = this.findVendor(vendorName, 'accept');
|
|
255
|
+
this.persistence.update(vendor, true);
|
|
256
|
+
this.emitter.trigger(`${vendor.name}:accepted`);
|
|
257
|
+
}
|
|
258
|
+
deny(vendorName) {
|
|
259
|
+
const vendor = this.findVendor(vendorName, 'deny');
|
|
260
|
+
this.persistence.update(vendor, false);
|
|
261
|
+
}
|
|
262
|
+
getRequestedVendors() {
|
|
263
|
+
return this.vendors.filter(vendor => {
|
|
264
|
+
return vendor.paradigm !== 'skip';
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
getUndecidedOptInVendors() {
|
|
268
|
+
return this.vendors.filter(vendor => {
|
|
269
|
+
return vendor.paradigm === 'opt-in' && this.persistence.read(vendor) === 'undecided';
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
triggerDecisionEvents() {
|
|
273
|
+
this.vendors.filter(vendor => {
|
|
274
|
+
return vendor.paradigm !== 'skip';
|
|
275
|
+
}).forEach(vendor => {
|
|
276
|
+
this.emitter.trigger(`${vendor.name}:${this.persistence.read(vendor)}`);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
findVendor(vendorName, actionForErrorMessage) {
|
|
280
|
+
const vendor = this.vendors.find(vendor => vendor.name === vendorName);
|
|
281
|
+
if (!vendor) {
|
|
282
|
+
throw new Error(`Cannot ${actionForErrorMessage} unknown vendor "${vendorName}". ` + 'Consider using consent.registerVendor.');
|
|
283
|
+
}
|
|
284
|
+
return vendor;
|
|
285
|
+
}
|
|
286
|
+
withState(vendors, {
|
|
287
|
+
applyDefaults
|
|
288
|
+
} = {}) {
|
|
289
|
+
return vendors.map(vendor => {
|
|
290
|
+
const state = this.persistence.read(vendor);
|
|
291
|
+
return {
|
|
292
|
+
...vendor,
|
|
293
|
+
state: state === 'undecided' && applyDefaults ? this.getDefaultState(vendor) : state
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
getDefaultState(vendor) {
|
|
298
|
+
if (vendor.paradigm === 'external opt-out') {
|
|
299
|
+
return 'accepted';
|
|
300
|
+
}
|
|
301
|
+
return 'undecided';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
557
304
|
Consent.create = function () {
|
|
558
|
-
|
|
305
|
+
const inEditor = typeof PAGEFLOW_EDITOR !== 'undefined' && PAGEFLOW_EDITOR;
|
|
559
306
|
return new Consent({
|
|
560
|
-
cookies
|
|
561
|
-
inEditor
|
|
307
|
+
cookies,
|
|
308
|
+
inEditor
|
|
562
309
|
});
|
|
563
310
|
};
|
|
564
311
|
|
|
565
|
-
|
|
312
|
+
const log = function (text, options) {
|
|
566
313
|
if (window.console && (debugMode() || options && options.force)) {
|
|
567
314
|
window.console.log(text);
|
|
568
315
|
}
|
|
569
316
|
};
|
|
570
|
-
|
|
317
|
+
const debugMode = function () {
|
|
571
318
|
return window.location.href.indexOf('debug=true') >= 0;
|
|
572
319
|
};
|
|
573
320
|
|
|
574
|
-
|
|
321
|
+
const state = typeof window !== 'undefined' && window.pageflow || {};
|
|
575
322
|
|
|
576
|
-
|
|
323
|
+
const assetUrls = state.assetUrls || {};
|
|
577
324
|
|
|
578
|
-
|
|
325
|
+
const events = Object.assign({}, BackboneEvents);
|
|
579
326
|
|
|
580
327
|
/**
|
|
581
328
|
* Detect browser via user agent. Use only if feature detection is not
|
|
582
329
|
* an option.
|
|
583
330
|
*/
|
|
584
|
-
|
|
331
|
+
const Agent = function (userAgent) {
|
|
585
332
|
return {
|
|
586
|
-
matchesSilk: function
|
|
333
|
+
matchesSilk: function () {
|
|
587
334
|
return matches(/\bSilk\b/);
|
|
588
335
|
},
|
|
589
|
-
matchesDesktopSafari: function
|
|
336
|
+
matchesDesktopSafari: function (options) {
|
|
590
337
|
if (options) {
|
|
591
338
|
return this.matchesSafari() && !this.matchesMobilePlatform() && matchesMinVersion(/Version\/(\d+)/i, options.minVersion);
|
|
592
339
|
} else {
|
|
593
340
|
return this.matchesSafari() && !this.matchesMobilePlatform();
|
|
594
341
|
}
|
|
595
342
|
},
|
|
596
|
-
matchesDesktopSafari9: function
|
|
343
|
+
matchesDesktopSafari9: function () {
|
|
597
344
|
return this.matchesSafari9() && !this.matchesMobilePlatform();
|
|
598
345
|
},
|
|
599
|
-
matchesDesktopSafari10: function
|
|
346
|
+
matchesDesktopSafari10: function () {
|
|
600
347
|
return this.matchesSafari10() && !this.matchesMobilePlatform();
|
|
601
348
|
},
|
|
602
|
-
matchesSafari9: function
|
|
349
|
+
matchesSafari9: function () {
|
|
603
350
|
return this.matchesSafari() && matches(/Version\/9/i);
|
|
604
351
|
},
|
|
605
|
-
matchesSafari10: function
|
|
352
|
+
matchesSafari10: function () {
|
|
606
353
|
return this.matchesSafari() && matches(/Version\/10/i);
|
|
607
354
|
},
|
|
608
|
-
matchesSafari11: function
|
|
355
|
+
matchesSafari11: function () {
|
|
609
356
|
return this.matchesSafari() && matches(/Version\/11/i);
|
|
610
357
|
},
|
|
611
|
-
matchesSafari11AndAbove: function
|
|
358
|
+
matchesSafari11AndAbove: function () {
|
|
612
359
|
return this.matchesSafari() && matchesMinVersion(/Version\/(\d+)/i, 11);
|
|
613
360
|
},
|
|
614
|
-
matchesSafari: function
|
|
361
|
+
matchesSafari: function () {
|
|
615
362
|
// - Chrome also reports to be a Safari
|
|
616
363
|
// - Safari does not report to be a Chrome
|
|
617
364
|
// - Edge also reports to be a Safari, but also reports to be Chrome
|
|
618
365
|
return matches(/Safari\//i) && !matches(/Chrome/i);
|
|
619
366
|
},
|
|
620
|
-
|
|
621
367
|
/**
|
|
622
368
|
* Returns true on iOS Safari.
|
|
623
369
|
* @return {boolean}
|
|
624
370
|
*/
|
|
625
|
-
matchesMobileSafari: function
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
371
|
+
matchesMobileSafari: function ({
|
|
372
|
+
osVersions
|
|
373
|
+
} = {}) {
|
|
374
|
+
var deviceMatchers = [/iPod/i, /iPad/i, /iPhone/i];
|
|
375
|
+
if (osVersions) {
|
|
376
|
+
return deviceMatchers.some(matcher => userAgent.match(matcher)) && osVersions.some(osVersion => userAgent.includes(osVersion.replace('.', '_')));
|
|
377
|
+
} else {
|
|
378
|
+
return matchesiPadSafari13AndAbove() || deviceMatchers.some(matcher => userAgent.match(matcher)) && !window.MSStream // IE exclusion from being detected as an iOS device;
|
|
379
|
+
;
|
|
380
|
+
}
|
|
631
381
|
},
|
|
632
|
-
|
|
633
382
|
/**
|
|
634
383
|
* Returns true on Android.
|
|
635
384
|
* @return {boolean}
|
|
636
385
|
*/
|
|
637
|
-
matchesAndroid: function
|
|
386
|
+
matchesAndroid: function () {
|
|
638
387
|
return matches(/Android/i);
|
|
639
388
|
},
|
|
640
|
-
|
|
641
389
|
/**
|
|
642
390
|
* Returns true on iOS or Android.
|
|
643
391
|
* @return {boolean}
|
|
644
392
|
*/
|
|
645
|
-
matchesMobilePlatform: function
|
|
393
|
+
matchesMobilePlatform: function () {
|
|
646
394
|
var matchers = [/iPod/i, /iPad/i, /iPhone/i, /Android/i, /Silk/i, /IEMobile/i];
|
|
647
395
|
return matchers.some(function (matcher) {
|
|
648
396
|
return userAgent.match(matcher);
|
|
649
397
|
}) || matchesiPadSafari13AndAbove();
|
|
650
398
|
},
|
|
651
|
-
|
|
652
399
|
/**
|
|
653
400
|
* Returns true on Internet Explorser version 9, 10 and 11.
|
|
654
401
|
* @return {boolean}
|
|
655
402
|
*/
|
|
656
|
-
matchesIEUpTo11: function
|
|
403
|
+
matchesIEUpTo11: function () {
|
|
657
404
|
return userAgent.match(/Trident\//);
|
|
658
405
|
},
|
|
659
|
-
|
|
660
406
|
/**
|
|
661
407
|
* Returns true in InApp browser of Facebook app.
|
|
662
408
|
* @return {boolean}
|
|
663
409
|
*/
|
|
664
|
-
matchesFacebookInAppBrowser: function
|
|
410
|
+
matchesFacebookInAppBrowser: function () {
|
|
665
411
|
return userAgent.match(/FBAN/) && userAgent.match(/FBAV/);
|
|
666
412
|
},
|
|
667
|
-
matchesDesktopChrome: function
|
|
413
|
+
matchesDesktopChrome: function (options) {
|
|
668
414
|
if (options) {
|
|
669
415
|
return this.matchesChrome() && !this.matchesMobilePlatform() && matchesMinVersion(/Chrome\/(\d+)/i, options.minVersion);
|
|
670
416
|
} else {
|
|
671
417
|
return this.matchesChrome() && !this.matchesMobilePlatform();
|
|
672
418
|
}
|
|
673
419
|
},
|
|
674
|
-
matchesDesktopFirefox: function
|
|
420
|
+
matchesDesktopFirefox: function (options) {
|
|
675
421
|
if (options) {
|
|
676
422
|
return this.matchesFirefox() && !this.matchesMobilePlatform() && matchesMinVersion(/Firefox\/(\d+)/i, options.minVersion);
|
|
677
423
|
} else {
|
|
678
424
|
return this.matchesFirefox() && !this.matchesMobilePlatform();
|
|
679
425
|
}
|
|
680
426
|
},
|
|
681
|
-
matchesDesktopEdge: function
|
|
427
|
+
matchesDesktopEdge: function (options) {
|
|
682
428
|
if (options) {
|
|
683
429
|
return this.matchesEdge() && !this.matchesMobilePlatform() && matchesMinVersion(/Edg\/(\d+)/i, options.minVersion);
|
|
684
430
|
} else {
|
|
685
431
|
return this.matchesEdge() && !this.matchesMobilePlatform();
|
|
686
432
|
}
|
|
687
433
|
},
|
|
688
|
-
|
|
689
434
|
/**
|
|
690
435
|
* Returns true on Google Chrome.
|
|
691
436
|
* @return {boolean}
|
|
692
437
|
*/
|
|
693
|
-
matchesChrome: function
|
|
438
|
+
matchesChrome: function () {
|
|
694
439
|
// - Edge also reports to be a Chrome
|
|
695
440
|
return matches(/Chrome\//i) && !matches(/Edg/i);
|
|
696
441
|
},
|
|
697
|
-
|
|
698
442
|
/**
|
|
699
443
|
* Returns true on Firefox.
|
|
700
444
|
* @return {boolean}
|
|
701
445
|
*/
|
|
702
|
-
matchesFirefox: function
|
|
446
|
+
matchesFirefox: function () {
|
|
703
447
|
return matches(/Firefox\//i) && !matches(/Seamonkey/i);
|
|
704
448
|
},
|
|
705
|
-
|
|
706
449
|
/**
|
|
707
450
|
* Returns true on Microsoft Edge.
|
|
708
451
|
* @return {boolean}
|
|
709
452
|
*/
|
|
710
|
-
matchesEdge: function
|
|
453
|
+
matchesEdge: function () {
|
|
711
454
|
return matches(/Edg\//i);
|
|
712
455
|
}
|
|
713
456
|
};
|
|
714
|
-
|
|
715
457
|
function matches(exp) {
|
|
716
458
|
return !!userAgent.match(exp);
|
|
717
459
|
}
|
|
718
|
-
|
|
719
460
|
function matchesMinVersion(exp, version) {
|
|
720
461
|
var match = userAgent.match(exp);
|
|
721
462
|
return match && match[1] && parseInt(match[1], 10) >= version;
|
|
722
|
-
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
//After ios13 update, iPad reports the same user string
|
|
723
466
|
//as Safari on Dekstop MacOS.
|
|
724
467
|
//At the time of this writing there are no other devices
|
|
725
468
|
//with multi-touch support other than IOS/iPadOS
|
|
726
469
|
//See: https://stackoverflow.com/a/58064481
|
|
727
|
-
|
|
728
|
-
|
|
729
470
|
function matchesiPadSafari13AndAbove() {
|
|
730
471
|
return agent.matchesSafari() && navigator.maxTouchPoints > 1 && navigator.platform === 'MacIntel';
|
|
731
472
|
}
|
|
732
473
|
};
|
|
733
|
-
|
|
474
|
+
const agent = new Agent(typeof navigator !== 'undefined' ? navigator.userAgent : 'ssr');
|
|
734
475
|
|
|
735
476
|
/**
|
|
736
477
|
* Browser feature detection.
|
|
737
478
|
*
|
|
738
479
|
* @since 0.9
|
|
739
480
|
*/
|
|
740
|
-
|
|
741
|
-
var browser = function () {
|
|
481
|
+
const browser = function () {
|
|
742
482
|
var tests = {},
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
483
|
+
results = {},
|
|
484
|
+
featureDetectionComplete = false;
|
|
485
|
+
let readyPromiseResolve;
|
|
486
|
+
let readyPromise = new Promise(function (resolve, reject) {
|
|
747
487
|
readyPromiseResolve = resolve;
|
|
748
488
|
});
|
|
749
489
|
return {
|
|
750
490
|
off: {},
|
|
751
491
|
on: {},
|
|
752
492
|
unset: {},
|
|
753
|
-
|
|
754
493
|
/**
|
|
755
494
|
* Add a feature test.
|
|
756
495
|
*
|
|
@@ -759,33 +498,28 @@ var browser = function () {
|
|
|
759
498
|
* `false` or a promise that resolves to `true` or `false`.
|
|
760
499
|
* @memberof pageflow.browser
|
|
761
500
|
*/
|
|
762
|
-
feature: function
|
|
501
|
+
feature: function (name, test) {
|
|
763
502
|
var s = name.replace(/ /g, '_');
|
|
764
|
-
|
|
765
503
|
this.off[s] = function () {
|
|
766
504
|
window.localStorage['override ' + name] = 'off';
|
|
767
505
|
log('Feature off: ' + name, {
|
|
768
506
|
force: true
|
|
769
507
|
});
|
|
770
508
|
};
|
|
771
|
-
|
|
772
509
|
this.on[s] = function () {
|
|
773
510
|
window.localStorage['override ' + name] = 'on';
|
|
774
511
|
log('Feature on: ' + name, {
|
|
775
512
|
force: true
|
|
776
513
|
});
|
|
777
514
|
};
|
|
778
|
-
|
|
779
515
|
this.unset[s] = function () {
|
|
780
516
|
window.localStorage.removeItem('override ' + name);
|
|
781
517
|
log('Feature unset: ' + name, {
|
|
782
518
|
force: true
|
|
783
519
|
});
|
|
784
520
|
};
|
|
785
|
-
|
|
786
521
|
tests[name] = test;
|
|
787
522
|
},
|
|
788
|
-
|
|
789
523
|
/**
|
|
790
524
|
* Check whether the browser has a specific feature. This method
|
|
791
525
|
* may only be called after the `#ready` promise is resolved.
|
|
@@ -794,37 +528,31 @@ var browser = function () {
|
|
|
794
528
|
* @return [Boolean]
|
|
795
529
|
* @memberof pageflow.browser
|
|
796
530
|
*/
|
|
797
|
-
has: function
|
|
531
|
+
has: function (name) {
|
|
798
532
|
if (!featureDetectionComplete) {
|
|
799
533
|
throw 'Feature detection has not finished yet.';
|
|
800
534
|
}
|
|
801
|
-
|
|
802
535
|
if (results[name] === undefined) {
|
|
803
536
|
throw 'Unknown feature "' + name + '".';
|
|
804
537
|
}
|
|
805
|
-
|
|
806
538
|
return results[name];
|
|
807
539
|
},
|
|
808
|
-
|
|
809
540
|
/**
|
|
810
541
|
* A promise that is resolved once feature detection has finished.
|
|
811
542
|
*
|
|
812
543
|
* @return Promise
|
|
813
544
|
* @memberof pageflow.browser
|
|
814
545
|
*/
|
|
815
|
-
ready: function
|
|
546
|
+
ready: function () {
|
|
816
547
|
return readyPromise;
|
|
817
548
|
},
|
|
818
|
-
|
|
819
549
|
/** @api private */
|
|
820
|
-
detectFeatures: function
|
|
550
|
+
detectFeatures: function () {
|
|
821
551
|
var promises = {};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
var runTest = function runTest() {
|
|
552
|
+
var asyncHas = function (name) {
|
|
553
|
+
var runTest = function () {
|
|
825
554
|
var value,
|
|
826
|
-
|
|
827
|
-
|
|
555
|
+
underscoredName = name.replace(/ /g, '_');
|
|
828
556
|
if (debugMode() && location.href.indexOf('&has=' + underscoredName) >= 0) {
|
|
829
557
|
value = location.href.indexOf('&has=' + underscoredName + '_on') >= 0;
|
|
830
558
|
log('FEATURE OVERRIDDEN ' + name + ': ' + value, {
|
|
@@ -841,27 +569,22 @@ var browser = function () {
|
|
|
841
569
|
return tests[name](asyncHas);
|
|
842
570
|
}
|
|
843
571
|
};
|
|
844
|
-
|
|
845
|
-
promises[name] = promises[name] || Promise.all([runTest()]).then(function (a) {
|
|
572
|
+
promises[name] = promises[name] || Promise.all([runTest()]).then(a => {
|
|
846
573
|
return a[0];
|
|
847
574
|
});
|
|
848
575
|
return promises[name];
|
|
849
576
|
};
|
|
850
|
-
|
|
851
577
|
asyncHas.not = function (name) {
|
|
852
578
|
return asyncHas(name).then(function (result) {
|
|
853
579
|
return !result;
|
|
854
580
|
});
|
|
855
581
|
};
|
|
856
|
-
|
|
857
|
-
|
|
582
|
+
asyncHas.all = function /* arguments */
|
|
583
|
+
() {
|
|
858
584
|
return Promise.all(arguments).then(function (results) {
|
|
859
|
-
return results.every(
|
|
860
|
-
return result;
|
|
861
|
-
});
|
|
585
|
+
return results.every(result => result);
|
|
862
586
|
});
|
|
863
587
|
};
|
|
864
|
-
|
|
865
588
|
Promise.all(Object.keys(tests).map(function (name) {
|
|
866
589
|
return asyncHas(name).then(function (result) {
|
|
867
590
|
var cssClassName = name.replace(/ /g, '_');
|
|
@@ -869,7 +592,7 @@ var browser = function () {
|
|
|
869
592
|
document.body.classList.toggle('has_no_' + cssClassName, !result);
|
|
870
593
|
results[name] = !!result;
|
|
871
594
|
});
|
|
872
|
-
})).then(
|
|
595
|
+
})).then(() => {
|
|
873
596
|
featureDetectionComplete = true;
|
|
874
597
|
readyPromiseResolve();
|
|
875
598
|
});
|
|
@@ -878,32 +601,36 @@ var browser = function () {
|
|
|
878
601
|
};
|
|
879
602
|
}();
|
|
880
603
|
|
|
604
|
+
browser.feature('broken ogg support', function () {
|
|
605
|
+
// ogg is not supported on iOS < 18.4 and broken on iOS 18.4
|
|
606
|
+
return agent.matchesMobileSafari();
|
|
607
|
+
});
|
|
608
|
+
|
|
881
609
|
browser.feature('autoplay support', function (has) {
|
|
882
610
|
return !agent.matchesSafari11AndAbove() && !agent.matchesMobilePlatform();
|
|
883
611
|
});
|
|
884
612
|
|
|
613
|
+
// See https://developer.mozilla.org/de/docs/Web/CSS/CSS_Animations/Detecting_CSS_animation_support
|
|
614
|
+
|
|
885
615
|
browser.feature('css animations', function () {
|
|
886
616
|
var prefixes = ['Webkit', 'Moz', 'O', 'ms', 'Khtml'],
|
|
887
|
-
|
|
888
|
-
|
|
617
|
+
elm = document.createElement('div');
|
|
889
618
|
if (elm.style.animationName !== undefined) {
|
|
890
619
|
return true;
|
|
891
620
|
}
|
|
892
|
-
|
|
893
621
|
for (var i = 0; i < prefixes.length; i++) {
|
|
894
622
|
if (elm.style[prefixes[i] + 'AnimationName'] !== undefined) {
|
|
895
623
|
return true;
|
|
896
624
|
}
|
|
897
625
|
}
|
|
898
|
-
|
|
899
626
|
return false;
|
|
900
627
|
});
|
|
901
628
|
|
|
629
|
+
// Facebook app displays a toolbar at the bottom of the screen on iOS
|
|
902
630
|
// phone which hides parts of the browser viewport. Normally this is
|
|
903
631
|
// hidden once the user scrolls, but since there is no native
|
|
904
632
|
// scrolling in Pageflow, the bar stays and hides page elements like
|
|
905
633
|
// the slim player controls.
|
|
906
|
-
|
|
907
634
|
browser.feature('facebook toolbar', function (has) {
|
|
908
635
|
return has.all(has('iphone platform'), agent.matchesFacebookInAppBrowser());
|
|
909
636
|
});
|
|
@@ -943,10 +670,8 @@ browser.feature('request animation frame support', function () {
|
|
|
943
670
|
});
|
|
944
671
|
|
|
945
672
|
browser.feature('touch support', function () {
|
|
946
|
-
return 'ontouchstart' in window ||
|
|
947
|
-
/*
|
|
948
|
-
window.DocumentTouch && document instanceof window.DocumentTouch ||
|
|
949
|
-
/* > 0 on IE touch devices */
|
|
673
|
+
return 'ontouchstart' in window || /* Firefox on android */
|
|
674
|
+
window.DocumentTouch && document instanceof window.DocumentTouch || /* > 0 on IE touch devices */
|
|
950
675
|
navigator.maxTouchPoints;
|
|
951
676
|
});
|
|
952
677
|
|
|
@@ -976,6 +701,16 @@ browser.feature('mse and native hls support', function (has) {
|
|
|
976
701
|
browser.feature('native video player', function (has) {
|
|
977
702
|
return has('iphone platform');
|
|
978
703
|
});
|
|
704
|
+
browser.feature('video scaling bug fixed by load', function (has) {
|
|
705
|
+
// When reusing video elements for videos with different
|
|
706
|
+
// resolutions, Safari gets confused and scales videos incorrectly -
|
|
707
|
+
// drawing them to only cover a part of the element. This appears to
|
|
708
|
+
// not happen when the video is loaded or played immediately after
|
|
709
|
+
// changing the source. No longer reproducible in iOS 17.4.
|
|
710
|
+
return agent.matchesMobileSafari({
|
|
711
|
+
osVersions: ['17.0', '17.1', '17.2', '17.3']
|
|
712
|
+
});
|
|
713
|
+
});
|
|
979
714
|
|
|
980
715
|
browser.feature('volume control support', function (has) {
|
|
981
716
|
return has.not('ios platform');
|
|
@@ -995,84 +730,69 @@ browser.Agent = Agent;
|
|
|
995
730
|
* @alias pageflow.features
|
|
996
731
|
* @since 0.9
|
|
997
732
|
*/
|
|
998
|
-
|
|
999
|
-
var Features = /*#__PURE__*/function () {
|
|
733
|
+
class Features {
|
|
1000
734
|
/** @lends pageflow.features */
|
|
1001
735
|
|
|
1002
736
|
/** @api private */
|
|
1003
|
-
|
|
1004
|
-
_classCallCheck(this, Features);
|
|
1005
|
-
|
|
737
|
+
constructor() {
|
|
1006
738
|
this.registry = {};
|
|
1007
739
|
this.enabledFeatureNames = [];
|
|
1008
740
|
}
|
|
741
|
+
|
|
1009
742
|
/**
|
|
1010
743
|
* `pageflow.features` has been renamed to `pageflow.browser`.
|
|
1011
744
|
* @deprecated
|
|
1012
745
|
*/
|
|
746
|
+
has( /* arguments */
|
|
747
|
+
) {
|
|
748
|
+
return browser.has.apply(browser, arguments);
|
|
749
|
+
}
|
|
1013
750
|
|
|
751
|
+
/**
|
|
752
|
+
* Register a function to configure a feature when it is active.
|
|
753
|
+
*
|
|
754
|
+
* @param {String} scope - Name of the scope the passed function
|
|
755
|
+
* shall be called in.
|
|
756
|
+
* @param name [String] Name of the feature
|
|
757
|
+
* @param fn [Function] Function to call when the given feature
|
|
758
|
+
* is activate.
|
|
759
|
+
*/
|
|
760
|
+
register(scope, name, fn) {
|
|
761
|
+
this.registry[scope] = this.registry[scope] || {};
|
|
762
|
+
this.registry[scope][name] = this.registry[scope][name] || [];
|
|
763
|
+
this.registry[scope][name].push(fn);
|
|
764
|
+
}
|
|
1014
765
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
* shall be called in.
|
|
1025
|
-
* @param name [String] Name of the feature
|
|
1026
|
-
* @param fn [Function] Function to call when the given feature
|
|
1027
|
-
* is activate.
|
|
1028
|
-
*/
|
|
1029
|
-
|
|
1030
|
-
}, {
|
|
1031
|
-
key: "register",
|
|
1032
|
-
value: function register(scope, name, fn) {
|
|
1033
|
-
this.registry[scope] = this.registry[scope] || {};
|
|
1034
|
-
this.registry[scope][name] = this.registry[scope][name] || [];
|
|
1035
|
-
this.registry[scope][name].push(fn);
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Check if a feature as been enabled.
|
|
1039
|
-
*
|
|
1040
|
-
* @param name [String]
|
|
1041
|
-
* @return [Boolean]
|
|
1042
|
-
*/
|
|
1043
|
-
|
|
1044
|
-
}, {
|
|
1045
|
-
key: "isEnabled",
|
|
1046
|
-
value: function isEnabled(name) {
|
|
1047
|
-
return this.enabledFeatureNames.includes(name);
|
|
1048
|
-
}
|
|
1049
|
-
/** @api private */
|
|
766
|
+
/**
|
|
767
|
+
* Check if a feature as been enabled.
|
|
768
|
+
*
|
|
769
|
+
* @param name [String]
|
|
770
|
+
* @return [Boolean]
|
|
771
|
+
*/
|
|
772
|
+
isEnabled(name) {
|
|
773
|
+
return this.enabledFeatureNames.includes(name);
|
|
774
|
+
}
|
|
1050
775
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
(
|
|
1058
|
-
fn();
|
|
1059
|
-
});
|
|
776
|
+
/** @api private */
|
|
777
|
+
enable(scope, names) {
|
|
778
|
+
var fns = this.registry[scope] || {};
|
|
779
|
+
this.enabledFeatureNames = this.enabledFeatureNames.concat(names);
|
|
780
|
+
names.forEach(function (name) {
|
|
781
|
+
(fns[name] || []).forEach(function (fn) {
|
|
782
|
+
fn();
|
|
1060
783
|
});
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}();
|
|
1066
|
-
var features = new Features();
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const features = new Features();
|
|
1067
788
|
|
|
1068
|
-
|
|
789
|
+
const handleFailedPlay = function (player, options) {
|
|
1069
790
|
var originalPlay = player.play;
|
|
1070
|
-
|
|
1071
|
-
|
|
791
|
+
player.play = function /* arguments */
|
|
792
|
+
() {
|
|
1072
793
|
var result = originalPlay.apply(player, arguments);
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
return result["catch"](function (e) {
|
|
794
|
+
if (result && typeof result.catch !== 'undefined') {
|
|
795
|
+
return result.catch(function (e) {
|
|
1076
796
|
if (e.name === 'NotAllowedError' && options.hasAutoplaySupport) {
|
|
1077
797
|
if (options.fallbackToMutedAutoplay) {
|
|
1078
798
|
player.muted(true);
|
|
@@ -1089,53 +809,45 @@ var handleFailedPlay = function handleFailedPlay(player, options) {
|
|
|
1089
809
|
}
|
|
1090
810
|
});
|
|
1091
811
|
}
|
|
1092
|
-
|
|
1093
812
|
return result;
|
|
1094
813
|
};
|
|
1095
814
|
};
|
|
1096
815
|
|
|
1097
|
-
|
|
816
|
+
const asyncPlay = function (player) {
|
|
1098
817
|
var originalPlay = player.play;
|
|
1099
818
|
var originalPause = player.pause;
|
|
1100
819
|
var intendingToPlay = false;
|
|
1101
820
|
var intendingToPause = false;
|
|
1102
|
-
|
|
1103
|
-
|
|
821
|
+
player.play = function /* arguments */
|
|
822
|
+
() {
|
|
1104
823
|
player.intendToPlay();
|
|
1105
824
|
return originalPlay.apply(player, arguments);
|
|
1106
825
|
};
|
|
1107
|
-
|
|
1108
|
-
|
|
826
|
+
player.pause = function /* arguments */
|
|
827
|
+
() {
|
|
1109
828
|
player.intendToPause();
|
|
1110
829
|
return originalPause.apply(player, arguments);
|
|
1111
830
|
};
|
|
1112
|
-
|
|
1113
831
|
player.intendToPlay = function () {
|
|
1114
832
|
intendingToPlay = true;
|
|
1115
833
|
intendingToPause = false;
|
|
1116
834
|
};
|
|
1117
|
-
|
|
1118
835
|
player.intendToPause = function () {
|
|
1119
836
|
intendingToPause = true;
|
|
1120
837
|
intendingToPlay = false;
|
|
1121
838
|
};
|
|
1122
|
-
|
|
1123
839
|
player.intendingToPlay = function () {
|
|
1124
840
|
return intendingToPlay;
|
|
1125
841
|
};
|
|
1126
|
-
|
|
1127
842
|
player.intendingToPause = function () {
|
|
1128
843
|
return intendingToPause;
|
|
1129
844
|
};
|
|
1130
|
-
|
|
1131
845
|
player.ifIntendingToPause = function () {
|
|
1132
846
|
return promiseFromBoolean(intendingToPause);
|
|
1133
847
|
};
|
|
1134
|
-
|
|
1135
848
|
player.ifIntendingToPlay = function () {
|
|
1136
849
|
return promiseFromBoolean(intendingToPlay);
|
|
1137
850
|
};
|
|
1138
|
-
|
|
1139
851
|
function promiseFromBoolean(value) {
|
|
1140
852
|
return new Promise(function (resolve, reject) {
|
|
1141
853
|
if (value) {
|
|
@@ -1147,20 +859,18 @@ var asyncPlay = function asyncPlay(player) {
|
|
|
1147
859
|
}
|
|
1148
860
|
};
|
|
1149
861
|
|
|
1150
|
-
|
|
862
|
+
const hooks = function (player, hooks) {
|
|
1151
863
|
var originalPlay = player.play;
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
_hooks = newHooks;
|
|
864
|
+
player.updateHooks = newHooks => {
|
|
865
|
+
hooks = newHooks;
|
|
1155
866
|
};
|
|
1156
|
-
|
|
1157
|
-
|
|
867
|
+
player.play = function /* args */
|
|
868
|
+
() {
|
|
1158
869
|
var args = arguments;
|
|
1159
870
|
player.trigger('beforeplay');
|
|
1160
871
|
player.intendToPlay();
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
return Promise.all([_hooks.before()]).then(function () {
|
|
872
|
+
if (hooks.before) {
|
|
873
|
+
return Promise.all([hooks.before()]).then(function () {
|
|
1164
874
|
return player.ifIntendingToPlay().then(function () {
|
|
1165
875
|
return originalPlay.apply(player, args);
|
|
1166
876
|
});
|
|
@@ -1169,40 +879,34 @@ var hooks = function hooks(player, _hooks) {
|
|
|
1169
879
|
return originalPlay.apply(player, args);
|
|
1170
880
|
}
|
|
1171
881
|
};
|
|
1172
|
-
|
|
1173
882
|
if (player.afterHookListener) {
|
|
1174
883
|
player.off('pause', player.afterHookListener);
|
|
1175
884
|
player.off('ended', player.afterHookListener);
|
|
1176
885
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
_hooks.after();
|
|
886
|
+
player.afterHookListener = () => {
|
|
887
|
+
if (hooks.after) {
|
|
888
|
+
hooks.after();
|
|
1181
889
|
}
|
|
1182
890
|
};
|
|
1183
|
-
|
|
1184
891
|
player.on('pause', player.afterHookListener);
|
|
1185
892
|
player.on('ended', player.afterHookListener);
|
|
1186
893
|
};
|
|
1187
894
|
|
|
1188
|
-
|
|
895
|
+
const volumeBinding = function (player, settings, options) {
|
|
1189
896
|
options = options || {};
|
|
1190
897
|
var originalPlay = player.play;
|
|
1191
898
|
var originalPause = player.pause;
|
|
1192
899
|
var volumeFactor = 'volumeFactor' in options ? options.volumeFactor : 1;
|
|
1193
|
-
|
|
1194
900
|
player.play = function () {
|
|
1195
901
|
player.intendToPlay();
|
|
1196
902
|
player.volume(player.targetVolume());
|
|
1197
903
|
listenToVolumeSetting();
|
|
1198
904
|
return originalPlay.call(player);
|
|
1199
905
|
};
|
|
1200
|
-
|
|
1201
906
|
player.playAndFadeIn = function (duration) {
|
|
1202
907
|
if (!player.paused() && !player.intendingToPause()) {
|
|
1203
908
|
return Promise.resolve();
|
|
1204
909
|
}
|
|
1205
|
-
|
|
1206
910
|
player.intendToPlay();
|
|
1207
911
|
player.volume(0);
|
|
1208
912
|
return Promise.all([originalPlay.call(player)]).then(function () {
|
|
@@ -1214,17 +918,14 @@ var volumeBinding = function volumeBinding(player, settings, options) {
|
|
|
1214
918
|
});
|
|
1215
919
|
});
|
|
1216
920
|
};
|
|
1217
|
-
|
|
1218
921
|
player.pause = function () {
|
|
1219
922
|
stopListeningToVolumeSetting();
|
|
1220
923
|
originalPause.call(player);
|
|
1221
924
|
};
|
|
1222
|
-
|
|
1223
925
|
player.fadeOutAndPause = function (duration) {
|
|
1224
926
|
if (player.paused() && !player.intendingToPlay()) {
|
|
1225
927
|
return Promise.resolve();
|
|
1226
928
|
}
|
|
1227
|
-
|
|
1228
929
|
player.intendToPause();
|
|
1229
930
|
stopListeningToVolumeSetting();
|
|
1230
931
|
return player.fadeVolume(0, duration).then(function () {
|
|
@@ -1233,26 +934,21 @@ var volumeBinding = function volumeBinding(player, settings, options) {
|
|
|
1233
934
|
});
|
|
1234
935
|
});
|
|
1235
936
|
};
|
|
1236
|
-
|
|
1237
937
|
player.changeVolumeFactor = function (factor, duration) {
|
|
1238
938
|
volumeFactor = factor;
|
|
1239
939
|
return player.fadeVolume(player.targetVolume(), duration);
|
|
1240
940
|
};
|
|
1241
|
-
|
|
1242
941
|
player.targetVolume = function () {
|
|
1243
942
|
return (options.ignoreVolumeSetting ? 1 : settings.get('volume')) * volumeFactor;
|
|
1244
943
|
};
|
|
1245
|
-
|
|
1246
944
|
function listenToVolumeSetting() {
|
|
1247
945
|
player.on('dispose', stopListeningToVolumeSetting);
|
|
1248
946
|
settings.on('change:volume', onVolumeChange);
|
|
1249
947
|
}
|
|
1250
|
-
|
|
1251
948
|
function stopListeningToVolumeSetting() {
|
|
1252
949
|
player.off('dispose', stopListeningToVolumeSetting);
|
|
1253
950
|
settings.off('change:volume', onVolumeChange);
|
|
1254
951
|
}
|
|
1255
|
-
|
|
1256
952
|
function onVolumeChange(model, value) {
|
|
1257
953
|
player.fadeVolume(player.targetVolume(), 40);
|
|
1258
954
|
}
|
|
@@ -1264,16 +960,14 @@ var volumeBinding = function volumeBinding(player, settings, options) {
|
|
|
1264
960
|
*
|
|
1265
961
|
* @since 12.1
|
|
1266
962
|
*/
|
|
1267
|
-
|
|
1268
|
-
var audioContext = {
|
|
963
|
+
const audioContext = {
|
|
1269
964
|
/**
|
|
1270
965
|
* @returns [AudioContext]
|
|
1271
966
|
* Returns `null` if web audio API is not supported or creating
|
|
1272
967
|
* the context fails.
|
|
1273
968
|
*/
|
|
1274
|
-
get: function
|
|
969
|
+
get: function () {
|
|
1275
970
|
var AudioContext = window.AudioContext || window.webkitAudioContext;
|
|
1276
|
-
|
|
1277
971
|
if (typeof this._audioContext === 'undefined') {
|
|
1278
972
|
try {
|
|
1279
973
|
this._audioContext = AudioContext && new AudioContext();
|
|
@@ -1284,12 +978,11 @@ var audioContext = {
|
|
|
1284
978
|
});
|
|
1285
979
|
}
|
|
1286
980
|
}
|
|
1287
|
-
|
|
1288
981
|
return this._audioContext;
|
|
1289
982
|
}
|
|
1290
983
|
};
|
|
1291
984
|
|
|
1292
|
-
|
|
985
|
+
const webAudio = function (player, audioContext) {
|
|
1293
986
|
var gainNode;
|
|
1294
987
|
var currentResolve;
|
|
1295
988
|
var currentTimeout;
|
|
@@ -1298,18 +991,15 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1298
991
|
var lastDuration;
|
|
1299
992
|
var lastStartValue;
|
|
1300
993
|
var allowedMinValue = 0.000001;
|
|
1301
|
-
|
|
1302
994
|
if (audioContext.state === 'suspended') {
|
|
1303
995
|
events.on('background_media:unmute', function () {
|
|
1304
996
|
player.volume(currentValue);
|
|
1305
997
|
});
|
|
1306
998
|
}
|
|
1307
|
-
|
|
1308
999
|
function tryResumeIfSuspended() {
|
|
1309
1000
|
return new Promise(function (resolve, reject) {
|
|
1310
1001
|
if (audioContext.state === 'suspended') {
|
|
1311
1002
|
var maybePromise = audioContext.resume();
|
|
1312
|
-
|
|
1313
1003
|
if (maybePromise && maybePromise.then) {
|
|
1314
1004
|
maybePromise.then(handlePromise);
|
|
1315
1005
|
} else {
|
|
@@ -1318,7 +1008,6 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1318
1008
|
} else {
|
|
1319
1009
|
resolve();
|
|
1320
1010
|
}
|
|
1321
|
-
|
|
1322
1011
|
function handlePromise() {
|
|
1323
1012
|
if (audioContext.state === 'suspended') {
|
|
1324
1013
|
reject();
|
|
@@ -1328,7 +1017,6 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1328
1017
|
}
|
|
1329
1018
|
});
|
|
1330
1019
|
}
|
|
1331
|
-
|
|
1332
1020
|
player.volume = function (value) {
|
|
1333
1021
|
if (typeof value !== 'undefined') {
|
|
1334
1022
|
tryResumeIfSuspended().then(function () {
|
|
@@ -1340,10 +1028,8 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1340
1028
|
currentValue = ensureInAllowedRange(value);
|
|
1341
1029
|
});
|
|
1342
1030
|
}
|
|
1343
|
-
|
|
1344
1031
|
return Math.round(currentValue * 100) / 100;
|
|
1345
1032
|
};
|
|
1346
|
-
|
|
1347
1033
|
player.fadeVolume = function (value, duration) {
|
|
1348
1034
|
return tryResumeIfSuspended().then(function () {
|
|
1349
1035
|
ensureGainNode();
|
|
@@ -1361,9 +1047,7 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1361
1047
|
return Promise.resolve();
|
|
1362
1048
|
});
|
|
1363
1049
|
};
|
|
1364
|
-
|
|
1365
1050
|
player.one('dispose', cancel);
|
|
1366
|
-
|
|
1367
1051
|
function ensureGainNode() {
|
|
1368
1052
|
if (!gainNode) {
|
|
1369
1053
|
gainNode = audioContext.createGain();
|
|
@@ -1372,14 +1056,12 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1372
1056
|
gainNode.connect(audioContext.destination);
|
|
1373
1057
|
}
|
|
1374
1058
|
}
|
|
1375
|
-
|
|
1376
1059
|
function resolveCurrent() {
|
|
1377
1060
|
clearTimeout(currentTimeout);
|
|
1378
1061
|
currentResolve('done');
|
|
1379
1062
|
currentTimeout = null;
|
|
1380
1063
|
currentResolve = null;
|
|
1381
1064
|
}
|
|
1382
|
-
|
|
1383
1065
|
function cancel() {
|
|
1384
1066
|
if (currentResolve) {
|
|
1385
1067
|
gainNode.gain.cancelScheduledValues(audioContext.currentTime);
|
|
@@ -1390,13 +1072,11 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1390
1072
|
updateCurrentValueFromComputedValue();
|
|
1391
1073
|
}
|
|
1392
1074
|
}
|
|
1393
|
-
|
|
1394
1075
|
function recordFadeStart(duration) {
|
|
1395
1076
|
lastStartTime = audioContext.currentTime;
|
|
1396
1077
|
lastStartValue = currentValue;
|
|
1397
1078
|
lastDuration = duration;
|
|
1398
1079
|
}
|
|
1399
|
-
|
|
1400
1080
|
function updateCurrentValueFromComputedValue() {
|
|
1401
1081
|
// Firefox 54 on Ubuntu does not provide computed values when gain
|
|
1402
1082
|
// was changed via one of the scheduling methods. Instead
|
|
@@ -1411,46 +1091,40 @@ var webAudio = function webAudio(player, audioContext) {
|
|
|
1411
1091
|
currentValue = gainNode.gain.value;
|
|
1412
1092
|
}
|
|
1413
1093
|
}
|
|
1414
|
-
|
|
1415
1094
|
function ensureInAllowedRange(value) {
|
|
1416
1095
|
return value < allowedMinValue ? allowedMinValue : value;
|
|
1417
1096
|
}
|
|
1418
1097
|
};
|
|
1419
1098
|
|
|
1420
|
-
|
|
1099
|
+
const noop = function (player) {
|
|
1421
1100
|
player.fadeVolume = function (value, duration) {
|
|
1422
1101
|
return Promise.resolve();
|
|
1423
1102
|
};
|
|
1424
1103
|
};
|
|
1425
1104
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1105
|
+
const interval = function (player) {
|
|
1106
|
+
const originalVolume = player.volume;
|
|
1107
|
+
let fadeVolumeResolve;
|
|
1108
|
+
let fadeVolumeInterval;
|
|
1431
1109
|
player.volume = function (value) {
|
|
1432
1110
|
if (typeof value !== 'undefined') {
|
|
1433
1111
|
cancelFadeVolume();
|
|
1434
1112
|
}
|
|
1435
|
-
|
|
1436
1113
|
return originalVolume.apply(player, arguments);
|
|
1437
1114
|
};
|
|
1438
|
-
|
|
1439
1115
|
player.fadeVolume = function (value, duration) {
|
|
1440
1116
|
cancelFadeVolume();
|
|
1441
1117
|
return new Promise(function (resolve, reject) {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1118
|
+
const resolution = 10;
|
|
1119
|
+
const startValue = volume();
|
|
1120
|
+
const steps = duration / resolution;
|
|
1121
|
+
const leap = (value - startValue) / steps;
|
|
1447
1122
|
if (value === startValue) {
|
|
1448
1123
|
resolve();
|
|
1449
1124
|
} else {
|
|
1450
1125
|
fadeVolumeResolve = resolve;
|
|
1451
1126
|
fadeVolumeInterval = setInterval(function () {
|
|
1452
1127
|
volume(volume() + leap);
|
|
1453
|
-
|
|
1454
1128
|
if (volume() >= value && value >= startValue || volume() <= value && value <= startValue) {
|
|
1455
1129
|
resolveFadeVolume();
|
|
1456
1130
|
}
|
|
@@ -1458,26 +1132,22 @@ var interval = function interval(player) {
|
|
|
1458
1132
|
}
|
|
1459
1133
|
});
|
|
1460
1134
|
};
|
|
1461
|
-
|
|
1462
1135
|
player.one('dispose', cancelFadeVolume);
|
|
1463
|
-
|
|
1464
|
-
|
|
1136
|
+
function volume( /* arguments */
|
|
1137
|
+
) {
|
|
1465
1138
|
return originalVolume.apply(player, arguments);
|
|
1466
1139
|
}
|
|
1467
|
-
|
|
1468
1140
|
function resolveFadeVolume() {
|
|
1469
1141
|
clearInterval(fadeVolumeInterval);
|
|
1470
1142
|
fadeVolumeResolve('done');
|
|
1471
1143
|
fadeVolumeInterval = null;
|
|
1472
1144
|
fadeVolumeResolve = null;
|
|
1473
1145
|
}
|
|
1474
|
-
|
|
1475
1146
|
function cancelFadeVolume() {
|
|
1476
1147
|
if (fadeVolumeResolve) {
|
|
1477
1148
|
fadeVolumeResolve('cancelled');
|
|
1478
1149
|
fadeVolumeResolve = null;
|
|
1479
1150
|
}
|
|
1480
|
-
|
|
1481
1151
|
if (fadeVolumeInterval) {
|
|
1482
1152
|
clearInterval(fadeVolumeInterval);
|
|
1483
1153
|
fadeVolumeInterval = null;
|
|
@@ -1485,7 +1155,7 @@ var interval = function interval(player) {
|
|
|
1485
1155
|
}
|
|
1486
1156
|
};
|
|
1487
1157
|
|
|
1488
|
-
|
|
1158
|
+
const volumeFading = function (player) {
|
|
1489
1159
|
if (!browser.has('volume control support')) {
|
|
1490
1160
|
return noop(player);
|
|
1491
1161
|
} else if (browser.has('audio context volume fading support') && audioContext.get() && player.getMediaElement) {
|
|
@@ -1499,10 +1169,10 @@ volumeFading.interval = interval;
|
|
|
1499
1169
|
volumeFading.noop = noop;
|
|
1500
1170
|
volumeFading.webAudio = webAudio;
|
|
1501
1171
|
|
|
1502
|
-
|
|
1172
|
+
const loadWaiting = function (player) {
|
|
1503
1173
|
var originalFadeVolume = player.fadeVolume;
|
|
1504
|
-
|
|
1505
|
-
|
|
1174
|
+
player.fadeVolume = function /* args */
|
|
1175
|
+
() {
|
|
1506
1176
|
var args = arguments;
|
|
1507
1177
|
return Promise.all([this.loadedPromise]).then(function () {
|
|
1508
1178
|
return originalFadeVolume.apply(player, args);
|
|
@@ -1510,98 +1180,76 @@ var loadWaiting = function loadWaiting(player) {
|
|
|
1510
1180
|
};
|
|
1511
1181
|
};
|
|
1512
1182
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
_classCallCheck(this, Settings);
|
|
1516
|
-
|
|
1183
|
+
class Settings {
|
|
1184
|
+
constructor() {
|
|
1517
1185
|
this.attributes = {
|
|
1518
1186
|
volume: 1
|
|
1519
1187
|
};
|
|
1520
1188
|
this.initialize();
|
|
1521
1189
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
var attrs;
|
|
1532
|
-
|
|
1533
|
-
if (typeof key === 'object') {
|
|
1534
|
-
attrs = key;
|
|
1535
|
-
} else {
|
|
1536
|
-
(attrs = {})[key] = value;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
for (var attr in attrs) {
|
|
1540
|
-
this.attributes[attr] = attrs[attr];
|
|
1541
|
-
this.trigger('change:' + attr);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
this.trigger('change');
|
|
1190
|
+
get(attributeName) {
|
|
1191
|
+
return this.attributes[attributeName];
|
|
1192
|
+
}
|
|
1193
|
+
set(key, value) {
|
|
1194
|
+
let attrs;
|
|
1195
|
+
if (typeof key === 'object') {
|
|
1196
|
+
attrs = key;
|
|
1197
|
+
} else {
|
|
1198
|
+
(attrs = {})[key] = value;
|
|
1545
1199
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
return _objectSpread2({}, this.attributes);
|
|
1200
|
+
for (const attr in attrs) {
|
|
1201
|
+
this.attributes[attr] = attrs[attr];
|
|
1202
|
+
this.trigger('change:' + attr);
|
|
1550
1203
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1204
|
+
this.trigger('change');
|
|
1205
|
+
}
|
|
1206
|
+
toJSON() {
|
|
1207
|
+
return {
|
|
1208
|
+
...this.attributes
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
initialize() {
|
|
1212
|
+
const storage = this.getLocalStorage();
|
|
1213
|
+
if (storage) {
|
|
1214
|
+
if (storage['pageflow.settings']) {
|
|
1215
|
+
try {
|
|
1216
|
+
this.set(JSON.parse(storage['pageflow.settings']));
|
|
1217
|
+
} catch (e) {
|
|
1218
|
+
log(e);
|
|
1563
1219
|
}
|
|
1564
|
-
|
|
1565
|
-
this.on('change', function () {
|
|
1566
|
-
storage['pageflow.settings'] = JSON.stringify(this.attributes);
|
|
1567
|
-
});
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
}, {
|
|
1571
|
-
key: "getLocalStorage",
|
|
1572
|
-
value: function getLocalStorage() {
|
|
1573
|
-
try {
|
|
1574
|
-
return window.localStorage;
|
|
1575
|
-
} catch (e) {
|
|
1576
|
-
// Safari throws SecurityError when accessing window.localStorage
|
|
1577
|
-
// if cookies/website data are disabled.
|
|
1578
|
-
return null;
|
|
1579
1220
|
}
|
|
1221
|
+
this.on('change', function () {
|
|
1222
|
+
storage['pageflow.settings'] = JSON.stringify(this.attributes);
|
|
1223
|
+
});
|
|
1580
1224
|
}
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1225
|
+
}
|
|
1226
|
+
getLocalStorage() {
|
|
1227
|
+
try {
|
|
1228
|
+
return window.localStorage;
|
|
1229
|
+
} catch (e) {
|
|
1230
|
+
// Safari throws SecurityError when accessing window.localStorage
|
|
1231
|
+
// if cookies/website data are disabled.
|
|
1232
|
+
return null;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1586
1236
|
Object.assign(Settings.prototype, BackboneEvents);
|
|
1587
|
-
|
|
1237
|
+
const settings = new Settings();
|
|
1588
1238
|
|
|
1589
|
-
|
|
1590
|
-
enhance: function
|
|
1591
|
-
handleFailedPlay(player,
|
|
1592
|
-
hasAutoplaySupport: browser.has('autoplay support')
|
|
1593
|
-
|
|
1239
|
+
const mediaPlayer = {
|
|
1240
|
+
enhance: function (player, options) {
|
|
1241
|
+
handleFailedPlay(player, {
|
|
1242
|
+
hasAutoplaySupport: browser.has('autoplay support'),
|
|
1243
|
+
...options
|
|
1244
|
+
});
|
|
1594
1245
|
asyncPlay(player);
|
|
1595
|
-
|
|
1596
1246
|
if (options.hooks) {
|
|
1597
1247
|
hooks(player, options.hooks);
|
|
1598
1248
|
}
|
|
1599
|
-
|
|
1600
1249
|
if (options.volumeFading) {
|
|
1601
1250
|
volumeFading(player);
|
|
1602
1251
|
volumeBinding(player, settings, options);
|
|
1603
1252
|
}
|
|
1604
|
-
|
|
1605
1253
|
if (options.loadWaiting) {
|
|
1606
1254
|
loadWaiting(player);
|
|
1607
1255
|
}
|
|
@@ -1617,12 +1265,12 @@ mediaPlayer.asyncPlay = asyncPlay;
|
|
|
1617
1265
|
|
|
1618
1266
|
// Replacement for Underscore's throttle, because scrolled entries
|
|
1619
1267
|
// don't have Underscore anymore
|
|
1268
|
+
|
|
1620
1269
|
function throttle(func, timeFrame) {
|
|
1621
1270
|
var lastTime = 0;
|
|
1622
1271
|
return function (options) {
|
|
1623
1272
|
var now = new Date();
|
|
1624
1273
|
func = func.bind(this);
|
|
1625
|
-
|
|
1626
1274
|
if (now - lastTime >= timeFrame) {
|
|
1627
1275
|
func(options);
|
|
1628
1276
|
lastTime = now;
|
|
@@ -1630,7 +1278,7 @@ function throttle(func, timeFrame) {
|
|
|
1630
1278
|
};
|
|
1631
1279
|
}
|
|
1632
1280
|
|
|
1633
|
-
|
|
1281
|
+
const mediaEvents = function (player, context) {
|
|
1634
1282
|
function triggerMediaEvent(name) {
|
|
1635
1283
|
events.trigger('media:' + name, {
|
|
1636
1284
|
fileName: player.currentSrc,
|
|
@@ -1641,10 +1289,15 @@ var mediaEvents = function mediaEvents(player, context) {
|
|
|
1641
1289
|
bitrate: 128000
|
|
1642
1290
|
});
|
|
1643
1291
|
}
|
|
1644
|
-
|
|
1645
1292
|
player.on('play', function () {
|
|
1646
1293
|
triggerMediaEvent('play');
|
|
1647
1294
|
});
|
|
1295
|
+
player.on('seeking', function () {
|
|
1296
|
+
triggerMediaEvent('seeking');
|
|
1297
|
+
});
|
|
1298
|
+
player.on('seeked', function () {
|
|
1299
|
+
triggerMediaEvent('seeked');
|
|
1300
|
+
});
|
|
1648
1301
|
player.on('timeupdate', function () {
|
|
1649
1302
|
triggerMediaEvent('timeupdate');
|
|
1650
1303
|
});
|
|
@@ -1662,32 +1315,27 @@ var mediaEvents = function mediaEvents(player, context) {
|
|
|
1662
1315
|
// Prevent audio play back when browser enters background on mobile
|
|
1663
1316
|
// device. Use the face that timeupdate events continue to fire while
|
|
1664
1317
|
// intervals no longer executed when the browser is in the background.
|
|
1665
|
-
|
|
1318
|
+
const pauseInBackground = function (player) {
|
|
1666
1319
|
var interval;
|
|
1667
1320
|
var lastInterval;
|
|
1668
1321
|
var resolution = 100;
|
|
1669
|
-
|
|
1670
1322
|
function startProbeInterval() {
|
|
1671
1323
|
interval = setInterval(function () {
|
|
1672
1324
|
lastInterval = new Date().getTime();
|
|
1673
1325
|
}, resolution);
|
|
1674
1326
|
}
|
|
1675
|
-
|
|
1676
1327
|
function stopProbeInterval() {
|
|
1677
1328
|
clearInterval(interval);
|
|
1678
1329
|
interval = null;
|
|
1679
1330
|
}
|
|
1680
|
-
|
|
1681
1331
|
function pauseIfProbeIntervalHalted() {
|
|
1682
1332
|
if (intervalHalted()) {
|
|
1683
1333
|
player.pause();
|
|
1684
1334
|
}
|
|
1685
1335
|
}
|
|
1686
|
-
|
|
1687
1336
|
function intervalHalted() {
|
|
1688
1337
|
return interval && lastInterval < new Date().getTime() - resolution * 5;
|
|
1689
1338
|
}
|
|
1690
|
-
|
|
1691
1339
|
player.on('play', startProbeInterval);
|
|
1692
1340
|
player.on('pause', stopProbeInterval);
|
|
1693
1341
|
player.on('ended', stopProbeInterval);
|
|
@@ -1701,26 +1349,22 @@ var pauseInBackground = function pauseInBackground(player) {
|
|
|
1701
1349
|
*
|
|
1702
1350
|
* @api private
|
|
1703
1351
|
*/
|
|
1704
|
-
|
|
1352
|
+
const seekWithInvalidStateHandling = function (player) {
|
|
1705
1353
|
var originalSeek = player.seek;
|
|
1706
|
-
|
|
1707
1354
|
player.seek = function (time) {
|
|
1708
1355
|
return retryOnProgress(function () {
|
|
1709
1356
|
originalSeek.call(player, time);
|
|
1710
1357
|
});
|
|
1711
1358
|
};
|
|
1712
|
-
|
|
1713
1359
|
function retryOnProgress(fn) {
|
|
1714
1360
|
var tries = 0;
|
|
1715
1361
|
return new Promise(function (resolve, reject) {
|
|
1716
1362
|
function tryOrWaitForProgress() {
|
|
1717
1363
|
tries += 1;
|
|
1718
|
-
|
|
1719
1364
|
if (tries >= 50) {
|
|
1720
1365
|
reject();
|
|
1721
1366
|
return;
|
|
1722
1367
|
}
|
|
1723
|
-
|
|
1724
1368
|
try {
|
|
1725
1369
|
fn();
|
|
1726
1370
|
resolve();
|
|
@@ -1728,13 +1372,12 @@ var seekWithInvalidStateHandling = function seekWithInvalidStateHandling(player)
|
|
|
1728
1372
|
player.one('progress', tryOrWaitForProgress);
|
|
1729
1373
|
}
|
|
1730
1374
|
}
|
|
1731
|
-
|
|
1732
1375
|
tryOrWaitForProgress();
|
|
1733
1376
|
});
|
|
1734
1377
|
}
|
|
1735
1378
|
};
|
|
1736
1379
|
|
|
1737
|
-
|
|
1380
|
+
const rewindMethod = function (player) {
|
|
1738
1381
|
/**
|
|
1739
1382
|
* Seek to beginning of file. If already at the beginning do
|
|
1740
1383
|
* nothing.
|
|
@@ -1752,7 +1395,7 @@ var rewindMethod = function rewindMethod(player) {
|
|
|
1752
1395
|
};
|
|
1753
1396
|
};
|
|
1754
1397
|
|
|
1755
|
-
|
|
1398
|
+
const getMediaElementMethod = function (player) {
|
|
1756
1399
|
player.getMediaElement = function () {
|
|
1757
1400
|
return player.audio.audio;
|
|
1758
1401
|
};
|
|
@@ -1772,20 +1415,19 @@ var getMediaElementMethod = function getMediaElementMethod(player) {
|
|
|
1772
1415
|
*
|
|
1773
1416
|
* @class
|
|
1774
1417
|
*/
|
|
1775
|
-
|
|
1776
|
-
var AudioPlayer = function AudioPlayer(sources, options) {
|
|
1418
|
+
const AudioPlayer = function (sources, options) {
|
|
1777
1419
|
options = options || {};
|
|
1778
1420
|
var codecMapping = {
|
|
1779
1421
|
vorbis: 'audio/ogg',
|
|
1780
1422
|
mp4: 'audio/mp4',
|
|
1781
1423
|
mp3: 'audio/mpeg'
|
|
1782
1424
|
};
|
|
1783
|
-
|
|
1784
|
-
|
|
1425
|
+
let readyResolve;
|
|
1426
|
+
let readyPromise = new Promise(function (resolve) {
|
|
1785
1427
|
readyResolve = resolve;
|
|
1786
1428
|
});
|
|
1787
|
-
|
|
1788
|
-
|
|
1429
|
+
let loadedResolve;
|
|
1430
|
+
let loadedPromise = new Promise(function (resolve) {
|
|
1789
1431
|
loadedResolve = resolve;
|
|
1790
1432
|
});
|
|
1791
1433
|
var audio = new Audio5js({
|
|
@@ -1800,22 +1442,19 @@ var AudioPlayer = function AudioPlayer(sources, options) {
|
|
|
1800
1442
|
audio.readyPromise = readyPromise;
|
|
1801
1443
|
audio.loadedPromise = loadedPromise;
|
|
1802
1444
|
audio.on('load', loadedResolve);
|
|
1803
|
-
|
|
1804
1445
|
if (options.mediaEvents) {
|
|
1805
1446
|
mediaEvents(audio, options.context);
|
|
1806
1447
|
}
|
|
1807
|
-
|
|
1808
1448
|
if (options.pauseInBackground && browser.has('mobile platform')) {
|
|
1809
1449
|
pauseInBackground(audio);
|
|
1810
1450
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
}
|
|
1451
|
+
mediaPlayer.enhance(audio, {
|
|
1452
|
+
loadWaiting: true,
|
|
1453
|
+
...options
|
|
1454
|
+
});
|
|
1815
1455
|
seekWithInvalidStateHandling(audio);
|
|
1816
1456
|
rewindMethod(audio);
|
|
1817
1457
|
getMediaElementMethod(audio);
|
|
1818
|
-
|
|
1819
1458
|
audio.src = function (sources) {
|
|
1820
1459
|
readyPromise.then(function () {
|
|
1821
1460
|
var source = (sources || []).find(function (source) {
|
|
@@ -1824,91 +1463,72 @@ var AudioPlayer = function AudioPlayer(sources, options) {
|
|
|
1824
1463
|
audio.load(source ? source.src : '');
|
|
1825
1464
|
});
|
|
1826
1465
|
};
|
|
1827
|
-
|
|
1828
1466
|
var originalLoad = audio.load;
|
|
1829
|
-
|
|
1830
1467
|
audio.load = function (src) {
|
|
1831
1468
|
if (!src) {
|
|
1832
1469
|
this.duration = 0;
|
|
1833
1470
|
}
|
|
1834
|
-
|
|
1835
1471
|
this.currentSrc = src;
|
|
1836
1472
|
this.position = 0;
|
|
1837
1473
|
this.trigger('timeupdate', this.position, this.duration);
|
|
1838
1474
|
originalLoad.apply(this, arguments);
|
|
1839
1475
|
};
|
|
1840
|
-
|
|
1841
1476
|
var originalSeek = audio.seek;
|
|
1842
|
-
|
|
1843
1477
|
audio.seek = function () {
|
|
1844
1478
|
if (this.currentSrc) {
|
|
1845
1479
|
return originalSeek.apply(this, arguments);
|
|
1846
1480
|
}
|
|
1847
1481
|
};
|
|
1848
|
-
|
|
1849
1482
|
var originalPlay = audio.play;
|
|
1850
|
-
|
|
1851
1483
|
audio.play = function () {
|
|
1852
1484
|
if (this.currentSrc) {
|
|
1853
1485
|
originalPlay.apply(this, arguments);
|
|
1854
1486
|
}
|
|
1855
1487
|
};
|
|
1856
|
-
|
|
1857
1488
|
audio.paused = function () {
|
|
1858
1489
|
return !audio.playing;
|
|
1859
1490
|
};
|
|
1860
|
-
|
|
1861
1491
|
audio.src(sources);
|
|
1862
1492
|
return audio;
|
|
1863
1493
|
};
|
|
1864
|
-
|
|
1865
1494
|
AudioPlayer.fromAudioTag = function (element, options) {
|
|
1866
1495
|
return new AudioPlayer(element.find('source').map(function () {
|
|
1867
1496
|
return {
|
|
1868
1497
|
src: this.getAttribute('src'),
|
|
1869
1498
|
type: this.getAttribute('type')
|
|
1870
1499
|
};
|
|
1871
|
-
}).get(),
|
|
1872
|
-
tag: element[0]
|
|
1873
|
-
|
|
1500
|
+
}).get(), {
|
|
1501
|
+
tag: element[0],
|
|
1502
|
+
...options
|
|
1503
|
+
});
|
|
1874
1504
|
};
|
|
1875
|
-
|
|
1876
1505
|
AudioPlayer.fromScriptTag = function (element, options) {
|
|
1877
1506
|
var sources = element.length ? JSON.parse(element.text()) : [];
|
|
1878
1507
|
return new AudioPlayer(sources, options);
|
|
1879
1508
|
};
|
|
1880
1509
|
|
|
1881
|
-
|
|
1510
|
+
const Null = function () {
|
|
1882
1511
|
this.playAndFadeIn = function () {
|
|
1883
1512
|
return Promise.resolve();
|
|
1884
1513
|
};
|
|
1885
|
-
|
|
1886
1514
|
this.fadeOutAndPause = function () {
|
|
1887
1515
|
return Promise.resolve();
|
|
1888
1516
|
};
|
|
1889
|
-
|
|
1890
1517
|
this.changeVolumeFactor = function () {
|
|
1891
1518
|
return Promise.resolve();
|
|
1892
1519
|
};
|
|
1893
|
-
|
|
1894
1520
|
this.play = function () {};
|
|
1895
|
-
|
|
1896
1521
|
this.pause = function () {};
|
|
1897
|
-
|
|
1898
1522
|
this.paused = function () {
|
|
1899
1523
|
return true;
|
|
1900
1524
|
};
|
|
1901
|
-
|
|
1902
1525
|
this.seek = function () {
|
|
1903
1526
|
return Promise.resolve();
|
|
1904
1527
|
};
|
|
1905
|
-
|
|
1906
1528
|
this.rewind = function () {
|
|
1907
1529
|
return Promise.resolve();
|
|
1908
1530
|
};
|
|
1909
|
-
|
|
1910
1531
|
this.formatTime = function () {};
|
|
1911
|
-
|
|
1912
1532
|
this.one = function (event, handler) {
|
|
1913
1533
|
handler();
|
|
1914
1534
|
};
|
|
@@ -1921,36 +1541,18 @@ AudioPlayer.seekWithInvalidStateHandling = seekWithInvalidStateHandling;
|
|
|
1921
1541
|
AudioPlayer.rewindMethod = rewindMethod;
|
|
1922
1542
|
AudioPlayer.pauseInBackground = pauseInBackground;
|
|
1923
1543
|
|
|
1924
|
-
function _arrayWithoutHoles(arr) {
|
|
1925
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
|
-
function _iterableToArray(iter) {
|
|
1929
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
function _nonIterableSpread() {
|
|
1933
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
function _toConsumableArray(arr) {
|
|
1937
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
1544
|
if (typeof window !== 'undefined') {
|
|
1941
1545
|
window.VIDEOJS_NO_DYNAMIC_STYLE = true;
|
|
1942
1546
|
}
|
|
1943
1547
|
|
|
1944
|
-
|
|
1548
|
+
const filterSources = function (playerElement) {
|
|
1945
1549
|
if (playerElement.tagName.toLowerCase() !== 'video') {
|
|
1946
1550
|
return playerElement;
|
|
1947
1551
|
}
|
|
1948
|
-
|
|
1949
1552
|
var changed = false;
|
|
1950
|
-
|
|
1951
1553
|
if (browser.has('mp4 support only')) {
|
|
1952
1554
|
// keep only mp4 source
|
|
1953
|
-
playerElement.querySelectorAll('source').forEach(
|
|
1555
|
+
playerElement.querySelectorAll('source').forEach(source => {
|
|
1954
1556
|
if (source.type !== 'video/mp4') {
|
|
1955
1557
|
playerElement.removeChild(source);
|
|
1956
1558
|
}
|
|
@@ -1958,14 +1560,12 @@ var filterSources = function filterSources(playerElement) {
|
|
|
1958
1560
|
changed = true;
|
|
1959
1561
|
} else if (browser.has('mse and native hls support')) {
|
|
1960
1562
|
// remove dash source to ensure hls is used
|
|
1961
|
-
|
|
1962
|
-
|
|
1563
|
+
const dashSource = playerElement.querySelector('source[type="application/dash+xml"]');
|
|
1963
1564
|
if (dashSource) {
|
|
1964
1565
|
playerElement.removeChild(dashSource);
|
|
1965
1566
|
changed = true;
|
|
1966
1567
|
}
|
|
1967
1568
|
}
|
|
1968
|
-
|
|
1969
1569
|
if (changed) {
|
|
1970
1570
|
// the video tags initially in the dom are broken since they "saw"
|
|
1971
1571
|
// the other sources. replace with clone
|
|
@@ -1977,9 +1577,8 @@ var filterSources = function filterSources(playerElement) {
|
|
|
1977
1577
|
}
|
|
1978
1578
|
};
|
|
1979
1579
|
|
|
1980
|
-
|
|
1580
|
+
const useSlimPlayerControlsDuringPhonePlayback = function (player) {
|
|
1981
1581
|
var originalPlay = player.play;
|
|
1982
|
-
|
|
1983
1582
|
player.play = function () {
|
|
1984
1583
|
if (browser.has('phone platform') && !browser.has('native video player')) {
|
|
1985
1584
|
state.widgets.use({
|
|
@@ -1989,57 +1588,46 @@ var useSlimPlayerControlsDuringPhonePlayback = function useSlimPlayerControlsDur
|
|
|
1989
1588
|
player.one('pause', restoreWidgets);
|
|
1990
1589
|
});
|
|
1991
1590
|
}
|
|
1992
|
-
|
|
1993
1591
|
return originalPlay.apply(this, arguments);
|
|
1994
1592
|
};
|
|
1995
1593
|
};
|
|
1996
1594
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1595
|
+
const prebuffering = function (player) {
|
|
1596
|
+
let prebufferPromiseReject;
|
|
2000
1597
|
player.isBufferedAhead = function (delta, silent) {
|
|
2001
1598
|
// video.js only gives us one time range starting from 0 here. We
|
|
2002
1599
|
// still ask for the last time range to be on the safe side.
|
|
2003
1600
|
var timeRanges = player.buffered();
|
|
2004
1601
|
var currentBufferTime = timeRanges.end(timeRanges.length - 1);
|
|
2005
1602
|
var desiredBufferTime = player.currentTime() + delta;
|
|
2006
|
-
|
|
2007
1603
|
if (player.duration()) {
|
|
2008
1604
|
desiredBufferTime = Math.min(desiredBufferTime, Math.floor(player.duration()));
|
|
2009
1605
|
}
|
|
2010
|
-
|
|
2011
1606
|
var result = currentBufferTime >= desiredBufferTime;
|
|
2012
|
-
|
|
2013
1607
|
if (!silent) {
|
|
2014
1608
|
log('buffered ahead ' + delta + ': ' + result + ' (' + currentBufferTime + '/' + desiredBufferTime + ')');
|
|
2015
1609
|
}
|
|
2016
|
-
|
|
2017
1610
|
return result;
|
|
2018
1611
|
};
|
|
2019
|
-
|
|
2020
1612
|
player.prebuffer = function (options) {
|
|
2021
1613
|
options = options || {};
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
1614
|
+
const delta = options.secondsToBuffer || 10;
|
|
1615
|
+
const secondsToWait = options.secondsToWait || 3;
|
|
1616
|
+
const interval = 200;
|
|
1617
|
+
const maxCount = secondsToWait * 1000 / interval;
|
|
1618
|
+
let count = 0;
|
|
2028
1619
|
if (browser.has('prebuffering support')) {
|
|
2029
1620
|
if (!player.isBufferedAhead(delta) && !player.prebufferPromise) {
|
|
2030
1621
|
log('prebuffering video ' + player.src());
|
|
2031
|
-
player.prebufferPromise = new Promise(
|
|
1622
|
+
player.prebufferPromise = new Promise((resolve, reject) => {
|
|
2032
1623
|
prebufferPromiseReject = reject;
|
|
2033
1624
|
wait();
|
|
2034
|
-
|
|
2035
1625
|
function wait() {
|
|
2036
1626
|
setTimeout(function () {
|
|
2037
1627
|
if (!player.prebufferPromise) {
|
|
2038
1628
|
return;
|
|
2039
1629
|
}
|
|
2040
|
-
|
|
2041
1630
|
count++;
|
|
2042
|
-
|
|
2043
1631
|
if (player.isBufferedAhead(delta) || count > maxCount) {
|
|
2044
1632
|
log('finished prebuffering video ' + player.src());
|
|
2045
1633
|
resolve();
|
|
@@ -2052,10 +1640,8 @@ var prebuffering = function prebuffering(player) {
|
|
|
2052
1640
|
});
|
|
2053
1641
|
}
|
|
2054
1642
|
}
|
|
2055
|
-
|
|
2056
1643
|
return player.prebufferPromise ? player.prebufferPromise : Promise.resolve();
|
|
2057
1644
|
};
|
|
2058
|
-
|
|
2059
1645
|
player.abortPrebuffering = function () {
|
|
2060
1646
|
if (player.prebufferPromise) {
|
|
2061
1647
|
log('ABORT prebuffering');
|
|
@@ -2063,20 +1649,17 @@ var prebuffering = function prebuffering(player) {
|
|
|
2063
1649
|
player.prebufferPromise = null;
|
|
2064
1650
|
}
|
|
2065
1651
|
};
|
|
2066
|
-
|
|
2067
1652
|
var originalPause = player.pause;
|
|
2068
|
-
|
|
2069
1653
|
player.pause = function () {
|
|
2070
1654
|
player.abortPrebuffering();
|
|
2071
1655
|
return originalPause.apply(this, arguments);
|
|
2072
1656
|
};
|
|
2073
|
-
|
|
2074
1657
|
player.one('dispose', function () {
|
|
2075
1658
|
player.abortPrebuffering();
|
|
2076
1659
|
});
|
|
2077
1660
|
};
|
|
2078
1661
|
|
|
2079
|
-
|
|
1662
|
+
const cueSettingsMethods = function (player) {
|
|
2080
1663
|
/**
|
|
2081
1664
|
* Specify the display position of text tracks. This method can also
|
|
2082
1665
|
* be used to make VideoJS reposition the text tracks after the
|
|
@@ -2114,7 +1697,9 @@ var cueSettingsMethods = function cueSettingsMethods(player) {
|
|
|
2114
1697
|
}
|
|
2115
1698
|
}
|
|
2116
1699
|
}
|
|
2117
|
-
});
|
|
1700
|
+
});
|
|
1701
|
+
|
|
1702
|
+
// Setting `line` does not update display directly, but only when
|
|
2118
1703
|
// the next cue is displayed. This is problematic, when we
|
|
2119
1704
|
// reposition text tracks to prevent overlap with player
|
|
2120
1705
|
// controls. Triggering the event makes VideoJS update positions.
|
|
@@ -2122,19 +1707,17 @@ var cueSettingsMethods = function cueSettingsMethods(player) {
|
|
|
2122
1707
|
// track changed since the last call, i.e. `line` has been changed
|
|
2123
1708
|
// for a cue even though the previous call had the same
|
|
2124
1709
|
// parameters.
|
|
2125
|
-
|
|
2126
1710
|
if ((this.prevLine !== line || changed) && command != 'lazy') {
|
|
2127
1711
|
var tech = player.tech({
|
|
2128
1712
|
IWillNotUseThisInPlugins: true
|
|
2129
1713
|
});
|
|
2130
1714
|
tech && tech.trigger('texttrackchange');
|
|
2131
1715
|
}
|
|
2132
|
-
|
|
2133
1716
|
this.prevLine = line;
|
|
2134
1717
|
};
|
|
2135
1718
|
};
|
|
2136
1719
|
|
|
2137
|
-
|
|
1720
|
+
const getMediaElementMethod$1 = function (player) {
|
|
2138
1721
|
player.getMediaElement = function () {
|
|
2139
1722
|
var tech = player.tech({
|
|
2140
1723
|
IWillNotUseThisInPlugins: true
|
|
@@ -2143,28 +1726,35 @@ var getMediaElementMethod$1 = function getMediaElementMethod(player) {
|
|
|
2143
1726
|
};
|
|
2144
1727
|
};
|
|
2145
1728
|
|
|
2146
|
-
|
|
1729
|
+
const mediaEvents$1 = function (player, context) {
|
|
2147
1730
|
player.updateMediaEventsContext = function (newContext) {
|
|
2148
1731
|
context = newContext;
|
|
2149
1732
|
};
|
|
2150
|
-
|
|
2151
|
-
function triggerMediaEvent(name) {
|
|
1733
|
+
player.triggerMediaAllocate = function () {
|
|
2152
1734
|
if (context) {
|
|
2153
|
-
events.trigger('media:'
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
currentTime: player.currentTime(),
|
|
2157
|
-
duration: player.duration(),
|
|
2158
|
-
volume: player.volume(),
|
|
2159
|
-
altText: player.getMediaElement().getAttribute('alt'),
|
|
2160
|
-
bitrate: 3500000
|
|
1735
|
+
events.trigger('media:allocate', {
|
|
1736
|
+
...mediaEventPayload(),
|
|
1737
|
+
element: player.getMediaElement()
|
|
2161
1738
|
});
|
|
2162
1739
|
}
|
|
2163
|
-
}
|
|
2164
|
-
|
|
1740
|
+
};
|
|
1741
|
+
player.triggerMediaRelease = function () {
|
|
1742
|
+
if (context) {
|
|
1743
|
+
events.trigger('media:release', {
|
|
1744
|
+
...mediaEventPayload(),
|
|
1745
|
+
element: player.getMediaElement()
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
2165
1749
|
player.on('play', function () {
|
|
2166
1750
|
triggerMediaEvent('play');
|
|
2167
1751
|
});
|
|
1752
|
+
player.on('seeking', function () {
|
|
1753
|
+
triggerMediaEvent('seeking');
|
|
1754
|
+
});
|
|
1755
|
+
player.on('seeked', function () {
|
|
1756
|
+
triggerMediaEvent('seeked');
|
|
1757
|
+
});
|
|
2168
1758
|
player.on('timeupdate', function () {
|
|
2169
1759
|
triggerMediaEvent('timeupdate');
|
|
2170
1760
|
});
|
|
@@ -2177,26 +1767,38 @@ var mediaEvents$1 = function mediaEvents(player, context) {
|
|
|
2177
1767
|
player.on('ended', function () {
|
|
2178
1768
|
triggerMediaEvent('ended');
|
|
2179
1769
|
});
|
|
1770
|
+
function triggerMediaEvent(name) {
|
|
1771
|
+
if (context) {
|
|
1772
|
+
events.trigger('media:' + name, mediaEventPayload());
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function mediaEventPayload() {
|
|
1776
|
+
return {
|
|
1777
|
+
fileName: player.previousSrc || player.currentSrc(),
|
|
1778
|
+
context: context,
|
|
1779
|
+
currentTime: player.currentTime(),
|
|
1780
|
+
duration: player.duration(),
|
|
1781
|
+
volume: player.volume(),
|
|
1782
|
+
altText: player.getMediaElement().getAttribute('alt'),
|
|
1783
|
+
bitrate: 3500000
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
2180
1786
|
};
|
|
2181
1787
|
|
|
2182
|
-
|
|
1788
|
+
const bufferUnderrunWaiting = function (player) {
|
|
2183
1789
|
var originalPause = player.pause;
|
|
2184
|
-
|
|
2185
1790
|
player.pause = function () {
|
|
2186
1791
|
cancelWaiting();
|
|
2187
1792
|
originalPause.apply(this, arguments);
|
|
2188
1793
|
};
|
|
2189
|
-
|
|
2190
1794
|
function pauseAndPreloadOnUnderrun() {
|
|
2191
1795
|
if (bufferUnderrun()) {
|
|
2192
1796
|
pauseAndPreload();
|
|
2193
1797
|
}
|
|
2194
1798
|
}
|
|
2195
|
-
|
|
2196
1799
|
function bufferUnderrun() {
|
|
2197
1800
|
return !player.isBufferedAhead(0.1, true) && !player.waitingOnUnderrun && !ignoringUnderruns();
|
|
2198
1801
|
}
|
|
2199
|
-
|
|
2200
1802
|
function pauseAndPreload() {
|
|
2201
1803
|
log('Buffer underrun');
|
|
2202
1804
|
player.trigger('bufferunderrun');
|
|
@@ -2212,9 +1814,8 @@ var bufferUnderrunWaiting = function bufferUnderrunWaiting(player) {
|
|
|
2212
1814
|
player.trigger('bufferunderruncontinue');
|
|
2213
1815
|
player.play();
|
|
2214
1816
|
}
|
|
2215
|
-
},
|
|
1817
|
+
}, () => {});
|
|
2216
1818
|
}
|
|
2217
|
-
|
|
2218
1819
|
function cancelWaiting() {
|
|
2219
1820
|
if (player.waitingOnUnderrun) {
|
|
2220
1821
|
player.ignoreUnderrunsUntil = new Date().getTime() + 5 * 1000;
|
|
@@ -2222,21 +1823,16 @@ var bufferUnderrunWaiting = function bufferUnderrunWaiting(player) {
|
|
|
2222
1823
|
player.trigger('bufferunderruncontinue');
|
|
2223
1824
|
}
|
|
2224
1825
|
}
|
|
2225
|
-
|
|
2226
1826
|
function ignoringUnderruns() {
|
|
2227
1827
|
var r = player.ignoreUnderrunsUntil && new Date().getTime() < player.ignoreUnderrunsUntil;
|
|
2228
|
-
|
|
2229
1828
|
if (r) {
|
|
2230
1829
|
log('ignoring underrun');
|
|
2231
1830
|
}
|
|
2232
|
-
|
|
2233
1831
|
return r;
|
|
2234
1832
|
}
|
|
2235
|
-
|
|
2236
1833
|
function stopListeningForProgress() {
|
|
2237
1834
|
player.off('progress', pauseAndPreloadOnUnderrun);
|
|
2238
1835
|
}
|
|
2239
|
-
|
|
2240
1836
|
if (browser.has('buffer underrun waiting support')) {
|
|
2241
1837
|
player.on('play', function () {
|
|
2242
1838
|
player.on('progress', pauseAndPreloadOnUnderrun);
|
|
@@ -2246,7 +1842,7 @@ var bufferUnderrunWaiting = function bufferUnderrunWaiting(player) {
|
|
|
2246
1842
|
}
|
|
2247
1843
|
};
|
|
2248
1844
|
|
|
2249
|
-
|
|
1845
|
+
const rewindMethod$1 = function (player) {
|
|
2250
1846
|
/**
|
|
2251
1847
|
* Seek to beginning of file. If already at the beginning do
|
|
2252
1848
|
* nothing.
|
|
@@ -2264,28 +1860,23 @@ var rewindMethod$1 = function rewindMethod(player) {
|
|
|
2264
1860
|
};
|
|
2265
1861
|
};
|
|
2266
1862
|
|
|
2267
|
-
|
|
1863
|
+
const VideoPlayer = function (element, options) {
|
|
2268
1864
|
options = options || {};
|
|
2269
1865
|
element = filterSources(element);
|
|
2270
1866
|
var player = VideoJS(element, options);
|
|
2271
|
-
|
|
2272
1867
|
if (options.useSlimPlayerControlsDuringPhonePlayback) {
|
|
2273
1868
|
useSlimPlayerControlsDuringPhonePlayback(player);
|
|
2274
1869
|
}
|
|
2275
|
-
|
|
2276
1870
|
prebuffering(player);
|
|
2277
1871
|
cueSettingsMethods(player);
|
|
2278
1872
|
getMediaElementMethod$1(player);
|
|
2279
1873
|
rewindMethod$1(player);
|
|
2280
|
-
|
|
2281
1874
|
if (options.mediaEvents) {
|
|
2282
1875
|
mediaEvents$1(player, options.context);
|
|
2283
1876
|
}
|
|
2284
|
-
|
|
2285
1877
|
if (options.bufferUnderrunWaiting) {
|
|
2286
1878
|
bufferUnderrunWaiting(player);
|
|
2287
1879
|
}
|
|
2288
|
-
|
|
2289
1880
|
mediaPlayer.enhance(player, options);
|
|
2290
1881
|
return player;
|
|
2291
1882
|
};
|
|
@@ -2297,9 +1888,9 @@ VideoPlayer.mediaEvents = mediaEvents$1;
|
|
|
2297
1888
|
VideoPlayer.cueSettingsMethods = cueSettingsMethods;
|
|
2298
1889
|
VideoPlayer.bufferUnderrunWaiting = bufferUnderrunWaiting;
|
|
2299
1890
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
1891
|
+
const createMediaPlayer = function (options) {
|
|
1892
|
+
let isAudio = options.tagName == 'AUDIO';
|
|
1893
|
+
const player = new VideoPlayer(options.mediaElement, {
|
|
2303
1894
|
controlBar: false,
|
|
2304
1895
|
loadingSpinner: false,
|
|
2305
1896
|
bigPlayButton: false,
|
|
@@ -2325,11 +1916,10 @@ var createMediaPlayer = function createMediaPlayer(options) {
|
|
|
2325
1916
|
context: null
|
|
2326
1917
|
});
|
|
2327
1918
|
player.textTrackSettings = {
|
|
2328
|
-
getValues
|
|
1919
|
+
getValues() {
|
|
2329
1920
|
return {};
|
|
2330
1921
|
}
|
|
2331
1922
|
};
|
|
2332
|
-
|
|
2333
1923
|
player.playOrPlayOnLoad = function () {
|
|
2334
1924
|
if (this.readyState() > 0) {
|
|
2335
1925
|
player.play();
|
|
@@ -2337,7 +1927,6 @@ var createMediaPlayer = function createMediaPlayer(options) {
|
|
|
2337
1927
|
player.on('loadedmetadata', player.play);
|
|
2338
1928
|
}
|
|
2339
1929
|
};
|
|
2340
|
-
|
|
2341
1930
|
player.addClass('video-js');
|
|
2342
1931
|
player.addClass('player');
|
|
2343
1932
|
return player;
|
|
@@ -2358,9 +1947,10 @@ var createMediaPlayer = function createMediaPlayer(options) {
|
|
|
2358
1947
|
* See the License for the specific language governing permissions and
|
|
2359
1948
|
* limitations under the License.
|
|
2360
1949
|
*/
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
1950
|
+
|
|
1951
|
+
const BLANK_AUDIO_SRC = 'data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBA' + 'AAAABAAEAIlYAAESsAAACABAAZGF0YRAAAAAAAAAAAAAAAAAAAAAAAA==';
|
|
1952
|
+
const BLANK_VIDEO_SRC = 'data:video/mp4;base64,AAAAHGZ0eXBNNFYgAAACAG' + 'lzb21pc28yYXZjMQAAAAhmcmVlAAAGF21kYXTeBAAAbGliZmFhYyAxLjI4AABCAJMgBDIARw' + 'AAArEGBf//rdxF6b3m2Ui3lizYINkj7u94MjY0IC0gY29yZSAxNDIgcjIgOTU2YzhkOCAtIE' + 'guMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTQgLSBodHRwOi8vd3' + 'd3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSBvcHRpb25zOiBjYWJhYz0wIHJlZj0zIGRlYm' + 'xvY2s9MTowOjAgYW5hbHlzZT0weDE6MHgxMTEgbWU9aGV4IHN1Ym1lPTcgcHN5PTEgcHN5X3' + 'JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbG' + 'lzPTEgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV' + '9xcF9vZmZzZXQ9LTIgdGhyZWFkcz02IGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3Rocm' + 'VhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb2' + '5zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTI1MCBrZXlpbn' + 'RfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NDAgcm' + 'M9Y3JmIG1idHJlZT0xIGNyZj0yMy4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcH' + 'N0ZXA9NCB2YnZfbWF4cmF0ZT03NjggdmJ2X2J1ZnNpemU9MzAwMCBjcmZfbWF4PTAuMCBuYW' + 'xfaHJkPW5vbmUgZmlsbGVyPTAgaXBfcmF0aW89MS40MCBhcT0xOjEuMDAAgAAAAFZliIQL8m' + 'KAAKvMnJycnJycnJycnXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' + 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXiEASZACGQAjgCEASZACGQAjgAAAAAdBmjgX4G' + 'SAIQBJkAIZACOAAAAAB0GaVAX4GSAhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpgL8DJIQBJkA' + 'IZACOAIQBJkAIZACOAAAAABkGagC/AySEASZACGQAjgAAAAAZBmqAvwMkhAEmQAhkAI4AhAE' + 'mQAhkAI4AAAAAGQZrAL8DJIQBJkAIZACOAAAAABkGa4C/AySEASZACGQAjgCEASZACGQAjgA' + 'AAAAZBmwAvwMkhAEmQAhkAI4AAAAAGQZsgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGbQC' + '/AySEASZACGQAjgCEASZACGQAjgAAAAAZBm2AvwMkhAEmQAhkAI4AAAAAGQZuAL8DJIQBJkA' + 'IZACOAIQBJkAIZACOAAAAABkGboC/AySEASZACGQAjgAAAAAZBm8AvwMkhAEmQAhkAI4AhAE' + 'mQAhkAI4AAAAAGQZvgL8DJIQBJkAIZACOAAAAABkGaAC/AySEASZACGQAjgCEASZACGQAjgA' + 'AAAAZBmiAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpAL8DJIQBJkAIZACOAAAAABkGaYC' + '/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmoAvwMkhAEmQAhkAI4AAAAAGQZqgL8DJIQBJkA' + 'IZACOAIQBJkAIZACOAAAAABkGawC/AySEASZACGQAjgAAAAAZBmuAvwMkhAEmQAhkAI4AhAE' + 'mQAhkAI4AAAAAGQZsAL8DJIQBJkAIZACOAAAAABkGbIC/AySEASZACGQAjgCEASZACGQAjgA' + 'AAAAZBm0AvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZtgL8DJIQBJkAIZACOAAAAABkGbgC' + 'vAySEASZACGQAjgCEASZACGQAjgAAAAAZBm6AnwMkhAEmQAhkAI4AhAEmQAhkAI4AhAEmQAh' + 'kAI4AhAEmQAhkAI4AAAAhubW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAD6AAABDcAAQAAAQ' + 'AAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAzB0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAA' + 'AAAAAAA+kAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAA' + 'BAAAAAALAAAACQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAPpAAAAAAABAAAAAAKobW' + 'RpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAB1MAAAdU5VxAAAAAAALWhkbHIAAAAAAAAAAHZpZG' + 'UAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAACU21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAA' + 'AAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAhNzdGJsAAAAr3N0c2QAAA' + 'AAAAAAAQAAAJ9hdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAALAAkABIAAAASAAAAAAAAA' + 'ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAALWF2Y0MBQsAN/+EAFW' + 'dCwA3ZAsTsBEAAAPpAADqYA8UKkgEABWjLg8sgAAAAHHV1aWRraEDyXyRPxbo5pRvPAyPzAA' + 'AAAAAAABhzdHRzAAAAAAAAAAEAAAAeAAAD6QAAABRzdHNzAAAAAAAAAAEAAAABAAAAHHN0c2' + 'MAAAAAAAAAAQAAAAEAAAABAAAAAQAAAIxzdHN6AAAAAAAAAAAAAAAeAAADDwAAAAsAAAALAA' + 'AACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAA' + 'oAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAA' + 'AAiHN0Y28AAAAAAAAAHgAAAEYAAANnAAADewAAA5gAAAO0AAADxwAAA+MAAAP2AAAEEgAABC' + 'UAAARBAAAEXQAABHAAAASMAAAEnwAABLsAAATOAAAE6gAABQYAAAUZAAAFNQAABUgAAAVkAA' + 'AFdwAABZMAAAWmAAAFwgAABd4AAAXxAAAGDQAABGh0cmFrAAAAXHRraGQAAAADAAAAAAAAAA' + 'AAAAACAAAAAAAABDcAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAA' + 'AAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAQkAAADcAABAA' + 'AAAAPgbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAC7gAAAykBVxAAAAAAALWhkbHIAAAAAAA' + 'AAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAADi21pbmYAAAAQc21oZAAAAAAAAA' + 'AAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAADT3N0YmwAAABnc3RzZA' + 'AAAAAAAAABAAAAV21wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAAC7gAAAAAAAM2VzZHMAAA' + 'AAA4CAgCIAAgAEgICAFEAVBbjYAAu4AAAADcoFgICAAhGQBoCAgAECAAAAIHN0dHMAAAAAAA' + 'AAAgAAADIAAAQAAAAAAQAAAkAAAAFUc3RzYwAAAAAAAAAbAAAAAQAAAAEAAAABAAAAAgAAAA' + 'IAAAABAAAAAwAAAAEAAAABAAAABAAAAAIAAAABAAAABgAAAAEAAAABAAAABwAAAAIAAAABAA' + 'AACAAAAAEAAAABAAAACQAAAAIAAAABAAAACgAAAAEAAAABAAAACwAAAAIAAAABAAAADQAAAA' + 'EAAAABAAAADgAAAAIAAAABAAAADwAAAAEAAAABAAAAEAAAAAIAAAABAAAAEQAAAAEAAAABAA' + 'AAEgAAAAIAAAABAAAAFAAAAAEAAAABAAAAFQAAAAIAAAABAAAAFgAAAAEAAAABAAAAFwAAAA' + 'IAAAABAAAAGAAAAAEAAAABAAAAGQAAAAIAAAABAAAAGgAAAAEAAAABAAAAGwAAAAIAAAABAA' + 'AAHQAAAAEAAAABAAAAHgAAAAIAAAABAAAAHwAAAAQAAAABAAAA4HN0c3oAAAAAAAAAAAAAAD' + 'MAAAAaAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAA' + 'AACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAA' + 'kAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAA' + 'AACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAA' + 'AAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAA' + 'AEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ' + '0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAA' + 'AAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYX' + 'ZmNTUuMzMuMTAw';
|
|
1953
|
+
const blankSources = {
|
|
2364
1954
|
audio: {
|
|
2365
1955
|
src: BLANK_AUDIO_SRC,
|
|
2366
1956
|
type: 'audio/wav'
|
|
@@ -2372,256 +1962,199 @@ var blankSources = {
|
|
|
2372
1962
|
};
|
|
2373
1963
|
|
|
2374
1964
|
/** @const @enum {string} */
|
|
2375
|
-
|
|
2376
|
-
var MediaType = {
|
|
1965
|
+
const MediaType = {
|
|
2377
1966
|
AUDIO: 'audio',
|
|
2378
1967
|
VIDEO: 'video'
|
|
2379
1968
|
};
|
|
2380
|
-
|
|
1969
|
+
let elId = 0;
|
|
1970
|
+
|
|
2381
1971
|
/**
|
|
2382
1972
|
* Media pool class handles the pool of Videojs media players
|
|
2383
1973
|
*/
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
2390
|
-
playerCount: 4
|
|
2391
|
-
};
|
|
2392
|
-
|
|
2393
|
-
_classCallCheck(this, MediaPool);
|
|
2394
|
-
|
|
1974
|
+
class MediaPool {
|
|
1975
|
+
constructor(options = {
|
|
1976
|
+
playerCount: 4
|
|
1977
|
+
}) {
|
|
2395
1978
|
this.playerCount = options.playerCount;
|
|
2396
1979
|
this.allocatedPlayers = {};
|
|
2397
1980
|
this.unAllocatedPlayers = {};
|
|
2398
|
-
this.mediaFactory_ =
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
_createClass(MediaPool, [{
|
|
2410
|
-
key: "allocatePlayer",
|
|
2411
|
-
value: function allocatePlayer(_ref) {
|
|
2412
|
-
var playerType = _ref.playerType,
|
|
2413
|
-
playerId = _ref.playerId,
|
|
2414
|
-
playsInline = _ref.playsInline,
|
|
2415
|
-
mediaEventsContextData = _ref.mediaEventsContextData,
|
|
2416
|
-
hooks = _ref.hooks,
|
|
2417
|
-
poster = _ref.poster,
|
|
2418
|
-
_ref$loop = _ref.loop,
|
|
2419
|
-
loop = _ref$loop === void 0 ? false : _ref$loop,
|
|
2420
|
-
_ref$controls = _ref.controls,
|
|
2421
|
-
controls = _ref$controls === void 0 ? false : _ref$controls,
|
|
2422
|
-
altText = _ref.altText,
|
|
2423
|
-
onRelease = _ref.onRelease;
|
|
2424
|
-
var player = undefined;
|
|
2425
|
-
|
|
2426
|
-
if (!this.unAllocatedPlayers[playerType]) {
|
|
2427
|
-
this.populateMediaPool_();
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
if (this.unAllocatedPlayers[playerType].length == 0) {
|
|
2431
|
-
this.freeOnePlayer(playerType);
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
player = this.unAllocatedPlayers[playerType].pop();
|
|
2435
|
-
|
|
2436
|
-
if (player) {
|
|
2437
|
-
player.pause();
|
|
2438
|
-
player.getMediaElement().loop = loop;
|
|
2439
|
-
player.getMediaElement().setAttribute('alt', altText);
|
|
2440
|
-
player.poster(poster);
|
|
2441
|
-
player.controls(controls);
|
|
2442
|
-
|
|
2443
|
-
if (playsInline) {
|
|
2444
|
-
player.playsinline(true);
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
player.updateHooks(hooks || {});
|
|
2448
|
-
player.updateMediaEventsContext(mediaEventsContextData);
|
|
2449
|
-
this.allocatedPlayers[playerType].push(player);
|
|
2450
|
-
player.playerId = playerId || this.allocatedPlayers[playerType].length;
|
|
2451
|
-
player.releaseCallback = onRelease;
|
|
2452
|
-
return player;
|
|
2453
|
-
} else {
|
|
2454
|
-
console.log('no player found for allocation');
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
}, {
|
|
2458
|
-
key: "freeOnePlayer",
|
|
2459
|
-
value: function freeOnePlayer(type) {
|
|
2460
|
-
this.unAllocatePlayer(this.allocatedPlayers[type][0]); // free up the first allocated player
|
|
2461
|
-
}
|
|
2462
|
-
}, {
|
|
2463
|
-
key: "unAllocatePlayer",
|
|
2464
|
-
value: function unAllocatePlayer(player) {
|
|
2465
|
-
if (player) {
|
|
2466
|
-
var type = this.getMediaTypeFromEl(player.el());
|
|
2467
|
-
this.allocatedPlayers[type] = this.allocatedPlayers[type].filter(function (p) {
|
|
2468
|
-
return p != player;
|
|
2469
|
-
});
|
|
2470
|
-
player.controls(false);
|
|
2471
|
-
player.getMediaElement().loop = false;
|
|
2472
|
-
player.playsinline(false);
|
|
2473
|
-
player.src(blankSources[type]);
|
|
2474
|
-
player.poster('');
|
|
2475
|
-
clearTextTracks(player);
|
|
2476
|
-
this.unAllocatedPlayers[type].push(player);
|
|
2477
|
-
|
|
2478
|
-
if (player.releaseCallback) {
|
|
2479
|
-
player.releaseCallback();
|
|
2480
|
-
player.releaseCallback = null;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
}, {
|
|
2485
|
-
key: "blessAll",
|
|
2486
|
-
value: function blessAll(value) {
|
|
2487
|
-
var _this = this;
|
|
2488
|
-
|
|
2489
|
-
if (this.unAllocatedPlayers[MediaType.AUDIO] == undefined || this.unAllocatedPlayers[MediaType.VIDEO] == undefined) {
|
|
2490
|
-
this.populateMediaPool_();
|
|
2491
|
-
}
|
|
2492
|
-
|
|
2493
|
-
this.forEachMediaType(function (key) {
|
|
2494
|
-
_this.allPlayersForType(MediaType[key]).forEach(function (player) {
|
|
2495
|
-
player.muted(value);
|
|
2496
|
-
});
|
|
2497
|
-
});
|
|
2498
|
-
}
|
|
2499
|
-
}, {
|
|
2500
|
-
key: "allPlayersForType",
|
|
2501
|
-
value: function allPlayersForType(type) {
|
|
2502
|
-
if (this.unAllocatedPlayers[type]) {
|
|
2503
|
-
return [].concat(_toConsumableArray(this.unAllocatedPlayers[type]), _toConsumableArray(this.allocatedPlayers[type]));
|
|
1981
|
+
this.mediaFactory_ = {
|
|
1982
|
+
[MediaType.AUDIO]: () => {
|
|
1983
|
+
const audioEl = document.createElement('audio');
|
|
1984
|
+
audioEl.setAttribute('crossorigin', 'anonymous');
|
|
1985
|
+
return audioEl;
|
|
1986
|
+
},
|
|
1987
|
+
[MediaType.VIDEO]: () => {
|
|
1988
|
+
const videoEl = document.createElement('video');
|
|
1989
|
+
videoEl.setAttribute('crossorigin', 'anonymous');
|
|
1990
|
+
return videoEl;
|
|
2504
1991
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
allocatePlayer({
|
|
1995
|
+
playerType,
|
|
1996
|
+
playerId,
|
|
1997
|
+
playsInline,
|
|
1998
|
+
mediaEventsContextData,
|
|
1999
|
+
hooks,
|
|
2000
|
+
poster,
|
|
2001
|
+
loop = false,
|
|
2002
|
+
controls = false,
|
|
2003
|
+
altText,
|
|
2004
|
+
onRelease
|
|
2005
|
+
}) {
|
|
2006
|
+
let player = undefined;
|
|
2007
|
+
if (!this.unAllocatedPlayers[playerType]) {
|
|
2008
|
+
this.populateMediaPool_();
|
|
2009
|
+
}
|
|
2010
|
+
if (this.unAllocatedPlayers[playerType].length == 0) {
|
|
2011
|
+
this.freeOnePlayer(playerType);
|
|
2012
|
+
}
|
|
2013
|
+
player = this.unAllocatedPlayers[playerType].pop();
|
|
2014
|
+
if (player) {
|
|
2015
|
+
player.pause();
|
|
2016
|
+
player.getMediaElement().loop = loop;
|
|
2017
|
+
player.getMediaElement().setAttribute('alt', altText);
|
|
2018
|
+
player.poster(poster);
|
|
2019
|
+
player.controls(controls);
|
|
2020
|
+
if (playsInline) {
|
|
2021
|
+
player.playsinline(true);
|
|
2515
2022
|
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2023
|
+
player.updateHooks(hooks || {});
|
|
2024
|
+
player.updateMediaEventsContext(mediaEventsContextData);
|
|
2025
|
+
this.allocatedPlayers[playerType].push(player);
|
|
2026
|
+
player.playerId = playerId || this.allocatedPlayers[playerType].length;
|
|
2027
|
+
player.releaseCallback = onRelease;
|
|
2028
|
+
player.previousSrc = null;
|
|
2029
|
+
player.triggerMediaAllocate();
|
|
2030
|
+
return player;
|
|
2031
|
+
} else {
|
|
2032
|
+
console.log('no player found for allocation');
|
|
2518
2033
|
}
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2034
|
+
}
|
|
2035
|
+
freeOnePlayer(type) {
|
|
2036
|
+
this.unAllocatePlayer(this.allocatedPlayers[type][0]); // free up the first allocated player
|
|
2037
|
+
}
|
|
2038
|
+
unAllocatePlayer(player) {
|
|
2039
|
+
if (player) {
|
|
2040
|
+
player.triggerMediaRelease();
|
|
2041
|
+
let type = this.getMediaTypeFromEl(player.el());
|
|
2042
|
+
this.allocatedPlayers[type] = this.allocatedPlayers[type].filter(p => p != player);
|
|
2043
|
+
player.previousSrc = player.currentSrc();
|
|
2044
|
+
player.controls(false);
|
|
2045
|
+
player.getMediaElement().loop = false;
|
|
2046
|
+
player.playsinline(false);
|
|
2047
|
+
player.src(blankSources[type]);
|
|
2048
|
+
player.poster('');
|
|
2049
|
+
clearTextTracks(player);
|
|
2050
|
+
this.unAllocatedPlayers[type].push(player);
|
|
2051
|
+
if (player.releaseCallback) {
|
|
2052
|
+
player.releaseCallback();
|
|
2053
|
+
player.releaseCallback = null;
|
|
2528
2054
|
}
|
|
2055
|
+
player.pause();
|
|
2529
2056
|
}
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2057
|
+
}
|
|
2058
|
+
blessAll(value) {
|
|
2059
|
+
if (this.unAllocatedPlayers[MediaType.AUDIO] == undefined || this.unAllocatedPlayers[MediaType.VIDEO] == undefined) {
|
|
2060
|
+
this.populateMediaPool_();
|
|
2534
2061
|
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
mediaEl.setAttribute('pool-element', elId++);
|
|
2539
|
-
|
|
2540
|
-
if (!this.unAllocatedPlayers[type]) {
|
|
2541
|
-
this.unAllocatedPlayers[type] = [];
|
|
2542
|
-
this.allocatedPlayers[type] = [];
|
|
2543
|
-
}
|
|
2544
|
-
|
|
2545
|
-
var player = createMediaPlayer({
|
|
2546
|
-
mediaElement: mediaEl,
|
|
2547
|
-
tagName: type
|
|
2062
|
+
this.forEachMediaType(key => {
|
|
2063
|
+
this.allPlayersForType(MediaType[key]).forEach(player => {
|
|
2064
|
+
player.muted(value);
|
|
2548
2065
|
});
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
allPlayersForType(type) {
|
|
2069
|
+
if (this.unAllocatedPlayers[type]) {
|
|
2070
|
+
return [...this.unAllocatedPlayers[type], ...this.allocatedPlayers[type]];
|
|
2553
2071
|
}
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
this.createPlayer_(type, mediaElSeed.cloneNode(true));
|
|
2561
|
-
}
|
|
2072
|
+
return [];
|
|
2073
|
+
}
|
|
2074
|
+
getMediaTypeFromEl(mediaElement) {
|
|
2075
|
+
let tagName = mediaElement.tagName.toLowerCase();
|
|
2076
|
+
if (tagName == 'div') {
|
|
2077
|
+
tagName = mediaElement.children[0].tagName.toLowerCase();
|
|
2562
2078
|
}
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
var mediaEl = _this2.mediaFactory_[type].call(_this2);
|
|
2572
|
-
|
|
2573
|
-
_this2.initializeMediaPool_(type, mediaEl);
|
|
2574
|
-
});
|
|
2079
|
+
return this.getMediaType(tagName);
|
|
2080
|
+
}
|
|
2081
|
+
getMediaType(tagName) {
|
|
2082
|
+
switch (tagName) {
|
|
2083
|
+
case 'audio':
|
|
2084
|
+
return MediaType.AUDIO;
|
|
2085
|
+
case 'video':
|
|
2086
|
+
return MediaType.VIDEO;
|
|
2575
2087
|
}
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2088
|
+
}
|
|
2089
|
+
forEachMediaType(callbackFn) {
|
|
2090
|
+
Object.keys(MediaType).forEach(callbackFn.bind(this));
|
|
2091
|
+
}
|
|
2092
|
+
createPlayer_(type, mediaEl) {
|
|
2093
|
+
mediaEl.setAttribute('pool-element', elId++);
|
|
2094
|
+
if (!this.unAllocatedPlayers[type]) {
|
|
2095
|
+
this.unAllocatedPlayers[type] = [];
|
|
2096
|
+
this.allocatedPlayers[type] = [];
|
|
2097
|
+
}
|
|
2098
|
+
let player = createMediaPlayer({
|
|
2099
|
+
mediaElement: mediaEl,
|
|
2100
|
+
tagName: type
|
|
2101
|
+
});
|
|
2102
|
+
mediaEl.setAttribute('src', blankSources[type].src);
|
|
2103
|
+
player.muted(true);
|
|
2104
|
+
this.unAllocatedPlayers[type].push(player);
|
|
2105
|
+
return player;
|
|
2106
|
+
}
|
|
2107
|
+
initializeMediaPool_(type, mediaElSeed) {
|
|
2108
|
+
const playerCount = typeof this.playerCount === 'function' ? this.playerCount(type) : this.playerCount;
|
|
2109
|
+
while (this.allPlayersForType(type).length < playerCount) {
|
|
2110
|
+
this.createPlayer_(type, mediaElSeed.cloneNode(true));
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
populateMediaPool_() {
|
|
2114
|
+
this.forEachMediaType(key => {
|
|
2115
|
+
let type = MediaType[key];
|
|
2116
|
+
let mediaEl = this.mediaFactory_[type].call(this);
|
|
2117
|
+
this.initializeMediaPool_(type, mediaEl);
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2581
2121
|
function clearTextTracks(player) {
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2122
|
+
const tracks = player.textTracks();
|
|
2123
|
+
let i = tracks.length;
|
|
2585
2124
|
while (i--) {
|
|
2586
2125
|
player.removeRemoteTextTrack(tracks[i]);
|
|
2587
2126
|
}
|
|
2588
2127
|
}
|
|
2589
2128
|
|
|
2590
|
-
|
|
2129
|
+
const media = {
|
|
2591
2130
|
playerPool: new MediaPool({
|
|
2592
|
-
playerCount:
|
|
2593
|
-
return features.isEnabled('large_player_pool') ? 10 : 4;
|
|
2594
|
-
}
|
|
2131
|
+
playerCount: () => features.isEnabled('large_player_pool') ? 10 : 4
|
|
2595
2132
|
}),
|
|
2596
2133
|
muteState: true,
|
|
2597
|
-
|
|
2598
2134
|
get muted() {
|
|
2599
2135
|
return this.muteState;
|
|
2600
2136
|
},
|
|
2601
|
-
|
|
2602
|
-
mute: function mute(value) {
|
|
2137
|
+
mute: function (value) {
|
|
2603
2138
|
this.muteState = value;
|
|
2604
2139
|
this.playerPool.blessAll(value);
|
|
2605
2140
|
this.trigger('change:muted', value);
|
|
2606
2141
|
},
|
|
2607
|
-
getPlayer: function
|
|
2142
|
+
getPlayer: function (fileSource, options) {
|
|
2608
2143
|
options.playerType = options.tagName || MediaType.VIDEO;
|
|
2609
|
-
|
|
2610
|
-
|
|
2144
|
+
let player = this.playerPool.allocatePlayer(options);
|
|
2611
2145
|
if (player) {
|
|
2612
2146
|
player.muted(this.muteState);
|
|
2613
2147
|
player.src(fileSource);
|
|
2614
|
-
|
|
2615
2148
|
if (options.textTrackSources) {
|
|
2616
|
-
options.textTrackSources.forEach(
|
|
2617
|
-
|
|
2618
|
-
|
|
2149
|
+
options.textTrackSources.forEach(track => player.addRemoteTextTrack(track, true));
|
|
2150
|
+
}
|
|
2151
|
+
if (browser.has('video scaling bug fixed by load')) {
|
|
2152
|
+
player.load();
|
|
2619
2153
|
}
|
|
2620
|
-
|
|
2621
2154
|
return player;
|
|
2622
2155
|
}
|
|
2623
2156
|
},
|
|
2624
|
-
releasePlayer: function
|
|
2157
|
+
releasePlayer: function (player) {
|
|
2625
2158
|
if (player) {
|
|
2626
2159
|
this.playerPool.unAllocatePlayer(player);
|
|
2627
2160
|
}
|
|
@@ -2634,47 +2167,39 @@ Object.assign(media, BackboneEvents);
|
|
|
2634
2167
|
*
|
|
2635
2168
|
* @class
|
|
2636
2169
|
*/
|
|
2637
|
-
|
|
2638
|
-
var MultiPlayer = function MultiPlayer(pool, options) {
|
|
2170
|
+
const MultiPlayer = function (pool, options) {
|
|
2639
2171
|
if (options.crossFade && options.playFromBeginning) {
|
|
2640
2172
|
throw 'pageflow.Audio.MultiPlayer: The options crossFade and playFromBeginning can not be used together at the moment.';
|
|
2641
2173
|
}
|
|
2642
|
-
|
|
2643
2174
|
var current = new AudioPlayer.Null();
|
|
2644
2175
|
var currentId = null;
|
|
2645
2176
|
var that = this;
|
|
2177
|
+
|
|
2646
2178
|
/**
|
|
2647
2179
|
* Continue playback.
|
|
2648
2180
|
*/
|
|
2649
|
-
|
|
2650
2181
|
this.resume = function () {
|
|
2651
2182
|
return current.play();
|
|
2652
2183
|
};
|
|
2184
|
+
|
|
2653
2185
|
/**
|
|
2654
2186
|
* Continue playback with fade in.
|
|
2655
2187
|
*/
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
2188
|
this.resumeAndFadeIn = function () {
|
|
2659
2189
|
return current.playAndFadeIn(options.fadeDuration);
|
|
2660
2190
|
};
|
|
2661
|
-
|
|
2662
2191
|
this.seek = function (position) {
|
|
2663
2192
|
return current.seek(position);
|
|
2664
2193
|
};
|
|
2665
|
-
|
|
2666
2194
|
this.pause = function () {
|
|
2667
2195
|
return current.pause();
|
|
2668
2196
|
};
|
|
2669
|
-
|
|
2670
2197
|
this.paused = function () {
|
|
2671
2198
|
return current.paused();
|
|
2672
2199
|
};
|
|
2673
|
-
|
|
2674
2200
|
this.fadeOutAndPause = function () {
|
|
2675
2201
|
return current.fadeOutAndPause(options.fadeDuration);
|
|
2676
2202
|
};
|
|
2677
|
-
|
|
2678
2203
|
this.fadeOutIfPlaying = function () {
|
|
2679
2204
|
if (current.paused()) {
|
|
2680
2205
|
return Promise.resolve();
|
|
@@ -2682,48 +2207,38 @@ var MultiPlayer = function MultiPlayer(pool, options) {
|
|
|
2682
2207
|
return current.fadeOutAndPause(options.fadeDuration);
|
|
2683
2208
|
}
|
|
2684
2209
|
};
|
|
2685
|
-
|
|
2686
2210
|
this.position = function () {
|
|
2687
2211
|
return current.position;
|
|
2688
2212
|
};
|
|
2689
|
-
|
|
2690
2213
|
this.duration = function () {
|
|
2691
2214
|
return current.duration;
|
|
2692
2215
|
};
|
|
2693
|
-
|
|
2694
2216
|
this.fadeTo = function (id) {
|
|
2695
2217
|
return changeCurrent(id, function (player) {
|
|
2696
2218
|
return player.playAndFadeIn(options.fadeDuration);
|
|
2697
2219
|
});
|
|
2698
2220
|
};
|
|
2699
|
-
|
|
2700
2221
|
this.play = function (id) {
|
|
2701
2222
|
return changeCurrent(id, function (player) {
|
|
2702
2223
|
return player.play();
|
|
2703
2224
|
});
|
|
2704
2225
|
};
|
|
2705
|
-
|
|
2706
2226
|
this.changeVolumeFactor = function (factor) {
|
|
2707
2227
|
return current.changeVolumeFactor(factor, options.fadeDuration);
|
|
2708
2228
|
};
|
|
2709
|
-
|
|
2710
2229
|
this.formatTime = function (time) {
|
|
2711
2230
|
return current.formatTime(time);
|
|
2712
2231
|
};
|
|
2713
|
-
|
|
2714
2232
|
function changeCurrent(id, callback) {
|
|
2715
2233
|
if (!options.playFromBeginning && id === currentId && !current.paused()) {
|
|
2716
2234
|
return Promise.resolve();
|
|
2717
2235
|
}
|
|
2718
|
-
|
|
2719
2236
|
var player = pool.get(id);
|
|
2720
2237
|
currentId = id;
|
|
2721
2238
|
var fadeOutPromise = current.fadeOutAndPause(options.fadeDuration);
|
|
2722
|
-
|
|
2723
2239
|
if (current._stopMultiPlayerEventPropagation && current.paused()) {
|
|
2724
2240
|
current._stopMultiPlayerEventPropagation();
|
|
2725
2241
|
}
|
|
2726
|
-
|
|
2727
2242
|
return handleCrossFade(fadeOutPromise).then(function () {
|
|
2728
2243
|
current = player;
|
|
2729
2244
|
startEventPropagation(current, id);
|
|
@@ -2732,7 +2247,6 @@ var MultiPlayer = function MultiPlayer(pool, options) {
|
|
|
2732
2247
|
});
|
|
2733
2248
|
});
|
|
2734
2249
|
}
|
|
2735
|
-
|
|
2736
2250
|
function handleCrossFade(fadePomise) {
|
|
2737
2251
|
if (options.crossFade) {
|
|
2738
2252
|
return Promise.resolve();
|
|
@@ -2740,7 +2254,6 @@ var MultiPlayer = function MultiPlayer(pool, options) {
|
|
|
2740
2254
|
return fadePomise;
|
|
2741
2255
|
}
|
|
2742
2256
|
}
|
|
2743
|
-
|
|
2744
2257
|
function handlePlayFromBeginning(player) {
|
|
2745
2258
|
if (options.playFromBeginning || options.rewindOnChange) {
|
|
2746
2259
|
return player.rewind();
|
|
@@ -2748,48 +2261,40 @@ var MultiPlayer = function MultiPlayer(pool, options) {
|
|
|
2748
2261
|
return Promise.resolve();
|
|
2749
2262
|
}
|
|
2750
2263
|
}
|
|
2751
|
-
|
|
2752
2264
|
function startEventPropagation(player, id) {
|
|
2753
|
-
|
|
2265
|
+
let playCallback = function () {
|
|
2754
2266
|
that.trigger('play', {
|
|
2755
2267
|
audioFileId: id
|
|
2756
2268
|
});
|
|
2757
2269
|
};
|
|
2758
|
-
|
|
2759
|
-
var pauseCallback = function pauseCallback() {
|
|
2270
|
+
let pauseCallback = function () {
|
|
2760
2271
|
that.trigger('pause', {
|
|
2761
2272
|
audioFileId: id
|
|
2762
2273
|
});
|
|
2763
|
-
|
|
2764
2274
|
if (currentId !== id) {
|
|
2765
2275
|
player._stopMultiPlayerEventPropagation();
|
|
2766
2276
|
}
|
|
2767
2277
|
};
|
|
2768
|
-
|
|
2769
|
-
var timeUpdateCallback = function timeUpdateCallback() {
|
|
2278
|
+
let timeUpdateCallback = function () {
|
|
2770
2279
|
that.trigger('timeupdate', {
|
|
2771
2280
|
audioFileId: id
|
|
2772
2281
|
});
|
|
2773
2282
|
};
|
|
2774
|
-
|
|
2775
|
-
var endedCallback = function endedCallback() {
|
|
2283
|
+
let endedCallback = function () {
|
|
2776
2284
|
that.trigger('ended', {
|
|
2777
2285
|
audioFileId: id
|
|
2778
2286
|
});
|
|
2779
2287
|
};
|
|
2780
|
-
|
|
2781
|
-
var playFailedCallback = function playFailedCallback() {
|
|
2288
|
+
let playFailedCallback = function () {
|
|
2782
2289
|
that.trigger('playfailed', {
|
|
2783
2290
|
audioFileId: id
|
|
2784
2291
|
});
|
|
2785
2292
|
};
|
|
2786
|
-
|
|
2787
2293
|
player.on('play', playCallback);
|
|
2788
2294
|
player.on('pause', pauseCallback);
|
|
2789
2295
|
player.on('timeupdate', timeUpdateCallback);
|
|
2790
2296
|
player.on('ended', endedCallback);
|
|
2791
2297
|
player.on('playfailed', playFailedCallback);
|
|
2792
|
-
|
|
2793
2298
|
player._stopMultiPlayerEventPropagation = function () {
|
|
2794
2299
|
player.off('play', playCallback);
|
|
2795
2300
|
player.off('pause', pauseCallback);
|
|
@@ -2801,54 +2306,48 @@ var MultiPlayer = function MultiPlayer(pool, options) {
|
|
|
2801
2306
|
};
|
|
2802
2307
|
Object.assign(MultiPlayer.prototype, BackboneEvents);
|
|
2803
2308
|
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2309
|
+
const PlayerSourceIDMap = function (media, {
|
|
2310
|
+
playerOptions
|
|
2311
|
+
} = {}) {
|
|
2808
2312
|
return {
|
|
2809
2313
|
current: undefined,
|
|
2810
2314
|
previous: undefined,
|
|
2811
|
-
mapSources: function
|
|
2315
|
+
mapSources: function (id, sources) {
|
|
2812
2316
|
this[id] = sources;
|
|
2813
2317
|
},
|
|
2814
|
-
get: function
|
|
2318
|
+
get: function (sourceID) {
|
|
2815
2319
|
if (!this[sourceID]) {
|
|
2816
2320
|
return new AudioPlayer.Null();
|
|
2817
2321
|
}
|
|
2818
|
-
|
|
2819
2322
|
if (this.current && this.current.playerId === sourceID) {
|
|
2820
2323
|
return this.current;
|
|
2821
2324
|
}
|
|
2822
|
-
|
|
2823
2325
|
if (this.previous && this.previous.playerId === sourceID) {
|
|
2824
|
-
|
|
2326
|
+
let holder = this.current;
|
|
2825
2327
|
this.current = this.previous;
|
|
2826
2328
|
this.previous = holder;
|
|
2827
2329
|
} else {
|
|
2828
2330
|
if (this.previous) {
|
|
2829
2331
|
media.releasePlayer(this.previous);
|
|
2830
2332
|
}
|
|
2831
|
-
|
|
2832
2333
|
this.previous = this.current;
|
|
2833
|
-
this.current = media.getPlayer(this[sourceID],
|
|
2334
|
+
this.current = media.getPlayer(this[sourceID], {
|
|
2834
2335
|
filePermaId: sourceID,
|
|
2835
|
-
playerId: sourceID
|
|
2836
|
-
|
|
2336
|
+
playerId: sourceID,
|
|
2337
|
+
...playerOptions
|
|
2338
|
+
});
|
|
2837
2339
|
}
|
|
2838
|
-
|
|
2839
2340
|
return this.current;
|
|
2840
2341
|
}
|
|
2841
2342
|
};
|
|
2842
2343
|
};
|
|
2843
2344
|
|
|
2844
|
-
|
|
2345
|
+
const PlayerPool = function (audio, options) {
|
|
2845
2346
|
this.players = {};
|
|
2846
|
-
|
|
2847
2347
|
this.get = function (audioFileId) {
|
|
2848
2348
|
this.players[audioFileId] = this.players[audioFileId] || audio.createPlayer(audioFileId, options);
|
|
2849
2349
|
return this.players[audioFileId];
|
|
2850
2350
|
};
|
|
2851
|
-
|
|
2852
2351
|
this.dispose = function () {
|
|
2853
2352
|
this.players = {};
|
|
2854
2353
|
};
|
|
@@ -2859,11 +2358,11 @@ var PlayerPool = function PlayerPool(audio, options) {
|
|
|
2859
2358
|
* @alias pageflow.audio
|
|
2860
2359
|
* @member
|
|
2861
2360
|
*/
|
|
2862
|
-
|
|
2863
|
-
var Audio = function Audio(options) {
|
|
2361
|
+
const Audio = function (options) {
|
|
2864
2362
|
this.getSources = options.getSources || function (audioFileId) {
|
|
2865
2363
|
return options.audioFiles[audioFileId] || '';
|
|
2866
2364
|
};
|
|
2365
|
+
|
|
2867
2366
|
/**
|
|
2868
2367
|
* Creates a player for the given audio file.
|
|
2869
2368
|
*
|
|
@@ -2877,19 +2376,18 @@ var Audio = function Audio(options) {
|
|
|
2877
2376
|
*
|
|
2878
2377
|
* @static
|
|
2879
2378
|
*/
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
2379
|
this.createPlayer = function (audioFileId, options) {
|
|
2883
2380
|
var sources = this.getSources(removeSuffix(audioFileId));
|
|
2884
|
-
|
|
2885
2381
|
if (sources) {
|
|
2886
|
-
return new AudioPlayer(sources,
|
|
2887
|
-
volumeFading: true
|
|
2888
|
-
|
|
2382
|
+
return new AudioPlayer(sources, {
|
|
2383
|
+
volumeFading: true,
|
|
2384
|
+
...options
|
|
2385
|
+
});
|
|
2889
2386
|
} else {
|
|
2890
2387
|
return new AudioPlayer.Null();
|
|
2891
2388
|
}
|
|
2892
2389
|
};
|
|
2390
|
+
|
|
2893
2391
|
/**
|
|
2894
2392
|
* Create a `MultiPlayer` to play and fade between multiple audio
|
|
2895
2393
|
* files.
|
|
@@ -2908,53 +2406,42 @@ var Audio = function Audio(options) {
|
|
|
2908
2406
|
*
|
|
2909
2407
|
* @return {pageflow.Audio.MultiPlayer}
|
|
2910
2408
|
*/
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
2409
|
this.createMultiPlayer = function (options) {
|
|
2914
2410
|
return new MultiPlayer(new PlayerPool(this, options), options);
|
|
2915
2411
|
};
|
|
2916
|
-
|
|
2917
2412
|
function removeSuffix(id) {
|
|
2918
2413
|
if (!id) {
|
|
2919
2414
|
return id;
|
|
2920
2415
|
}
|
|
2921
|
-
|
|
2922
2416
|
return parseInt(id.toString().split('.')[0], 10);
|
|
2923
2417
|
}
|
|
2924
2418
|
};
|
|
2925
|
-
|
|
2926
2419
|
Audio.setup = function (options) {
|
|
2927
2420
|
state.audio = new Audio(options);
|
|
2928
2421
|
};
|
|
2929
2422
|
|
|
2930
2423
|
Audio.PlayerPool = PlayerPool;
|
|
2931
2424
|
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
callbacks.forEach(function (cb) {
|
|
2425
|
+
let isEventAdded = false;
|
|
2426
|
+
let callbacks = [];
|
|
2427
|
+
let muteInBackground = () => {
|
|
2428
|
+
callbacks.forEach(cb => {
|
|
2937
2429
|
cb(document.visibilityState);
|
|
2938
2430
|
});
|
|
2939
2431
|
};
|
|
2940
|
-
|
|
2941
2432
|
function documentHiddenState(callback) {
|
|
2942
2433
|
callbacks.push(callback);
|
|
2943
|
-
|
|
2944
2434
|
if (!isEventAdded) {
|
|
2945
2435
|
isEventAdded = true;
|
|
2946
2436
|
document.addEventListener('visibilitychange', muteInBackground, false);
|
|
2947
2437
|
}
|
|
2948
|
-
|
|
2949
2438
|
return {
|
|
2950
|
-
removeCallback:
|
|
2951
|
-
callbacks = callbacks.filter(
|
|
2952
|
-
return c !== callback;
|
|
2953
|
-
});
|
|
2439
|
+
removeCallback: () => {
|
|
2440
|
+
callbacks = callbacks.filter(c => c !== callback);
|
|
2954
2441
|
}
|
|
2955
2442
|
};
|
|
2956
2443
|
}
|
|
2957
2444
|
|
|
2958
|
-
|
|
2445
|
+
const consent = Consent.create();
|
|
2959
2446
|
|
|
2960
2447
|
export { Audio, AudioPlayer, Consent, Features, MediaPool, MediaType, MultiPlayer, PlayerSourceIDMap, VideoPlayer, assetUrls, audioContext, blankSources, browser, consent, cookies, debugMode, documentHiddenState, events, features, log, media, mediaPlayer, setItemCookieString, settings };
|