From b6d4b431be99a22c4f1c37df815c0f3b9cf37315 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Fri, 3 Dec 2021 11:25:49 -0600 Subject: [PATCH] Replace twitter-typeahead-rails with @github/auto-complete-element This is less code for us to manage and is a library that is currently receiving maintenance --- .rubocop.yml | 1 + .../javascripts/blacklight/blacklight.js | 70 ++++++------------- .../javascripts/blacklight/blacklight.js.map | 2 +- .../stylesheets/blacklight/_autocomplete.scss | 21 ++++++ .../blacklight/_blacklight_base.scss | 1 + .../blacklight/search_bar_component.html.erb | 15 +++- .../concerns/blacklight/catalog.rb | 8 +-- app/javascript/blacklight/autocomplete.js | 40 ----------- app/javascript/blacklight/index.js | 2 - app/views/catalog/suggest.html.erb | 3 + app/views/layouts/blacklight/base.html.erb | 3 + lib/blacklight/routes/searchable.rb | 2 +- lib/generators/blacklight/assets_generator.rb | 3 - spec/controllers/catalog_controller_spec.rb | 14 ---- spec/features/autocomplete_spec.rb | 2 +- spec/requests/load_suggestions_spec.rb | 16 +++++ 16 files changed, 88 insertions(+), 115 deletions(-) create mode 100644 app/assets/stylesheets/blacklight/_autocomplete.scss delete mode 100644 app/javascript/blacklight/autocomplete.js create mode 100644 app/views/catalog/suggest.html.erb create mode 100644 spec/requests/load_suggestions_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index ad70526151..52001c4ea0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -229,6 +229,7 @@ RSpec/DescribeClass: Exclude: - 'spec/lib/tasks/blacklight_task_spec.rb' - 'spec/features/**/*' + - 'spec/requests/**/*' - 'spec/views/**/*' RSpec/ExcessiveDocstringSpacing: # new in 2.5 Enabled: true diff --git a/app/assets/javascripts/blacklight/blacklight.js b/app/assets/javascripts/blacklight/blacklight.js index 6e3d0368ec..f029b34ece 100644 --- a/app/assets/javascripts/blacklight/blacklight.js +++ b/app/assets/javascripts/blacklight/blacklight.js @@ -1,12 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('typeahead.js/dist/bloodhound.js')) : - typeof define === 'function' && define.amd ? define(['typeahead.js/dist/bloodhound.js'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Blacklight = factory(global.Bloodhound)); -})(this, (function (Bloodhound) { 'use strict'; - - const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; - - const Bloodhound__default = /*#__PURE__*/_interopDefaultLegacy(Bloodhound); + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Blacklight = factory()); +})(this, (function () { 'use strict'; const Blacklight = function() { var buffer = new Array; @@ -61,41 +57,6 @@ elem.classList.add('js'); }); - const Autocomplete = (() => { - Blacklight.onLoad(function() { - - $('[data-autocomplete-enabled="true"]').each(function() { - var $el = $(this); - if($el.hasClass('tt-hint')) { - return; - } - var suggestUrl = $el.data().autocompletePath; - - var terms = new Bloodhound__default.default({ - datumTokenizer: Bloodhound__default.default.tokenizers.obj.whitespace('value'), - queryTokenizer: Bloodhound__default.default.tokenizers.whitespace, - remote: { - url: suggestUrl + '?q=%QUERY', - wildcard: '%QUERY' - } - }); - - terms.initialize(); - - $el.typeahead({ - hint: true, - highlight: true, - minLength: 2 - }, - { - name: 'terms', - displayKey: 'term', - source: terms.ttAdapter() - }); - }); - }); - })(); - /* Converts a "toggle" form, with single submit button to add/remove something, like used for Bookmarks, into an AJAXy checkbox instead. Apply to a form. Does require certain assumption about the form: @@ -381,7 +342,7 @@ this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown + ''; $(Blacklight.modal.modalSelector).find('.modal-content').html(contents); - $(Blacklight.modal.modalSelector).modal('show'); + Blacklight.modal.show(); }; Blacklight.modal.receiveAjax = function (contents) { @@ -402,7 +363,7 @@ // if they did preventDefault, don't show the dialog if (e.isDefaultPrevented()) return; - $(Blacklight.modal.modalSelector).modal('show'); + Blacklight.modal.show(); }; @@ -463,7 +424,7 @@ if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) { var modalFlashes = $(this).find('.flash_messages'); - $(event.target).modal('hide'); + Blacklight.modal.hide(event.target); event.preventDefault(); var mainFlashes = $('#main-flashes'); @@ -472,6 +433,22 @@ } }; + Blacklight.modal.hide = function(el) { + if (bootstrap.Modal.VERSION >= "5") { + bootstrap.Modal.getOrCreateInstance(el).hide(); + } else { + $(el || Blacklight.modal.modalSelector).modal('hide'); + } + }; + + Blacklight.modal.show = function(el) { + if (bootstrap.Modal.VERSION >= "5") { + bootstrap.Modal.getOrCreateInstance(el).show(); + } else { + $(el || Blacklight.modal.modalSelector).modal('show'); + } + }; + Blacklight.onLoad(function() { Blacklight.modal.setupModal(); }); @@ -540,7 +517,6 @@ })(); const index = { - Autocomplete, BookmarkToggle, ButtonFocus, FacetLoad, diff --git a/app/assets/javascripts/blacklight/blacklight.js.map b/app/assets/javascripts/blacklight/blacklight.js.map index 7f855bd874..a518517870 100644 --- a/app/assets/javascripts/blacklight/blacklight.js.map +++ b/app/assets/javascripts/blacklight/blacklight.js.map @@ -1 +1 @@ -{"version":3,"file":"blacklight.js","sources":["../../../javascript/blacklight/core.js","../../../javascript/blacklight/autocomplete.js","../../../javascript/blacklight/checkbox_submit.js","../../../javascript/blacklight/bookmark_toggle.js","../../../javascript/blacklight/button_focus.js","../../../javascript/blacklight/facet_load.js","../../../javascript/blacklight/modal.js","../../../javascript/blacklight/search_context.js","../../../javascript/blacklight/index.js"],"sourcesContent":["const Blacklight = function() {\n var buffer = new Array;\n return {\n onLoad: function(func) {\n buffer.push(func);\n },\n\n activate: function() {\n for(var i = 0; i < buffer.length; i++) {\n buffer[i].call();\n }\n },\n\n listeners: function () {\n var listeners = [];\n if (typeof Turbo !== 'undefined') {\n listeners.push('turbo:load');\n } else if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {\n // Turbolinks 5\n if (Turbolinks.BrowserAdapter) {\n listeners.push('turbolinks:load');\n } else {\n // Turbolinks < 5\n listeners.push('page:load', 'DOMContentLoaded');\n }\n } else {\n listeners.push('DOMContentLoaded');\n }\n\n return listeners;\n }\n };\n}();\n\n// turbolinks triggers page:load events on page transition\n// If app isn't using turbolinks, this event will never be triggered, no prob.\nBlacklight.listeners().forEach(function(listener) {\n document.addEventListener(listener, function() {\n Blacklight.activate()\n })\n})\n\nBlacklight.onLoad(function () {\n const elem = document.querySelector('.no-js');\n\n // The \"no-js\" class may already have been removed because this function is\n // run on every turbo:load event, in that case, it won't find an element.\n if (!elem) return;\n\n elem.classList.remove('no-js')\n elem.classList.add('js')\n})\n\n\nexport default Blacklight\n","import Bloodhound from 'typeahead.js/dist/bloodhound.js'\nimport Blacklight from './core'\n\nconst Autocomplete = (() => {\n Blacklight.onLoad(function() {\n 'use strict';\n\n $('[data-autocomplete-enabled=\"true\"]').each(function() {\n var $el = $(this);\n if($el.hasClass('tt-hint')) {\n return;\n }\n var suggestUrl = $el.data().autocompletePath;\n\n var terms = new Bloodhound({\n datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),\n queryTokenizer: Bloodhound.tokenizers.whitespace,\n remote: {\n url: suggestUrl + '?q=%QUERY',\n wildcard: '%QUERY'\n }\n });\n\n terms.initialize();\n\n $el.typeahead({\n hint: true,\n highlight: true,\n minLength: 2\n },\n {\n name: 'terms',\n displayKey: 'term',\n source: terms.ttAdapter()\n });\n });\n });\n})();\n\nexport default Autocomplete\n","/* Converts a \"toggle\" form, with single submit button to add/remove\n something, like used for Bookmarks, into an AJAXy checkbox instead.\n Apply to a form. Does require certain assumption about the form:\n 1) The same form 'action' href must be used for both ADD and REMOVE\n actions, with the different being the hidden input name=\"_method\"\n being set to \"put\" or \"delete\" -- that's the Rails method to pretend\n to be doing a certain HTTP verb. So same URL, PUT to add, DELETE\n to remove. This plugin assumes that.\n Plus, the form this is applied to should provide a data-doc-id\n attribute (HTML5-style doc-*) that contains the id/primary key\n of the object in question -- used by plugin for a unique value for\n DOM id's.\n Uses HTML for a checkbox compatible with Bootstrap 4.\n new CheckboxSubmit(document.querySelector('form.something')).render()\n*/\nexport default class CheckboxSubmit {\n constructor(form) {\n this.form = form\n this.cssClass = 'toggle-bookmark'\n\n //View needs to set data-doc-id so we know a unique value\n //for making DOM id\n const uniqueId = this.form.getAttribute('data-doc-id') || Math.random();\n const id = `${this.cssClass}_${uniqueId}`\n this.checkbox = this._buildCheckbox(this.cssClass, id)\n this.span = this._buildSpan()\n this.label = this._buildLabel(id, this.cssClass, this.checkbox, this.span)\n\n // if form is currently using method delete to change state,\n // then checkbox is currently checked\n this.checked = (this.form.querySelectorAll('input[name=_method][value=delete]').length != 0);\n }\n\n _buildCheckbox(cssClass, id) {\n const checkbox = document.createElement('input')\n checkbox.setAttribute('type', 'checkbox')\n checkbox.classList.add(cssClass)\n checkbox.id = id\n return checkbox\n }\n\n _buildLabel(id, cssClass, checkbox, span) {\n const label = document.createElement('label')\n label.classList.add(cssClass)\n label.for = id\n\n label.appendChild(checkbox)\n label.appendChild(document.createTextNode(' '))\n label.appendChild(span)\n return label\n }\n\n _buildSpan() {\n return document.createElement('span')\n }\n\n _buildCheckboxDiv() {\n const checkboxDiv = document.createElement('div')\n checkboxDiv.classList.add('checkbox')\n checkboxDiv.classList.add(this.cssClass)\n checkboxDiv.appendChild(this.label)\n return checkboxDiv\n }\n\n render() {\n const children = this.form.children\n Array.from(children).forEach((child) => child.classList.add('hidden'))\n\n //We're going to use the existing form to actually send our add/removes\n //This works conveneintly because the exact same action href is used\n //for both bookmarks/$doc_id. But let's take out the irrelevant parts\n //of the form to avoid any future confusion.\n this.form.querySelectorAll('input[type=submit]').forEach((el) => this.form.removeChild(el))\n this.form.appendChild(this._buildCheckboxDiv())\n this.updateStateFor(this.checked)\n\n this.checkbox.onclick = this._clicked.bind(this)\n }\n\n async _clicked(evt) {\n this.span.innerHTML = this.form.getAttribute('data-inprogress')\n this.label.setAttribute('disabled', 'disabled');\n this.checkbox.setAttribute('disabled', 'disabled');\n const response = await fetch(this.form.getAttribute('action'), {\n body: new FormData(this.form),\n method: this.form.getAttribute('method').toUpperCase(),\n headers: {\n 'Accept': 'application/json',\n 'X-Requested-With': 'XMLHttpRequest'\n }\n })\n this.label.removeAttribute('disabled')\n this.checkbox.removeAttribute('disabled')\n if (response.ok) {\n const json = await response.json()\n this.checked = !this.checked\n this.updateStateFor(this.checked)\n document.querySelector('[data-role=bookmark-counter]').innerHTML = json.bookmarks.count\n } else {\n alert('Error')\n }\n }\n\n updateStateFor(state) {\n this.checkbox.checked = state\n\n if (state) {\n this.label.classList.add('checked')\n //Set the Rails hidden field that fakes an HTTP verb\n //properly for current state action.\n this.form.querySelector('input[name=_method]').value = 'delete'\n this.span.innerHTML = this.form.getAttribute('data-present')\n } else {\n this.label.classList.remove('checked')\n this.form.querySelector('input[name=_method]').value = 'put'\n this.span.innerHTML = this.form.getAttribute('data-absent')\n }\n }\n}\n","import Blacklight from './core'\nimport CheckboxSubmit from './checkbox_submit'\n\nconst BookmarkToggle = (() => {\n // change form submit toggle to checkbox\n Blacklight.doBookmarkToggleBehavior = function() {\n document.querySelectorAll(Blacklight.doBookmarkToggleBehavior.selector).forEach((el) => {\n new CheckboxSubmit(el).render()\n })\n };\n Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';\n\n Blacklight.onLoad(function() {\n Blacklight.doBookmarkToggleBehavior();\n });\n})()\n\nexport default BookmarkToggle\n","import Blacklight from './core'\n\nconst ButtonFocus = (() => {\n Blacklight.onLoad(function() {\n // Button clicks should change focus. As of 10/3/19, Firefox for Mac and\n // Safari both do not set focus to a button on button click.\n // See https://zellwk.com/blog/inconsistent-button-behavior/ for background information\n document.querySelectorAll('button.collapse-toggle').forEach((button) => {\n button.addEventListener('click', () => {\n event.target.focus();\n });\n });\n });\n})()\n\nexport default ButtonFocus\n","import Blacklight from './core'\n\nBlacklight.doResizeFacetLabelsAndCounts = function() {\n // adjust width of facet columns to fit their contents\n function longer (a,b) { return b.textContent.length - a.textContent.length }\n\n document.querySelectorAll('.facet-values, .pivot-facet').forEach(function(elem){\n const nodes = elem.querySelectorAll('.facet-count')\n // TODO: when we drop ie11 support, this can become the spread operator:\n const longest = Array.from(nodes).sort(longer)[0]\n if (longest && longest.textContent) {\n const width = longest.textContent.length + 1 + 'ch'\n elem.querySelector('.facet-count').style.width = width\n }\n })\n}\n\nconst FacetLoad = (() => {\n Blacklight.onLoad(function() {\n Blacklight.doResizeFacetLabelsAndCounts()\n })\n})()\n\nexport default FacetLoad\n","/*\n The blacklight modal plugin can display some interactions inside a Bootstrap\n modal window, including some multi-page interactions.\n\n It supports unobtrusive Javascript, where a link or form that would have caused\n a new page load is changed to display it's results inside a modal dialog,\n by this plugin. The plugin assumes there is a Bootstrap modal div\n on the page with id #blacklight-modal to use as the modal -- the standard Blacklight\n layout provides this.\n\n To make a link or form have their results display inside a modal, add\n `data-blacklight-modal=\"trigger\"` to the link or form. (Note, form itself not submit input)\n With Rails link_to helper, you'd do that like:\n\n link_to something, link, data: { blacklight_modal: \"trigger\" }\n\n The results of the link href or form submit will be displayed inside\n a modal -- they should include the proper HTML markup for a bootstrap modal's\n contents. Also, you ordinarily won't want the Rails template with wrapping\n navigational elements to be used. The Rails controller could suppress\n the layout when a JS AJAX request is detected, OR the response\n can include a `
` -- only the contents\n of the container will be placed inside the modal, the rest of the\n page will be ignored.\n\n If you'd like to have a link or button that closes the modal,\n you can just add a `data-dismiss=\"modal\"` to the link,\n standard Bootstrap convention. But you can also have\n an href on this link for non-JS contexts, we'll make sure\n inside the modal it closes the modal and the link is NOT followed.\n\n Link or forms inside the modal will ordinarily cause page loads\n when they are triggered. However, if you'd like their results\n to stay within the modal, just add `data-blacklight-modal=\"preserve\"`\n to the link or form.\n\n Here's an example of what might be returned, demonstrating most of the devices available:\n\n
\n
\n \n

