Skip to content

Instantly share code, notes, and snippets.

@lots0logs
Last active December 31, 2015 20:50
Show Gist options
  • Select an option

  • Save lots0logs/03c9bdc151dcc0ae4999 to your computer and use it in GitHub Desktop.

Select an option

Save lots0logs/03c9bdc151dcc0ae4999 to your computer and use it in GitHub Desktop.
Divi RTL Columns Fix: Add to ePanel>>Integrations>>Add to the <body>:
<script>
(function($) {
var rtl_mobile = false,
rtl_tablet = false,
running = false;
function toggle_booleon_value(val) {
return (true === val) ? false : true;
}
function do_rtl_fix_mobile(keep_running) {
$('.et_pb_row').each(function() {
$(this).children('.et_pb_column').each(function() {
var $modules = $(this).children('.et_pb_module');
if ($modules.length) {
$modules.each(function() {
$(this).prependTo($(this).parent());
});
}
$(this).prependTo($(this).parent());
});
});
rtl_mobile = toggle_booleon_value(rtl_mobile);
running = keep_running;
}
function do_rtl_fix_tablet(keep_running) {
$('.et_pb_row').each(function() {
var $columns = $(this).children('.et_pb_column');
if ($columns.length === 4) {
$columns.eq(3).prependTo($(this));
$columns.eq(2).prependTo($(this));
} else if ($columns.length === 3) {
$columns.eq(0).appendTo($(this));
$columns.eq(2).prependTo($(this));
} else if ($columns.length === 2) {
$columns.eq(0).appendTo($(this));
}
$columns = $(this).children('.et_pb_column');
$columns.each(function() {
var $modules = $(this).children('.et_pb_module');
if ($modules.length === 4) {
$modules.eq(3).prependTo($(this));
$modules.eq(2).prependTo($(this));
} else if ($modules.length === 3) {
$modules.eq(0).appendTo($(this));
$modules.eq(2).prependTo($(this));
} else if ($modules.length === 2) {
$modules.eq(0).appendTo($(this));
}
});
});
rtl_tablet = toggle_booleon_value(rtl_tablet);
running = keep_running;
}
function fix_rtl_columns() {
var window_width = $(window).width();
if (false === running) {
running = true;
if (window_width <= 479 && false === rtl_mobile && false === rtl_tablet) {
do_rtl_fix_mobile(false);
return;
}
if (window_width > 479 && true === rtl_mobile && false === rtl_tablet) {
do_rtl_fix_mobile(true);
do_rtl_fix_tablet(false);
return;
}
if (window_width <= 980 && false === rtl_mobile && false === rtl_tablet) {
do_rtl_fix_tablet(false);
return;
}
if (window_width > 980 && false === rtl_mobile && true === rtl_tablet) {
do_rtl_fix_tablet(true);
do_rtl_fix_mobile(false);
return;
}
}
}
$(document).ready(fix_rtl_columns);
$(window).resize(fix_rtl_columns);
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment