1(function($) { 2 'use strict'; 3 4 const dcHiddenSelector = '.dc-hidden-column', 5 dcHideWrapperSelector = '.dc-hide-wrapper', 6 dcHideOthersSelector = '.dc-hide-others', 7 dcRowSelector = '.elementor-row,.elementor-container', 8 dcColumnSelector = '> .elementor-column'; 9 10 11 function resizeColumns() { 12 const $columns = $(dcHiddenSelector); 13 $columns.each(function(index, column) { 14 const $column = $(column), 15 hiddenSize = parseFloat($column.data('size')), 16 $row = $column.closest(dcRowSelector), 17 $children = $row.find(dcColumnSelector); 18 19 if ($children.length === 0) { 20 return; 21 } 22 23 // get percent-width of row 24 const rowSize = $children.toArray().reduce( 25 (acc, child) => acc + calcRowWidth($(child), $row), 26 0 27 ); 28 29 $children.each(function(cIndex, child) { 30 // resize columns 31 const $child = $(child), 32 childSize = calcRowWidth($child, $row), 33 newSize = childSize + (hiddenSize * (childSize / rowSize)); 34 35 if (childSize < 100) { 36 $child.css({width: newSize + '%'}); 37 } 38 }); 39 40 }); 41 } 42 43 function calcRowWidth($child, $row) { 44 return parseFloat($child.width() / $row.width() * 100); 45 } 46 47 function resetColumns() { 48 const $columns = $(dcHiddenSelector); 49 $columns.each(function(index, column) { 50 const $children = $(column).closest(dcRowSelector).find(dcColumnSelector); 51 52 // reset width for recalc 53 $children.css({width: ''}); 54 }); 55 } 56 57 function hideWrappers() { 58 const $elements = $(dcHideWrapperSelector); 59 $elements.each(function(index, element) { 60 const $element = $(element), 61 $wrapper = $element.closest($element.data('selector')); 62 $wrapper.css({display: 'none'}); 63 }); 64 } 65 66 function hideOthers() { 67 const $elements = $(dcHideOthersSelector); 68 $elements.each(function(index, element) { 69 const $element = $(element), 70 $toHide = $($element.data('selector')); 71 $toHide.css({display: 'none'}); 72 }); 73 } 74 75 $(window).on('resize', function() { 76 resetColumns(); 77 resizeColumns(); 78 }); 79 80 $(window).on('elementor/frontend/init', function() { 81 resetColumns(); 82 resizeColumns(); 83 hideWrappers(); 84 hideOthers(); 85 }); 86})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.