Skip to content

Commit

Permalink
Merge pull request #2 from asulibraries/bootstrap-5
Browse files Browse the repository at this point in the history
Update Popover for Bootstrap 5
  • Loading branch information
seth-shaw-asu authored Oct 17, 2024
2 parents fadd9d0 + 7afd2ad commit 3db609b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"require": {
"ext-bcmath": "*",
"google/apiclient": "^2.15",
"google/analytics-data": "^0.16.0"
"google/analytics-data": "^0.16.0"
},
"conflict": {
"drupal/bootstrap_barrio": "<5.5"
}
}
2 changes: 1 addition & 1 deletion js/item-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Activate the Popover utility.
*/
[].slice.call(document.querySelectorAll('.block-asu-item-analytics-item-block span[data-toggle="popover"]')).map(function (el) {
[].slice.call(document.querySelectorAll('.asu-item-analytics-popover span[data-bs-toggle="popover"]')).map(function (el) {
return new bootstrap.Popover(el)
})
}())
12 changes: 7 additions & 5 deletions src/Plugin/Block/ItemBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ public function build() {
$count = array_sum($this->analyticsQueryService->entityMonthly($entity) ?? []);
if ($count > 0) {
return [
'#type' => 'container',
'#attributes' => ['class' => ['asu-item-analytics-popover']],
'popover' => [
'#type' => 'html_tag',
'#tag' => 'span',
'#attributes' => [
'tabindex' => '0',
'role' => 'button',
'data-placement' => 'bottom',
'data-toggle' => 'popover',
'data-trigger' => 'focus',
'data-bs-placement' => 'bottom',
'data-bs-toggle' => 'popover',
'data-bs-trigger' => 'focus',
'title' => 'Information',
'data-content' => 'The repository began collecting download statistics in 2021.',
'data-bs-content' => 'The repository began collecting download statistics in 2021.',
],
'icon' => [
'#type' => 'html_tag',
Expand All @@ -110,7 +112,7 @@ public function build() {
'#plain_text' => 'Download count: ' . number_format($count),
],
// Attach the library to the block.
'#attached' => ['library' => ['asu_item_analytics/item_block' => 'asu_item_analytics/item_block']],
'#attached' => ['library' => ['asu_item_analytics/item_block']],
'#cache' => ['contexts' => ['url.path']],
];
}
Expand Down

0 comments on commit 3db609b

Please sign in to comment.