From 919e6cccd4ae746c8a3cb5beff700f54cdb9dc04 Mon Sep 17 00:00:00 2001 From: Hassan Faghihi Date: Wed, 25 Dec 2024 18:02:48 +0330 Subject: [PATCH 1/5] #69: Add RTL support --- demos/css/jquery.toast.css | 7 ++++- demos/index.html | 64 +++++++++++++++++++++++++++++++++----- demos/js/jquery.toast.js | 45 ++++++++++++++++++++++----- src/jquery.toast.css | 7 ++++- src/jquery.toast.js | 18 +++++++++-- 5 files changed, 121 insertions(+), 20 deletions(-) diff --git a/demos/css/jquery.toast.css b/demos/css/jquery.toast.css index 54ddf67..2b9fa50 100644 --- a/demos/css/jquery.toast.css +++ b/demos/css/jquery.toast.css @@ -9,17 +9,22 @@ .jq-toast-wrap.top-left { top: 20px; left: 20px; } .jq-toast-wrap.top-right { top: 20px; right: 40px; } -.jq-toast-single { display: block; width: 100%; padding: 10px; margin: 0px 0px 5px; border-radius: 4px; font-size: 12px; font-family: arial, sans-serif; line-height: 17px; position: relative; pointer-events: all !important; background-color: #444444; color: white; } +.jq-toast-single { display: block; direction: ltr; width: 100%; padding: 10px; margin: 0px 0px 5px; border-radius: 4px; font-size: 12px; font-family: arial, sans-serif; line-height: 17px; position: relative; pointer-events: all !important; background-color: #444444; color: white; } +.jq-toast-rtl .jq-toast-single { direction: rtl; } .jq-toast-single h2 { font-family: arial, sans-serif; font-size: 14px; margin: 0px 0px 7px; background: none; color: inherit; line-height: inherit; letter-spacing: normal; } +.jq-toast-rtl .jq-toast-single { } .jq-toast-single a { color: #eee; text-decoration: none; font-weight: bold; border-bottom: 1px solid white; padding-bottom: 3px; font-size: 12px; } +.jq-toast-rtl .jq-toast-single a { color: #eee; text-decoration: none; font-weight: bold; border-bottom: 1px solid white; padding-bottom: 3px; font-size: 12px; } .jq-toast-single ul { margin: 0px 0px 0px 15px; background: none; padding:0px; } .jq-toast-single ul li { list-style-type: disc !important; line-height: 17px; background: none; margin: 0; padding: 0; letter-spacing: normal; } .close-jq-toast-single { position: absolute; top: 3px; right: 7px; font-size: 14px; cursor: pointer; } +.jq-toast-rtl .close-jq-toast-single { right: auto; left: 7px; } .jq-toast-loader { display: block; position: absolute; top: -2px; height: 5px; width: 0%; left: 0; border-radius: 5px; background: red; } +.jq-toast-rtl .jq-toast-loader { left: auto; right: 0; } .jq-toast-loaded { width: 100%; } .jq-has-icon { padding: 10px 10px 10px 50px; background-repeat: no-repeat; background-position: 10px; } .jq-icon-info { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII='); background-color: #31708f; color: #d9edf7; border-color: #bce8f1; } diff --git a/demos/index.html b/demos/index.html index 67491fa..c696a60 100644 --- a/demos/index.html +++ b/demos/index.html @@ -284,7 +284,34 @@

6. Setting the toast stack

Note Hit the run button multiple times to test these demos.

-

7. Positioning the toast

+

7. Direction of the toast

+

direction property can be used to specify the direction of content. There are following predefined direction which you can use:

+ + +
+ Run Code +
$.toast({
+    heading: 'Direction',
+    text: 'این متن از چپ به راست نوشته شده است. This text is written from left to right.',
+    direction: 'ltr',
+    stack: false
+})
+
+ +
+ Run Code +
$.toast({
+    heading: 'Direction',
+    text: 'این متن از راست به چپ نوشته شده است. This text is written from right to left.',
+    direction: 'rtl',
+    stack: false
+})
+
+ +

8. Positioning the toast

position property can be used to specify the position. There are following predefined positions which you can use: