From 6381505ddd2b40381508281da7b02748263d8f7f Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Tue, 5 Jun 2018 08:49:22 -0400
Subject: [PATCH] Add RTL to autocomplete.

---
 themes/bootstrap3/js/common.js           | 1 +
 themes/bootstrap3/js/lib/autocomplete.js | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index 1a7055a1e6a..a3f978cadb4 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -266,6 +266,7 @@ function setupAutocomplete() {
   }
   // Search autocomplete
   searchbox.autocomplete({
+    rtl: $(document.body).hasClass("rtl"),
     maxResults: 10,
     loadingString: VuFind.translate('loading') + '...',
     handler: function vufindACHandler(input, cb) {
diff --git a/themes/bootstrap3/js/lib/autocomplete.js b/themes/bootstrap3/js/lib/autocomplete.js
index db78e438fb3..cb6e6ee04e1 100644
--- a/themes/bootstrap3/js/lib/autocomplete.js
+++ b/themes/bootstrap3/js/lib/autocomplete.js
@@ -14,9 +14,13 @@
         var position = input.offset();
         element.css({
           top: position.top + input.outerHeight(),
-          left: position.left,
           minWidth: input.width()
         });
+        if (options.rtl) {
+          element.css("right", document.body.offsetWidth - position.left - input.outerWidth());
+        } else {
+          element.css("left", position.left);
+        }
       };
 
       var _show = function _show() {
@@ -396,7 +400,8 @@
     highlight: true,
     loadingString: 'Loading...',
     maxResults: 20,
-    minLength: 3
+    minLength: 3,
+    rtl: false
   };
 
   var timer = false;
-- 
GitLab