From 8cc3a372b765048bafde38a347171c3b1ea3aae6 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 2 Oct 2014 12:46:51 -0500 Subject: [PATCH] i18n: Fix help tip popup for RTL display --- scp/js/tips.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scp/js/tips.js b/scp/js/tips.js index 4d623eb16..93f4f14c7 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -10,8 +10,16 @@ jQuery(function() { var tip_shadow = $('<div>').addClass('tip_shadow'); var tip_content = $('<div>').addClass('tip_content').load(url, function() { tip_content.prepend('<a href="#" class="tip_close"><i class="icon-remove-circle"></i></a>').append(tip_arrow); - if ($(window).width() < tip_content.outerWidth() + the_tip.position().left) { - console.log(x_pos, tip_content.outerWidth(), elem.width()); + var width = $(window).width(), + rtl = $('html').hasClass('rtl'), + size = tip_content.outerWidth(), + left = the_tip.position().left, + left_room = left - size, + right_room = width - size - left, + flip = rtl + ? (left_room > 0 && left_room > right_room) + : (right_room < 0 && left_room > right_room); + if (flip) { the_tip.css({'left':x_pos-tip_content.outerWidth()-elem.width()-32+'px'}); tip_box.addClass('right'); tip_arrow.addClass('flip-x'); @@ -105,7 +113,16 @@ jQuery(function() { tip_timer = setTimeout(function() { $('.tip_box').remove(); $('body').append(the_tip.hide().fadeIn()); - if ($(window).width() < tip_content.outerWidth() + the_tip.position().left) { + var width = $(window).width(), + rtl = $('html').hasClass('rtl'), + size = tip_content.outerWidth(), + left = the_tip.position().left, + left_room = left - size, + right_room = width - size - left, + flip = rtl + ? (left_room > 0 && left_room > right_room) + : (right_room < 0 && left_room > right_room); + if (flip) { the_tip.css({'left':x_pos-tip_content.outerWidth()-40+'px'}); tip_box.addClass('right'); tip_arrow.addClass('flip-x'); -- GitLab