Request Placed

\n
\n\n
\n

Some message

\n <%= link_to \"This result will still be within modal\", some_link, data: { blacklight_modal: \"preserve\" } %>\n
\n\n\n
\n <%= link_to \"Close the modal\", request_done_path, class: \"submit button dialog-close\", data: { dismiss: \"modal\" } %>\n
\n
\n\n\n One additional feature. If the content returned from the AJAX modal load\n has an element with `data-blacklight-modal=close`, that will trigger the modal\n to be closed. And if this element includes a node with class \"flash_messages\",\n the flash-messages node will be added to the main page inside #main-flahses.\n\n == Events\n\n We'll send out an event 'loaded.blacklight.blacklight-modal' with the #blacklight-modal\n dialog as the target, right after content is loaded into the modal but before\n it is shown (if not already a shown modal). In an event handler, you can\n inspect loaded content by looking inside $(this). If you call event.preventDefault(),\n we won't 'show' the dialog (although it may already have been shown, you may want to\n $(this).modal(\"hide\") if you want to ensure hidden/closed.\n\n The data-blacklight-modal=close behavior is implemented with this event, see for example.\n*/\nimport Blacklight from './core'\n\nconst Modal = (() => {\n // We keep all our data in Blacklight.modal object.\n // Create lazily if someone else created first.\n if (Blacklight.modal === undefined) {\n Blacklight.modal = {};\n }\n\n // a Bootstrap modal div that should be already on the page hidden\n Blacklight.modal.modalSelector = '#blacklight-modal';\n\n // Trigger selectors identify forms or hyperlinks that should open\n // inside a modal dialog.\n Blacklight.modal.triggerLinkSelector = 'a[data-blacklight-modal~=trigger]';\n Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]';\n\n // preserve selectors identify forms or hyperlinks that, if activated already\n // inside a modal dialog, should have destinations remain inside the modal -- but\n // won't trigger a modal if not already in one.\n //\n // No need to repeat selectors from trigger selectors, those will already\n // be preserved. MUST be manually prefixed with the modal selector,\n // so they only apply to things inside a modal.\n Blacklight.modal.preserveLinkSelector = Blacklight.modal.modalSelector + ' a[data-blacklight-modal~=preserve]';\n\n Blacklight.modal.containerSelector = '[data-blacklight-modal~=container]';\n\n Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]';\n\n // Called on fatal failure of ajax load, function returns content\n // to show to user in modal. Right now called only for extreme\n // network errors.\n Blacklight.modal.onFailure = function(jqXHR, textStatus, errorThrown) {\n console.error('Server error:', this.url, jqXHR.status, errorThrown);\n\n var contents = '
' +\n '
There was a problem with your request.
' +\n '
' +\n '

