From efd18af9b769440ae2096f4e0296e8f38121e30e Mon Sep 17 00:00:00 2001 From: Herwin Date: Sat, 16 Nov 2024 17:11:47 +0100 Subject: [PATCH] Implemented text direction switch Update index.php, text-direction-switch.js, and text_alignment.php --- htdocs/index.php | 1 + htdocs/js/text-direction-switch.js | 16 ++++++++++++++++ htdocs/parts/text_alignment.php | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 htdocs/js/text-direction-switch.js diff --git a/htdocs/index.php b/htdocs/index.php index e3d7691..7f727a4 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -131,5 +131,6 @@ + diff --git a/htdocs/js/text-direction-switch.js b/htdocs/js/text-direction-switch.js new file mode 100644 index 0000000..4e3332d --- /dev/null +++ b/htdocs/js/text-direction-switch.js @@ -0,0 +1,16 @@ +const eTextDirectionSwitches = document.querySelectorAll(".text-direction-switch"); +const eTextDirectionTargets = document.querySelectorAll(".text-direction-target"); + +document.addEventListener("DOMContentLoaded", () => { + eTextDirectionSwitches.forEach(eSwitch => { + eSwitch.onclick = function() { + eTextDirectionTargets.forEach(eTarget => { + if(eTarget.style.direction === "rtl") { + eTarget.style.direction = 'ltr'; + } else { + eTarget.style.direction = 'rtl'; + } + }); + }; + }); +}); diff --git a/htdocs/parts/text_alignment.php b/htdocs/parts/text_alignment.php index 74c527b..67cfcc7 100644 --- a/htdocs/parts/text_alignment.php +++ b/htdocs/parts/text_alignment.php @@ -20,27 +20,27 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {

Left

-

Left

+

Left

t-left

Center

-

Centered

+

Centered

t-center

Right

-

Right

+

Right

t-right

Start

-

Start

+

Start

t-start

End

-

End

+

End

t-end @@ -50,5 +50,6 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) { - + +