Skip to content

Commit

Permalink
AV-689: Convert guide tables to bootstrap responsive oens
Browse files Browse the repository at this point in the history
  • Loading branch information
bzar committed Dec 5, 2023
1 parent a962e72 commit 18f928e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions drupal/modules/avoindata-theme/avoindata.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ webfonts:
cycle-guide-menu-items:
js:
'js/cycle_guide_menu_items.js': {}

inject-responsive-tables:
js:
'scripts/inject_responsive_tables.js': {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
#}
{{ attach_library('avoindata/cycle-guide-menu-items') }}
{{ attach_library('avoindata/inject-responsive-tables') }}
{% set has_menu = drupal_region('guide_menu')|render|striptags|trim %}


Expand Down
3 changes: 2 additions & 1 deletion opendata-assets/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ gulp.task("scripts", (done) => {
pump([
gulp.src([paths.src.scripts, paths.src.drupal_avoindata_header]),
gulp.dest(paths.dist + "/scripts"),
gulp.dest(paths.ckanResources + "/scripts")
gulp.dest(paths.ckanResources + "/scripts"),
gulp.dest(paths.drupalTheme + "/scripts")
], done)
});

Expand Down
5 changes: 4 additions & 1 deletion opendata-assets/src/scripts/inject_responsive_tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ var injectResponsiveTables = function (next) {
if (document.readyState == "interactive" || document.readyState == "complete") {
var content = document.getElementsByClassName("region-content");
if (content.length != 0) {
var sections = content[0].getElementsByTagName("section");
var sections = content[0].getElementsByClassName("avoindata-section-content");
for ( var j = 0; j < sections.length; j++) {
var tables = sections[j].getElementsByTagName("table");
for (var i = 0; i < tables.length; ++i) {
if(tables[i].parentElement.classList.contains('table-responsive')) {
continue;
}
var wrapper = document.createElement("div");
tables[i].classList.add("table");
wrapper.classList.add("table-responsive");
Expand Down

0 comments on commit 18f928e

Please sign in to comment.