This repository has been archived by the owner on Nov 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3496 from staceymosier/RHDX-221--webinar-countdown
[RHDX-221] Add webinar countdown component
- Loading branch information
Showing
23 changed files
with
360 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ilesystem/web/config/sync/field.field.assembly.call_to_action.field_display_cta_timer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
uuid: abc3e596-dc3d-4416-af44-b4c2d748de80 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
config: | ||
- assembly.assembly_type.call_to_action | ||
- field.storage.assembly.field_display_cta_timer | ||
module: | ||
- datetime | ||
id: assembly.call_to_action.field_display_cta_timer | ||
field_name: field_display_cta_timer | ||
entity_type: assembly | ||
bundle: call_to_action | ||
label: 'Display CTA Timer' | ||
description: 'Provide a datetime (EST / GMT-05:00) if you would like to hide a CTA button and display a countdown/timer ex. preceding an event like a webinar. Once this datetime has been reached, the countdown/timer will be hidden and the CTA will display.' | ||
required: false | ||
translatable: false | ||
default_value: { } | ||
default_value_callback: '' | ||
settings: { } | ||
field_type: datetime |
19 changes: 19 additions & 0 deletions
19
...tem/web/config/sync/field.field.assembly.call_to_action.field_display_cta_timer_label.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
uuid: 429a703a-d938-4fb5-9879-49272548e331 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
config: | ||
- assembly.assembly_type.call_to_action | ||
- field.storage.assembly.field_display_cta_timer_label | ||
id: assembly.call_to_action.field_display_cta_timer_label | ||
field_name: field_display_cta_timer_label | ||
entity_type: assembly | ||
bundle: call_to_action | ||
label: 'Display CTA Timer Label' | ||
description: 'This text will display over the timer/countdown component ex. "Event starting in...", "Event coming soon", "Webinar available in...", etc.' | ||
required: false | ||
translatable: false | ||
default_value: { } | ||
default_value_callback: '' | ||
settings: { } | ||
field_type: string |
20 changes: 20 additions & 0 deletions
20
...upal/drupal-filesystem/web/config/sync/field.storage.assembly.field_display_cta_timer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
uuid: d5085b7f-c3a5-4f59-a71f-29aaca3e38b1 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- assembly | ||
- datetime | ||
id: assembly.field_display_cta_timer | ||
field_name: field_display_cta_timer | ||
entity_type: assembly | ||
type: datetime | ||
settings: | ||
datetime_type: datetime | ||
module: datetime | ||
locked: false | ||
cardinality: 1 | ||
translatable: true | ||
indexes: { } | ||
persist_with_no_fields: false | ||
custom_storage: false |
21 changes: 21 additions & 0 deletions
21
...rupal-filesystem/web/config/sync/field.storage.assembly.field_display_cta_timer_label.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
uuid: 3e8cc0df-e8e0-4f71-9ff3-1a14a27b7e6a | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- assembly | ||
id: assembly.field_display_cta_timer_label | ||
field_name: field_display_cta_timer_label | ||
entity_type: assembly | ||
type: string | ||
settings: | ||
max_length: 255 | ||
is_ascii: false | ||
case_sensitive: false | ||
module: core | ||
locked: false | ||
cardinality: 1 | ||
translatable: true | ||
indexes: { } | ||
persist_with_no_fields: false | ||
custom_storage: false |
74 changes: 74 additions & 0 deletions
74
_docker/drupal/drupal-filesystem/web/modules/custom/rhd_assemblies/js/countdown.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* @file | ||
* Javascript Countdown Component | ||
* Provides a countdown to reveal the call to action. | ||
* Also see https://codepen.io/SitePoint/pen/MwNPVq, | ||
* https://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/ | ||
*/ | ||
|
||
(function ($, Drupal) { | ||
|
||
function toggleCountdownAndCTA(clock) { | ||
$(clock).next().removeClass('hide'); | ||
$(clock).addClass('hide'); | ||
} | ||
|
||
function getTimeRemaining(countdownDate) { | ||
var now = new Date().toLocaleString('en-US', {timeZone: 'America/New_York'}); | ||
var countdownDateObj = new Date(countdownDate); | ||
|
||
var t = Date.parse(countdownDateObj) - Date.parse(now); | ||
var seconds = Math.floor((t / 1000) % 60); | ||
var minutes = Math.floor((t / 1000 / 60) % 60); | ||
var hours = Math.floor((t / (1000 * 60 * 60)) % 24); | ||
var days = Math.floor(t / (1000 * 60 * 60 * 24)); | ||
return { | ||
'total': t, | ||
'days': days, | ||
'hours': hours, | ||
'minutes': minutes, | ||
'seconds': seconds | ||
}; | ||
} | ||
|
||
function initializeClock(clock, countdownDate) { | ||
var daysSpan = clock.find('.days span'); | ||
var hoursSpan = clock.find('.hours span'); | ||
var minutesSpan = clock.find('.minutes span'); | ||
var secondsSpan = clock.find('.seconds span'); | ||
|
||
function updateClock(clock) { | ||
var t = getTimeRemaining(countdownDate); | ||
daysSpan.html(t.days); | ||
hoursSpan.html(('0' + t.hours).slice(-2)); | ||
minutesSpan.html(('0' + t.minutes).slice(-2)); | ||
secondsSpan.html(('0' + t.seconds).slice(-2)); | ||
|
||
if (t.total <= 0) { | ||
clearInterval(timeinterval); | ||
toggleCountdownAndCTA(clock); | ||
} | ||
} | ||
|
||
updateClock(clock); | ||
var timeinterval = setInterval(updateClock, 1000, clock); | ||
} | ||
|
||
Drupal.behaviors.rhd_CtaCountdown = { | ||
attach: function (context, settings) { | ||
$('.assembly-type-call_to_action.has-countdown', context).once('rhdCTACountdown').each(function (){ | ||
var clock = $('.rhd-c-countdown', $(this)); | ||
var countdownDate = settings.rhd_assemblies.countdown_date; | ||
var startingOffsetTime = getTimeRemaining(countdownDate); | ||
|
||
if (startingOffsetTime.total == 0) { | ||
toggleCountdownAndCTA(clock); | ||
} else { | ||
$(clock).removeClass('hide'); | ||
initializeClock( clock, countdownDate); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
})(jQuery, Drupal); |
8 changes: 8 additions & 0 deletions
8
...r/drupal/drupal-filesystem/web/modules/custom/rhd_assemblies/rhd_assemblies.libraries.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
countdown: | ||
version: VERSION | ||
js: | ||
js/countdown.js: {} | ||
dependencies: | ||
- core/jquery | ||
- core/jquery.once | ||
- core/drupal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
color: var(--pfe-theme--color--text--on-dark, $white); | ||
} | ||
} | ||
} | ||
} |
21 changes: 10 additions & 11 deletions
21
...web/themes/custom/rhdp2/rhd-frontend/src/styles/rhd-theme/components/_call-to-action.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.