From 5032dbeb4eb999046db94ec4a377ffe313a5ae36 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Fri, 8 Dec 2023 12:55:49 -0800 Subject: [PATCH] Remove chosen.js dependency --- Gemfile | 2 - Gemfile.lock | 12 - app/assets/javascripts/application.js | 1 - app/assets/javascripts/orangelight.js | 253 ++++++++++-------- app/assets/stylesheets/application.scss | 3 +- .../components/search--advanced.scss | 18 -- 6 files changed, 135 insertions(+), 154 deletions(-) diff --git a/Gemfile b/Gemfile index fdefe7014..b00d21049 100644 --- a/Gemfile +++ b/Gemfile @@ -22,8 +22,6 @@ gem 'bootstrap-select-rails' # In the Capistrano documentation, it has these limited to the development group, and `require: false`` gem 'capistrano', '~> 3.4' gem 'capistrano-passenger' -# jquery multiselect plugin for advanced search -gem 'chosen-rails' gem 'ddtrace', '~> 1.14.0' # Authentication and authorization gem 'devise', '>= 4.6.0' diff --git a/Gemfile.lock b/Gemfile.lock index a2f5f7823..2853e1d02 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,21 +179,10 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - chosen-rails (1.10.0) - coffee-rails (>= 3.2) - railties (>= 3.0) - sassc-rails (>= 2.1.2) chronic (0.10.2) coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - coffee-rails (5.0.0) - coffee-script (>= 2.2.0) - railties (>= 5.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) concurrent-ruby (1.2.2) connection_pool (2.4.1) coveralls_reborn (0.28.0) @@ -685,7 +674,6 @@ DEPENDENCIES capistrano-passenger capistrano-rails capybara - chosen-rails coveralls_reborn ddtrace (~> 1.14.0) devise (>= 4.6.0) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4f2c156aa..94e466ccb 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,7 +16,6 @@ //= require popper //= require bootstrap //= require modernizr -//= require chosen-jquery // //= require bootstrap/tab // diff --git a/app/assets/javascripts/orangelight.js b/app/assets/javascripts/orangelight.js index e2eff1748..978dbb45b 100644 --- a/app/assets/javascripts/orangelight.js +++ b/app/assets/javascripts/orangelight.js @@ -1,135 +1,150 @@ //= require 'jquery' -$(function() { - //link highlighting of hierarchy - $(".search-subject, .search-name-title, .search-title").hover( - function() { - $(this).prevAll().addClass("field-hierarchy"); - }, - function() { - $(this).prevAll().removeClass("field-hierarchy"); - } - ); +$(function () { + //link highlighting of hierarchy + $('.search-subject, .search-name-title, .search-title').hover( + function () { + $(this).prevAll().addClass('field-hierarchy') + }, + function () { + $(this).prevAll().removeClass('field-hierarchy') + } + ) - $('.chosen-select').chosen({ - allow_single_deselect: true, - no_results_text: 'No results matched' - }); + //tooltip for everything else + $('#main-container').tooltip({ + selector: "[data-toggle='tooltip']", + placement: 'bottom', + container: 'body', + trigger: 'hover', + }) - //tooltip for everything else - $("#main-container").tooltip({ - selector: "[data-toggle='tooltip']", - placement: "bottom", - container: "body", - trigger: "hover" - }); + // availability toggle journal current issues + $('#availability').on('click', '.trigger', function (event) { + event.preventDefault() + $(this) + .siblings('.journal-current-issues') + .children() + .toggleClass('all-issues') + $(this).text(function (i, toggle) { + return toggle === 'More' ? 'Less' : 'More' + }) + }) - // availability toggle journal current issues - $("#availability").on("click", ".trigger", function(event) { - event.preventDefault(); - $(this).siblings(".journal-current-issues").children().toggleClass("all-issues"); - $(this).text(function(i, toggle) { - return toggle === "More" ? "Less" : "More"; - }); + //Select all items in specific account table to be checked or unchecked + $('body').on('change', "[id^='select-all']", function (e) { + if (this.checked) { + $(this) + .closest('table') + .find('td input:checkbox') + .each(function (index) { + $(this).prop('checked', true) + $(this).closest('tr').toggleClass('info', this.checked) + }) + } else { + $(this) + .closest('table') + .find('td input:checkbox') + .each(function (index) { + $(this).prop('checked', false) + $(this).closest('tr').toggleClass('info', this.checked) + }) + } + }) - }); + //Add active class to tr if selected + $('body').on('change', 'td input:checkbox', function (e) { + $(this).closest('tr').toggleClass('info', this.checked) + }) - //Select all items in specific account table to be checked or unchecked - $("body").on("change", "[id^='select-all']", function (e) { - if (this.checked) { - $(this).closest("table").find("td input:checkbox").each(function(index) { - $(this).prop("checked", true); - $(this).closest("tr").toggleClass("info", this.checked); - }); - } else { - $(this).closest("table").find("td input:checkbox").each(function(index) { - $(this).prop("checked", false); - $(this).closest("tr").toggleClass("info", this.checked); - }); - } - }); + // Auto dismiss alert-info and alert-success + setTimeout(function () { + $('.flash_messages .alert-info, .flash_messages .alert-success').fadeOut( + 'slow', + function () { + $( + '.flash_messages .alert-info, .flash_messages .alert-success' + ).remove() + } + ) + }, 5000) + + $('#search_field').on('change', function (e) { + $('#q').attr('placeholder', $(this).find(':selected').data('placeholder')) + }) - //Add active class to tr if selected - $("body").on("change", "td input:checkbox", function(e) { - $(this).closest("tr").toggleClass("info", this.checked); - }); + // Back to top button appears on scroll + $(window).scroll(function () { + if ($(this).scrollTop() > 100) { + $('.back-to-top').fadeIn() + } else { + $('.back-to-top').fadeOut() + } + }) - // Auto dismiss alert-info and alert-success - setTimeout(function() { - $(".flash_messages .alert-info, .flash_messages .alert-success").fadeOut('slow', function(){ - $(".flash_messages .alert-info, .flash_messages .alert-success").remove(); - }); - }, 5000); + $('.back-to-top').click(function () { + $('html, body').animate({ scrollTop: 0 }, 800) + return false + }) - $('#search_field').on('change', function(e){ - $('#q').attr('placeholder', $(this).find(':selected').data('placeholder')); - }); + $('.document-thumbnail').click(function (e) { + var target = $('#viewer-container') + if (target.length) { + e.preventDefault() + $('html, body').stop().animate( + { + scrollTop: target.offset().top, + }, + 800 + ) + } + }) - // Back to top button appears on scroll - $(window).scroll(function(){ - if ($(this).scrollTop() > 100) { - $('.back-to-top').fadeIn(); + $('.facet-select').one('click', function (e) { + if ($('#q').val()) { + var query = encodeURIComponent($('#q').val()) + var queryDict = {} + this.href + .substr(1) + .split('&') + .forEach(function (item) { + queryDict[item.split('=')[0]] = item.split('=')[1] + }) + if (query != queryDict['q']) { + if (queryDict['q'] == null) { + this.href = this.href + '&q=' + query } else { - $('.back-to-top').fadeOut(); + this.href = this.href.replace('&q=' + queryDict['q'], '&q=' + query) } - }); - - $('.back-to-top').click(function(){ - $('html, body').animate({scrollTop : 0},800); - return false; - }); - - $('.document-thumbnail').click(function(e){ - var target = $('#viewer-container'); - if( target.length ) { - e.preventDefault(); - $('html, body').stop().animate({ - scrollTop: target.offset().top - }, 800); + } + if ($('#search_field').val() != queryDict['search_field']) { + if (queryDict['search_field'] == null) { + this.href = this.href + '&search_field=' + $('#search_field').val() + } else { + this.href = this.href.replace( + '&search_field=' + queryDict['search_field'], + '&search_field=' + $('#search_field').val() + ) } - }); + } + } + }) + $('.clickable-row').on('click', function () { + window.location = $(this).data('href') + }) - $('.facet-select').one('click', function (e) { - if ($('#q').val()) { - var query = encodeURIComponent($('#q').val()) - var queryDict = {}; - this.href.substr(1).split("&").forEach(function(item) { - queryDict[item.split("=")[0]] = item.split("=")[1] - }); - if (query != queryDict['q']) { - if (queryDict['q'] == null) { - this.href = this.href + '&q=' + query; - } else { - this.href = this.href.replace('&q='+queryDict['q'], '&q='+query); - } - } - if ($('#search_field').val() != queryDict['search_field']) { - if (queryDict['search_field'] == null) { - this.href = this.href + '&search_field=' + $("#search_field").val(); - } else { - this.href = this.href.replace('&search_field='+queryDict['search_field'], - '&search_field='+$('#search_field').val()); - } - } + $('#unauthenticated-library-account-link').on('click', function () { + // Update the page with the id of the user once they have authenticated. + // Since we don't know how long it will take the user to authenticate via CAS + // we set up a timer to check every couple of seconds. + var getUserIdTimer = setInterval(function () { + $.getJSON('/account/user-id', function (data) { + if (data.user_id !== null) { + clearInterval(getUserIdTimer) + $('button.dropdown-toggle.btn-account').text(data.user_id) } - }); - $('.clickable-row').on("click",function(){ - window.location = $(this).data('href'); - }); - - $('#unauthenticated-library-account-link').on("click",function(){ - // Update the page with the id of the user once they have authenticated. - // Since we don't know how long it will take the user to authenticate via CAS - // we set up a timer to check every couple of seconds. - var getUserIdTimer = setInterval(function(){ - $.getJSON("/account/user-id", function(data) { - if (data.user_id !== null) { - clearInterval(getUserIdTimer); - $("button.dropdown-toggle.btn-account").text(data.user_id); - } - }); - }, 2000); - return true; - }); - -}); + }) + }, 2000) + return true + }) +}) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index b77cf98c6..faf9364c1 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -11,8 +11,7 @@ * file per style scope. * *= require 'blacklight_range_limit' -*= require 'bootstrap-select' - *= require chosen + *= require 'bootstrap-select' *= require_self */ diff --git a/app/assets/stylesheets/components/search--advanced.scss b/app/assets/stylesheets/components/search--advanced.scss index c355e888f..8c6cf8086 100644 --- a/app/assets/stylesheets/components/search--advanced.scss +++ b/app/assets/stylesheets/components/search--advanced.scss @@ -49,21 +49,6 @@ margin-bottom: 0; } -.chosen-container-multi .chosen-choices { - min-height: 34px; - border-radius: 4px; - background-image: none; - padding: 0 5px 3.25px; -} - -.chosen-container-multi .chosen-choices li.search-field { - margin-top: 3px; -} - -.chosen-container-multi .chosen-choices li.search-choice { - margin: 6.5px 5px -1px 0; -} - #guided_search { padding-bottom: 1.25em; } @@ -104,9 +89,6 @@ margin-bottom: 5px; } -.chosen-container .chosen-results li.group-result { - cursor: pointer; -} #advanced_search_facets .dropdown-toggle::after { position: absolute;