(function ($, Drupal) { // 'use strict'; // To understand behaviors, see https://drupal.org/node/756722#behaviors Drupal.behaviors.inequality_branch_behavior = { attach: function (context, settings) { // Place your code here. } }; $(window).on('load', function () { resizeDrupalContent(); }); $(window).resize(function () { resizeDrupalContent(); }); function resizeDrupalContent(i = 0) { if (i > 15) { if ($('.width-ref').length <= 0) { if($('.container-lg').length <= 0) $('.region-header').addClass('container-lg') // if($('.drupalPageFooter').length <= 0) $('.react-page-footer').addClass('drupalPageFooter') } return; // retry upto 10 times } var w = $('.width-ref').width(); // console.log('Width:', w, i) if (w) { $('.region-header').css("width", w + "px"); // $('.react-page-footer').css("maxWidth", w + "px"); } else { setTimeout(function () { resizeDrupalContent(++i); }, 100); } } })(jQuery, Drupal);