Last active
February 9, 2016 20:53
-
-
Save lots0logs/b13872ffb7a0768ff6f9 to your computer and use it in GitHub Desktop.
WordPress :: Divi Builder :: RTL Columns Mobile Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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; | |
| } | |
| } | |
| } | |
| $(window).on('resize.et_divi', fix_rtl_columns); | |
| })(jQuery); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment