Advertisement
Guest User

marquee antonino

a guest
Dec 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // Function to check if the text string is in arabic or hebrew;
  2. function testArabicHebrew(text) {
  3. arabicRange = /[\u0600-\u06FF]/;
  4. hebrewRange = /[\u0590-\u05FF]/;
  5. return arabicRange.test(text) || hebrewRange.test(text);
  6. }
  7.  
  8. // Function to add marquee to the overflowed text.
  9. function wrapContentsInMarquee(element) {
  10. // Calculate the secs to stop the marquee depending of the length
  11. secs = (element.text().length / 5) * 1200;
  12. $(".marquee-ltr").removeClass("marquee-ltr");
  13. $(".marquee-rtl").removeClass("marquee-rtl");
  14. parentElement = element.parent();
  15. // Check if the string is arabic or hebrew
  16. setTimeout(function () {
  17. if (testArabicHebrew(element.text())) {
  18. marqueeClass = "marquee-rtl"
  19. } else {
  20. marqueeClass = "marquee-ltr";
  21. }
  22. parentElement.addClass(marqueeClass);
  23.  
  24. clearTimeout(timeOutToMarquee);
  25.  
  26. timeOutToMarquee = setTimeout(function () {
  27. wrapContentsInMarquee(element);
  28. }, secs)
  29. }, 500);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement