Skip to content

Commit

Permalink
feat(shs-5693): attached file for table wrap and table scope in text …
Browse files Browse the repository at this point in the history
…area tables and add drupal behavior to vertical tabs
  • Loading branch information
Mari Nez committed Dec 2, 2024
1 parent e1a7c7c commit d20ea84
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
function closeDetails() {
// Close Revision Information Details element in Layout Builder by default.
if (document.querySelector('.layout-builder-form')) {
const details = document.querySelector('.layout-builder-form details');
if (details) {
details.removeAttribute('open');
}
}
}
(function (Drupal) {
Drupal.behaviors.addTableScopeAttributes = {
// eslint-disable-next-line no-unused-vars
attach(context) {
function closeDetails() {
// Close Revision Information Details element in Layout Builder by default.
if (document.querySelector('.layout-builder-form')) {
const details = document.querySelector('.layout-builder-form details');
if (details) {
details.removeAttribute('open');
}
}
}

document.addEventListener('DOMContentLoaded', () => {
closeDetails(document);
});
document.addEventListener('DOMContentLoaded', () => {
closeDetails(document);
});
},
};
}(Drupal));
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ admin-preview:
css:
theme:
css/humsci_colorful-preview.css: {}
js:
js/index.js: {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ admin-preview:
css:
theme:
css/humsci_traditional-preview.css: {}
js:
js/index.js: {}
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ function su_humsci_gin_admin_preprocess(&$variables, $hook) {
$variables['wrapper_attributes'] = new Attribute();
$variables['wrapper_attributes']->addClass($classes);
}

/**
* Implements hook_preprocess_HOOK().
*/
function su_humsci_gin_admin_preprocess_field(&$variables) {
if ($variables['field_name'] == 'field_hs_text_area') {
$variables['#attached']['library'][] = 'humsci_basic/tablewrap';
$variables['#attached']['library'][] = 'humsci_basic/tablescope';
}
}

0 comments on commit d20ea84

Please sign in to comment.