Expected a successful response from the server, but got an error

' +\n '
' +\n              this.type + ' ' + this.url + \"\\n\" + jqXHR.status + ': ' + errorThrown +\n              '
';\n $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);\n $(Blacklight.modal.modalSelector).modal('show');\n }\n\n Blacklight.modal.receiveAjax = function (contents) {\n // does it have a data- selector for container?\n // important we don't execute script tags, we shouldn't.\n // code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/main/src/ajax/load.js?source=c#L62\n var container = $('
').\n append( jQuery.parseHTML(contents) ).find( Blacklight.modal.containerSelector ).first();\n if (container.length !== 0) {\n contents = container.html();\n }\n\n $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);\n\n // send custom event with the modal dialog div as the target\n var e = $.Event('loaded.blacklight.blacklight-modal')\n $(Blacklight.modal.modalSelector).trigger(e);\n // if they did preventDefault, don't show the dialog\n if (e.isDefaultPrevented()) return;\n\n $(Blacklight.modal.modalSelector).modal('show');\n };\n\n\n Blacklight.modal.modalAjaxLinkClick = function(e) {\n e.preventDefault();\n\n $.ajax({\n url: $(this).attr('href')\n })\n .fail(Blacklight.modal.onFailure)\n .done(Blacklight.modal.receiveAjax)\n };\n\n Blacklight.modal.modalAjaxFormSubmit = function(e) {\n e.preventDefault();\n\n $.ajax({\n url: $(this).attr('action'),\n data: $(this).serialize(),\n type: $(this).attr('method') // POST\n })\n .fail(Blacklight.modal.onFailure)\n .done(Blacklight.modal.receiveAjax)\n }\n\n\n\n Blacklight.modal.setupModal = function() {\n \t// Event indicating blacklight is setting up a modal link,\n // you can catch it and call e.preventDefault() to abort\n // setup.\n \tvar e = $.Event('setup.blacklight.blacklight-modal');\n \t$('body').trigger(e);\n \tif (e.isDefaultPrevented()) return;\n\n // Register both trigger and preserve selectors in ONE event handler, combining\n // into one selector with a comma, so if something matches BOTH selectors, it\n // still only gets the event handler called once.\n $('body').on('click', Blacklight.modal.triggerLinkSelector + ', ' + Blacklight.modal.preserveLinkSelector,\n Blacklight.modal.modalAjaxLinkClick);\n $('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector,\n Blacklight.modal.modalAjaxFormSubmit);\n\n // Catch our own custom loaded event to implement data-blacklight-modal=closed\n $('body').on('loaded.blacklight.blacklight-modal', Blacklight.modal.checkCloseModal);\n\n // we support doing data-dismiss=modal on a with a href for non-ajax\n // use, we need to suppress following the a's href that's there for\n // non-JS contexts.\n $('body').on('click', Blacklight.modal.modalSelector + ' a[data-dismiss~=modal]', function (e) {\n e.preventDefault();\n });\n };\n\n // A function used as an event handler on loaded.blacklight.blacklight-modal\n // to catch contained data-blacklight-modal=closed directions\n Blacklight.modal.checkCloseModal = function(event) {\n if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {\n var modalFlashes = $(this).find('.flash_messages');\n\n $(event.target).modal('hide');\n event.preventDefault();\n\n var mainFlashes = $('#main-flashes');\n mainFlashes.append(modalFlashes);\n modalFlashes.fadeIn(500);\n }\n }\n\n Blacklight.onLoad(function() {\n Blacklight.modal.setupModal();\n });\n})()\n\nexport default Modal\n","import Blacklight from './core'\n\nconst SearchContext = (() => {\n Blacklight.doSearchContextBehavior = function() {\n const elements = document.querySelectorAll('a[data-context-href]')\n const nodes = Array.from(elements)\n\n nodes.forEach(function(element) {\n element.addEventListener('click', function(e) {\n Blacklight.handleSearchContextMethod.call(e.currentTarget, e)\n })\n })\n };\n\n Blacklight.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content\n Blacklight.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content\n\n // this is the Rails.handleMethod with a couple adjustments, described inline:\n // first, we're attaching this directly to the event handler, so we can check for meta-keys\n Blacklight.handleSearchContextMethod = function(event) {\n var link = this\n\n // instead of using the normal href, we need to use the context href instead\n let href = link.getAttribute('data-context-href')\n let target = link.getAttribute('target')\n let csrfToken = Blacklight.csrfToken()\n let csrfParam = Blacklight.csrfParam()\n let form = document.createElement('form')\n form.method = 'post'\n form.action = href\n\n\n let formContent = `\n `\n\n // check for meta keys.. if set, we should open in a new tab\n if(event.metaKey || event.ctrlKey) {\n target = '_blank';\n }\n\n if (csrfParam !== undefined && csrfToken !== undefined) {\n formContent += ``\n }\n\n // Must trigger submit by click on a button, else \"submit\" event handler won't work!\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit\n formContent += ''\n\n if (target) { form.setAttribute('target', target); }\n\n form.style.display = 'none'\n form.innerHTML = formContent\n document.body.appendChild(form)\n form.querySelector('[type=\"submit\"]').click()\n\n event.preventDefault()\n event.stopPropagation()\n };\n\n Blacklight.onLoad(function() {\n Blacklight.doSearchContextBehavior();\n });\n})()\n\nexport default SearchContext\n","import Autocomplete from './autocomplete'\nimport BookmarkToggle from './bookmark_toggle'\nimport ButtonFocus from './button_focus'\nimport FacetLoad from './facet_load'\nimport Modal from './modal'\nimport SearchContext from './search_context'\nimport Core from './core'\n\nexport default {\n Autocomplete,\n BookmarkToggle,\n ButtonFocus,\n FacetLoad,\n Modal,\n SearchContext,\n onLoad: Core.onLoad\n}\n"],"names":["Bloodhound","Core"],"mappings":";;;;;;;;;;EAAA,MAAM,UAAU,GAAG,WAAW;EAC9B,EAAE,IAAI,MAAM,GAAG,IAAI,KAAK,CAAC;EACzB,EAAE,OAAO;EACT,IAAI,MAAM,EAAE,SAAS,IAAI,EAAE;EAC3B,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;EACxB,KAAK;AACL;EACA,IAAI,QAAQ,EAAE,WAAW;EACzB,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;EAC7C,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;EACzB,OAAO;EACP,KAAK;AACL;EACA,IAAI,SAAS,EAAE,YAAY;EAC3B,MAAM,IAAI,SAAS,GAAG,EAAE,CAAC;EACzB,MAAM,IAA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W;EAChC,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAC;EACnC,IAAI,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,KAAK,GAAE;AACjD;EACA,IAAI,KAAK,CAAC,cAAc,GAAE;EAC1B,IAAI,KAAK,CAAC,eAAe,GAAE;EAC3B,GAAG,CAAC;AACJ;EACA,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW;EAC/B,IAAI,UAAU,CAAC,uBAAuB,EAAE,CAAC;EACzC,GAAG,CAAC,CAAC;EACL,CAAC;;ACtDD,gBAAe;EACf,EAAE,YAAY;EACd,EAAE,cAAc;EAChB,EAAE,WAAW;EACb,EAAE,SAAS;EACX,EAAE,KAAK;EACP,EAAE,aAAa;EACf,EAAE,MAAM,EAAEC,UAAI,CAAC,MAAM;EACrB;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"blacklight.js","sources":["../../../javascript/blacklight/core.js","../../../javascript/blacklight/checkbox_submit.js","../../../javascript/blacklight/bookmark_toggle.js","../../../javascript/blacklight/button_focus.js","../../../javascript/blacklight/facet_load.js","../../../javascript/blacklight/modal.js","../../../javascript/blacklight/search_context.js","../../../javascript/blacklight/index.js"],"sourcesContent":["const Blacklight = function() {\n var buffer = new Array;\n return {\n onLoad: function(func) {\n buffer.push(func);\n },\n\n activate: function() {\n for(var i = 0; i < buffer.length; i++) {\n buffer[i].call();\n }\n },\n\n listeners: function () {\n var listeners = [];\n if (typeof Turbo !== 'undefined') {\n listeners.push('turbo:load');\n } else if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {\n // Turbolinks 5\n if (Turbolinks.BrowserAdapter) {\n listeners.push('turbolinks:load');\n } else {\n // Turbolinks < 5\n listeners.push('page:load', 'DOMContentLoaded');\n }\n } else {\n listeners.push('DOMContentLoaded');\n }\n\n return listeners;\n }\n };\n}();\n\n// turbolinks triggers page:load events on page transition\n// If app isn't using turbolinks, this event will never be triggered, no prob.\nBlacklight.listeners().forEach(function(listener) {\n document.addEventListener(listener, function() {\n Blacklight.activate()\n })\n})\n\nBlacklight.onLoad(function () {\n const elem = document.querySelector('.no-js');\n\n // The \"no-js\" class may already have been removed because this function is\n // run on every turbo:load event, in that case, it won't find an element.\n if (!elem) return;\n\n elem.classList.remove('no-js')\n elem.classList.add('js')\n})\n\n\nexport default Blacklight\n","/* Converts a \"toggle\" form, with single submit button to add/remove\n something, like used for Bookmarks, into an AJAXy checkbox instead.\n Apply to a form. Does require certain assumption about the form:\n 1) The same form 'action' href must be used for both ADD and REMOVE\n actions, with the different being the hidden input name=\"_method\"\n being set to \"put\" or \"delete\" -- that's the Rails method to pretend\n to be doing a certain HTTP verb. So same URL, PUT to add, DELETE\n to remove. This plugin assumes that.\n Plus, the form this is applied to should provide a data-doc-id\n attribute (HTML5-style doc-*) that contains the id/primary key\n of the object in question -- used by plugin for a unique value for\n DOM id's.\n Uses HTML for a checkbox compatible with Bootstrap 4.\n new CheckboxSubmit(document.querySelector('form.something')).render()\n*/\nexport default class CheckboxSubmit {\n constructor(form) {\n this.form = form\n this.cssClass = 'toggle-bookmark'\n\n //View needs to set data-doc-id so we know a unique value\n //for making DOM id\n const uniqueId = this.form.getAttribute('data-doc-id') || Math.random();\n const id = `${this.cssClass}_${uniqueId}`\n this.checkbox = this._buildCheckbox(this.cssClass, id)\n this.span = this._buildSpan()\n this.label = this._buildLabel(id, this.cssClass, this.checkbox, this.span)\n\n // if form is currently using method delete to change state,\n // then checkbox is currently checked\n this.checked = (this.form.querySelectorAll('input[name=_method][value=delete]').length != 0);\n }\n\n _buildCheckbox(cssClass, id) {\n const checkbox = document.createElement('input')\n checkbox.setAttribute('type', 'checkbox')\n checkbox.classList.add(cssClass)\n checkbox.id = id\n return checkbox\n }\n\n _buildLabel(id, cssClass, checkbox, span) {\n const label = document.createElement('label')\n label.classList.add(cssClass)\n label.for = id\n\n label.appendChild(checkbox)\n label.appendChild(document.createTextNode(' '))\n label.appendChild(span)\n return label\n }\n\n _buildSpan() {\n return document.createElement('span')\n }\n\n _buildCheckboxDiv() {\n const checkboxDiv = document.createElement('div')\n checkboxDiv.classList.add('checkbox')\n checkboxDiv.classList.add(this.cssClass)\n checkboxDiv.appendChild(this.label)\n return checkboxDiv\n }\n\n render() {\n const children = this.form.children\n Array.from(children).forEach((child) => child.classList.add('hidden'))\n\n //We're going to use the existing form to actually send our add/removes\n //This works conveneintly because the exact same action href is used\n //for both bookmarks/$doc_id. But let's take out the irrelevant parts\n //of the form to avoid any future confusion.\n this.form.querySelectorAll('input[type=submit]').forEach((el) => this.form.removeChild(el))\n this.form.appendChild(this._buildCheckboxDiv())\n this.updateStateFor(this.checked)\n\n this.checkbox.onclick = this._clicked.bind(this)\n }\n\n async _clicked(evt) {\n this.span.innerHTML = this.form.getAttribute('data-inprogress')\n this.label.setAttribute('disabled', 'disabled');\n this.checkbox.setAttribute('disabled', 'disabled');\n const response = await fetch(this.form.getAttribute('action'), {\n body: new FormData(this.form),\n method: this.form.getAttribute('method').toUpperCase(),\n headers: {\n 'Accept': 'application/json',\n 'X-Requested-With': 'XMLHttpRequest'\n }\n })\n this.label.removeAttribute('disabled')\n this.checkbox.removeAttribute('disabled')\n if (response.ok) {\n const json = await response.json()\n this.checked = !this.checked\n this.updateStateFor(this.checked)\n document.querySelector('[data-role=bookmark-counter]').innerHTML = json.bookmarks.count\n } else {\n alert('Error')\n }\n }\n\n updateStateFor(state) {\n this.checkbox.checked = state\n\n if (state) {\n this.label.classList.add('checked')\n //Set the Rails hidden field that fakes an HTTP verb\n //properly for current state action.\n this.form.querySelector('input[name=_method]').value = 'delete'\n this.span.innerHTML = this.form.getAttribute('data-present')\n } else {\n this.label.classList.remove('checked')\n this.form.querySelector('input[name=_method]').value = 'put'\n this.span.innerHTML = this.form.getAttribute('data-absent')\n }\n }\n}\n","import Blacklight from './core'\nimport CheckboxSubmit from './checkbox_submit'\n\nconst BookmarkToggle = (() => {\n // change form submit toggle to checkbox\n Blacklight.doBookmarkToggleBehavior = function() {\n document.querySelectorAll(Blacklight.doBookmarkToggleBehavior.selector).forEach((el) => {\n new CheckboxSubmit(el).render()\n })\n };\n Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';\n\n Blacklight.onLoad(function() {\n Blacklight.doBookmarkToggleBehavior();\n });\n})()\n\nexport default BookmarkToggle\n","import Blacklight from './core'\n\nconst ButtonFocus = (() => {\n Blacklight.onLoad(function() {\n // Button clicks should change focus. As of 10/3/19, Firefox for Mac and\n // Safari both do not set focus to a button on button click.\n // See https://zellwk.com/blog/inconsistent-button-behavior/ for background information\n document.querySelectorAll('button.collapse-toggle').forEach((button) => {\n button.addEventListener('click', () => {\n event.target.focus();\n });\n });\n });\n})()\n\nexport default ButtonFocus\n","import Blacklight from './core'\n\nBlacklight.doResizeFacetLabelsAndCounts = function() {\n // adjust width of facet columns to fit their contents\n function longer (a,b) { return b.textContent.length - a.textContent.length }\n\n document.querySelectorAll('.facet-values, .pivot-facet').forEach(function(elem){\n const nodes = elem.querySelectorAll('.facet-count')\n // TODO: when we drop ie11 support, this can become the spread operator:\n const longest = Array.from(nodes).sort(longer)[0]\n if (longest && longest.textContent) {\n const width = longest.textContent.length + 1 + 'ch'\n elem.querySelector('.facet-count').style.width = width\n }\n })\n}\n\nconst FacetLoad = (() => {\n Blacklight.onLoad(function() {\n Blacklight.doResizeFacetLabelsAndCounts()\n })\n})()\n\nexport default FacetLoad\n","/*\n The blacklight modal plugin can display some interactions inside a Bootstrap\n modal window, including some multi-page interactions.\n\n It supports unobtrusive Javascript, where a link or form that would have caused\n a new page load is changed to display it's results inside a modal dialog,\n by this plugin. The plugin assumes there is a Bootstrap modal div\n on the page with id #blacklight-modal to use as the modal -- the standard Blacklight\n layout provides this.\n\n To make a link or form have their results display inside a modal, add\n `data-blacklight-modal=\"trigger\"` to the link or form. (Note, form itself not submit input)\n With Rails link_to helper, you'd do that like:\n\n link_to something, link, data: { blacklight_modal: \"trigger\" }\n\n The results of the link href or form submit will be displayed inside\n a modal -- they should include the proper HTML markup for a bootstrap modal's\n contents. Also, you ordinarily won't want the Rails template with wrapping\n navigational elements to be used. The Rails controller could suppress\n the layout when a JS AJAX request is detected, OR the response\n can include a `
` -- only the contents\n of the container will be placed inside the modal, the rest of the\n page will be ignored.\n\n If you'd like to have a link or button that closes the modal,\n you can just add a `data-dismiss=\"modal\"` to the link,\n standard Bootstrap convention. But you can also have\n an href on this link for non-JS contexts, we'll make sure\n inside the modal it closes the modal and the link is NOT followed.\n\n Link or forms inside the modal will ordinarily cause page loads\n when they are triggered. However, if you'd like their results\n to stay within the modal, just add `data-blacklight-modal=\"preserve\"`\n to the link or form.\n\n Here's an example of what might be returned, demonstrating most of the devices available:\n\n
\n
\n \n

Request Placed

\n
\n\n
\n

Some message

\n <%= link_to \"This result will still be within modal\", some_link, data: { blacklight_modal: \"preserve\" } %>\n
\n\n\n
\n <%= link_to \"Close the modal\", request_done_path, class: \"submit button dialog-close\", data: { dismiss: \"modal\" } %>\n
\n
\n\n\n One additional feature. If the content returned from the AJAX modal load\n has an element with `data-blacklight-modal=close`, that will trigger the modal\n to be closed. And if this element includes a node with class \"flash_messages\",\n the flash-messages node will be added to the main page inside #main-flahses.\n\n == Events\n\n We'll send out an event 'loaded.blacklight.blacklight-modal' with the #blacklight-modal\n dialog as the target, right after content is loaded into the modal but before\n it is shown (if not already a shown modal). In an event handler, you can\n inspect loaded content by looking inside $(this). If you call event.preventDefault(),\n we won't 'show' the dialog (although it may already have been shown, you may want to\n $(this).modal(\"hide\") if you want to ensure hidden/closed.\n\n The data-blacklight-modal=close behavior is implemented with this event, see for example.\n*/\nimport Blacklight from './core'\n\nconst Modal = (() => {\n // We keep all our data in Blacklight.modal object.\n // Create lazily if someone else created first.\n if (Blacklight.modal === undefined) {\n Blacklight.modal = {};\n }\n\n // a Bootstrap modal div that should be already on the page hidden\n Blacklight.modal.modalSelector = '#blacklight-modal';\n\n // Trigger selectors identify forms or hyperlinks that should open\n // inside a modal dialog.\n Blacklight.modal.triggerLinkSelector = 'a[data-blacklight-modal~=trigger]';\n Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]';\n\n // preserve selectors identify forms or hyperlinks that, if activated already\n // inside a modal dialog, should have destinations remain inside the modal -- but\n // won't trigger a modal if not already in one.\n //\n // No need to repeat selectors from trigger selectors, those will already\n // be preserved. MUST be manually prefixed with the modal selector,\n // so they only apply to things inside a modal.\n Blacklight.modal.preserveLinkSelector = Blacklight.modal.modalSelector + ' a[data-blacklight-modal~=preserve]';\n\n Blacklight.modal.containerSelector = '[data-blacklight-modal~=container]';\n\n Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]';\n\n // Called on fatal failure of ajax load, function returns content\n // to show to user in modal. Right now called only for extreme\n // network errors.\n Blacklight.modal.onFailure = function(jqXHR, textStatus, errorThrown) {\n console.error('Server error:', this.url, jqXHR.status, errorThrown);\n\n var contents = '
' +\n '
There was a problem with your request.
' +\n '
' +\n '

Expected a successful response from the server, but got an error

' +\n '
' +\n              this.type + ' ' + this.url + \"\\n\" + jqXHR.status + ': ' + errorThrown +\n              '
';\n $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);\n Blacklight.modal.show();\n }\n\n Blacklight.modal.receiveAjax = function (contents) {\n // does it have a data- selector for container?\n // important we don't execute script tags, we shouldn't.\n // code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/main/src/ajax/load.js?source=c#L62\n var container = $('
').\n append( jQuery.parseHTML(contents) ).find( Blacklight.modal.containerSelector ).first();\n if (container.length !== 0) {\n contents = container.html();\n }\n\n $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);\n\n // send custom event with the modal dialog div as the target\n var e = $.Event('loaded.blacklight.blacklight-modal')\n $(Blacklight.modal.modalSelector).trigger(e);\n // if they did preventDefault, don't show the dialog\n if (e.isDefaultPrevented()) return;\n\n Blacklight.modal.show();\n };\n\n\n Blacklight.modal.modalAjaxLinkClick = function(e) {\n e.preventDefault();\n\n $.ajax({\n url: $(this).attr('href')\n })\n .fail(Blacklight.modal.onFailure)\n .done(Blacklight.modal.receiveAjax)\n };\n\n Blacklight.modal.modalAjaxFormSubmit = function(e) {\n e.preventDefault();\n\n $.ajax({\n url: $(this).attr('action'),\n data: $(this).serialize(),\n type: $(this).attr('method') // POST\n })\n .fail(Blacklight.modal.onFailure)\n .done(Blacklight.modal.receiveAjax)\n }\n\n\n\n Blacklight.modal.setupModal = function() {\n \t// Event indicating blacklight is setting up a modal link,\n // you can catch it and call e.preventDefault() to abort\n // setup.\n \tvar e = $.Event('setup.blacklight.blacklight-modal');\n \t$('body').trigger(e);\n \tif (e.isDefaultPrevented()) return;\n\n // Register both trigger and preserve selectors in ONE event handler, combining\n // into one selector with a comma, so if something matches BOTH selectors, it\n // still only gets the event handler called once.\n $('body').on('click', Blacklight.modal.triggerLinkSelector + ', ' + Blacklight.modal.preserveLinkSelector,\n Blacklight.modal.modalAjaxLinkClick);\n $('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector,\n Blacklight.modal.modalAjaxFormSubmit);\n\n // Catch our own custom loaded event to implement data-blacklight-modal=closed\n $('body').on('loaded.blacklight.blacklight-modal', Blacklight.modal.checkCloseModal);\n\n // we support doing data-dismiss=modal on a with a href for non-ajax\n // use, we need to suppress following the a's href that's there for\n // non-JS contexts.\n $('body').on('click', Blacklight.modal.modalSelector + ' a[data-dismiss~=modal]', function (e) {\n e.preventDefault();\n });\n };\n\n // A function used as an event handler on loaded.blacklight.blacklight-modal\n // to catch contained data-blacklight-modal=closed directions\n Blacklight.modal.checkCloseModal = function(event) {\n if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {\n var modalFlashes = $(this).find('.flash_messages');\n\n Blacklight.modal.hide(event.target);\n event.preventDefault();\n\n var mainFlashes = $('#main-flashes');\n mainFlashes.append(modalFlashes);\n modalFlashes.fadeIn(500);\n }\n }\n\n Blacklight.modal.hide = function(el) {\n if (bootstrap.Modal.VERSION >= \"5\") {\n bootstrap.Modal.getOrCreateInstance(el).hide();\n } else {\n $(el || Blacklight.modal.modalSelector).modal('hide');\n }\n }\n\n Blacklight.modal.show = function(el) {\n if (bootstrap.Modal.VERSION >= \"5\") {\n bootstrap.Modal.getOrCreateInstance(el).show();\n } else {\n $(el || Blacklight.modal.modalSelector).modal('show');\n }\n }\n\n Blacklight.onLoad(function() {\n Blacklight.modal.setupModal();\n });\n})()\n\nexport default Modal\n","import Blacklight from './core'\n\nconst SearchContext = (() => {\n Blacklight.doSearchContextBehavior = function() {\n const elements = document.querySelectorAll('a[data-context-href]')\n const nodes = Array.from(elements)\n\n nodes.forEach(function(element) {\n element.addEventListener('click', function(e) {\n Blacklight.handleSearchContextMethod.call(e.currentTarget, e)\n })\n })\n };\n\n Blacklight.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content\n Blacklight.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content\n\n // this is the Rails.handleMethod with a couple adjustments, described inline:\n // first, we're attaching this directly to the event handler, so we can check for meta-keys\n Blacklight.handleSearchContextMethod = function(event) {\n var link = this\n\n // instead of using the normal href, we need to use the context href instead\n let href = link.getAttribute('data-context-href')\n let target = link.getAttribute('target')\n let csrfToken = Blacklight.csrfToken()\n let csrfParam = Blacklight.csrfParam()\n let form = document.createElement('form')\n form.method = 'post'\n form.action = href\n\n\n let formContent = `\n `\n\n // check for meta keys.. if set, we should open in a new tab\n if(event.metaKey || event.ctrlKey) {\n target = '_blank';\n }\n\n if (csrfParam !== undefined && csrfToken !== undefined) {\n formContent += ``\n }\n\n // Must trigger submit by click on a button, else \"submit\" event handler won't work!\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit\n formContent += ''\n\n if (target) { form.setAttribute('target', target); }\n\n form.style.display = 'none'\n form.innerHTML = formContent\n document.body.appendChild(form)\n form.querySelector('[type=\"submit\"]').click()\n\n event.preventDefault()\n event.stopPropagation()\n };\n\n Blacklight.onLoad(function() {\n Blacklight.doSearchContextBehavior();\n });\n})()\n\nexport default SearchContext\n","import BookmarkToggle from './bookmark_toggle'\nimport ButtonFocus from './button_focus'\nimport FacetLoad from './facet_load'\nimport Modal from './modal'\nimport SearchContext from './search_context'\nimport Core from './core'\n\nexport default {\n BookmarkToggle,\n ButtonFocus,\n FacetLoad,\n Modal,\n SearchContext,\n onLoad: Core.onLoad\n}\n"],"names":["Core"],"mappings":";;;;;;EAAA,MAAM,UAAU,GAAG,WAAW;EAC9B,EAAE,IAAI,MAAM,GAAG,IAAI,KAAK,CAAC;EACzB,EAAE,OAAO;EACT,IAAI,MAAM,EAAE,SAAS,IAAI,EAAE;EAC3B,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;EACxB,KAAK;AACL;EACA,IAAI,QAAQ,EAAE,WAAW;EACzB,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;EAC7C,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;EACzB,OAAO;EACP,KAAK;AACL;EACA,IAAI,SAAS,EAAE,YAAY;EAC3B,MAAM,IAAI,SAAS,GAAG,EAAE,CAAC;EACzB,MAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;EACxC,QAAQ,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;EACrC,OAAO,MAAM,IAAI,OAAO,UAAU,KAAK,WAAW,IAAI,UAAU,CAAC,SAAS,EAAE;EAC5E;EACA,QAAQ,IAAI,UAAU,CAAC,cAAc,EAAE;EACvC,UAAU,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;EAC5C,SAAS,MAAM;EACf;EACA,UAAU,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;EAC1D,SAAS;EACT,OAAO,MAAM;EACb,QAAQ,SAAS,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;EAC3C,OAAO;AACP;EACA,MAAM,OA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EAAE,SAAS,CAAC,kBAAkB,EAAC;EACvF,KAAK;AACL;EACA;EACA;EACA,IAAI,WAAW,IAAI,0BAAyB;AAC5C;EACA,IAAI,IAAI,MAAM,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EAAE;AACxD;EACA,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,OAAM;EAC/B,IAAI,IAAI,CAAC,SAAS,GAAG,YAAW;EAChC,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAC;EACnC,IAAI,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,KAAK,GAAE;AACjD;EACA,IAAI,KAAK,CAAC,cAAc,GAAE;EAC1B,IAAI,KAAK,CAAC,eAAe,GAAE;EAC3B,GAAG,CAAC;AACJ;EACA,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW;EAC/B,IAAI,UAAU,CAAC,uBAAuB,EAAE,CAAC;EACzC,GAAG,CAAC,CAAC;EACL,CAAC;;ACvDD,gBAAe;EACf,EAAE,cAAc;EAChB,EAAE,WAAW;EACb,EAAE,SAAS;EACX,EAAE,KAAK;EACP,EAAE,aAAa;EACf,EAAE,MAAM,EAAEA,UAAI,CAAC,MAAM;EACrB;;;;;;;;"} \ No newline at end of file diff --git a/app/assets/stylesheets/blacklight/_autocomplete.scss b/app/assets/stylesheets/blacklight/_autocomplete.scss new file mode 100644 index 0000000000..c134d0bf95 --- /dev/null +++ b/app/assets/stylesheets/blacklight/_autocomplete.scss @@ -0,0 +1,21 @@ +auto-complete [aria-selected="true"], +auto-complete [role="option"]:hover { + background-color: $dropdown-link-hover-bg; +} +auto-complete { + position: relative; + flex-grow: 3; + + ul { + list-style-type: none; + position: absolute; + background-color: $dropdown-bg; + padding-left: 0; + border: 1px solid $dropdown-border-color; + border-radius: $dropdown-border-radius; + } + + [role="option"]{ + padding: 0.25rem 1.5rem; + } +} diff --git a/app/assets/stylesheets/blacklight/_blacklight_base.scss b/app/assets/stylesheets/blacklight/_blacklight_base.scss index d40f8bc5fd..fdad1fd881 100644 --- a/app/assets/stylesheets/blacklight/_blacklight_base.scss +++ b/app/assets/stylesheets/blacklight/_blacklight_base.scss @@ -24,3 +24,4 @@ @import "modal"; @import "twitter_typeahead"; @import "icons"; +@import "autocomplete"; diff --git a/app/components/blacklight/search_bar_component.html.erb b/app/components/blacklight/search_bar_component.html.erb index ed35fd966c..9299195e4d 100644 --- a/app/components/blacklight/search_bar_component.html.erb +++ b/app/components/blacklight/search_bar_component.html.erb @@ -18,7 +18,20 @@ <% end %> - <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %> + + <% if autocomplete_path.present? %> + + <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), + class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", + id: "#{@prefix}q", autofocus: @autofocus %> + +
    +
    + <% else %> + <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), + class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", + id: "#{@prefix}q", autofocus: @autofocus %> + <% end %> <%= append %> diff --git a/app/controllers/concerns/blacklight/catalog.rb b/app/controllers/concerns/blacklight/catalog.rb index c3c148369a..f83d73c365 100644 --- a/app/controllers/concerns/blacklight/catalog.rb +++ b/app/controllers/concerns/blacklight/catalog.rb @@ -110,12 +110,10 @@ def opensearch end end + # Returns the dropdown list for autocomplete def suggest - respond_to do |format| - format.json do - render json: suggestions_service.suggestions - end - end + @suggestions = suggestions_service.suggestions + render 'suggest', layout: false end # @return [Array] first value is a Blacklight::Solr::Response and the second diff --git a/app/javascript/blacklight/autocomplete.js b/app/javascript/blacklight/autocomplete.js deleted file mode 100644 index e99b9f6f91..0000000000 --- a/app/javascript/blacklight/autocomplete.js +++ /dev/null @@ -1,40 +0,0 @@ -import Bloodhound from 'typeahead.js/dist/bloodhound.js' -import Blacklight from './core' - -const Autocomplete = (() => { - Blacklight.onLoad(function() { - 'use strict'; - - $('[data-autocomplete-enabled="true"]').each(function() { - var $el = $(this); - if($el.hasClass('tt-hint')) { - return; - } - var suggestUrl = $el.data().autocompletePath; - - var terms = new Bloodhound({ - datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), - queryTokenizer: Bloodhound.tokenizers.whitespace, - remote: { - url: suggestUrl + '?q=%QUERY', - wildcard: '%QUERY' - } - }); - - terms.initialize(); - - $el.typeahead({ - hint: true, - highlight: true, - minLength: 2 - }, - { - name: 'terms', - displayKey: 'term', - source: terms.ttAdapter() - }); - }); - }); -})(); - -export default Autocomplete diff --git a/app/javascript/blacklight/index.js b/app/javascript/blacklight/index.js index 5cf804a797..b683737a7e 100644 --- a/app/javascript/blacklight/index.js +++ b/app/javascript/blacklight/index.js @@ -1,4 +1,3 @@ -import Autocomplete from './autocomplete' import BookmarkToggle from './bookmark_toggle' import ButtonFocus from './button_focus' import FacetLoad from './facet_load' @@ -7,7 +6,6 @@ import SearchContext from './search_context' import Core from './core' export default { - Autocomplete, BookmarkToggle, ButtonFocus, FacetLoad, diff --git a/app/views/catalog/suggest.html.erb b/app/views/catalog/suggest.html.erb new file mode 100644 index 0000000000..0ff86b9a16 --- /dev/null +++ b/app/views/catalog/suggest.html.erb @@ -0,0 +1,3 @@ +<% @suggestions.each do |suggestion| %> +
  • <%= suggestion['term'] %>
  • +<% end %> diff --git a/app/views/layouts/blacklight/base.html.erb b/app/views/layouts/blacklight/base.html.erb index c9938e1b21..0e985016ac 100644 --- a/app/views/layouts/blacklight/base.html.erb +++ b/app/views/layouts/blacklight/base.html.erb @@ -15,6 +15,9 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> <%= content_for(:head) %> +