Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to check if the text string is in arabic or hebrew;
- function testArabicHebrew(text) {
- arabicRange = /[\u0600-\u06FF]/;
- hebrewRange = /[\u0590-\u05FF]/;
- return arabicRange.test(text) || hebrewRange.test(text);
- }
- // Function to add marquee to the overflowed text.
- function wrapContentsInMarquee(element) {
- // Calculate the secs to stop the marquee depending of the length
- secs = (element.text().length / 5) * 1200;
- $(".marquee-ltr").removeClass("marquee-ltr");
- $(".marquee-rtl").removeClass("marquee-rtl");
- parentElement = element.parent();
- // Check if the string is arabic or hebrew
- setTimeout(function () {
- if (testArabicHebrew(element.text())) {
- marqueeClass = "marquee-rtl"
- } else {
- marqueeClass = "marquee-ltr";
- }
- parentElement.addClass(marqueeClass);
- clearTimeout(timeOutToMarquee);
- timeOutToMarquee = setTimeout(function () {
- wrapContentsInMarquee(element);
- }, secs)
- }, 500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement