Skip to content

Commit

Permalink
Remove chosen.js dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sandbergja committed Dec 8, 2023
1 parent de4034f commit 5032dbe
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 154 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
12 changes: 0 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -685,7 +674,6 @@ DEPENDENCIES
capistrano-passenger
capistrano-rails
capybara
chosen-rails
coveralls_reborn
ddtrace (~> 1.14.0)
devise (>= 4.6.0)
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//= require popper
//= require bootstrap
//= require modernizr
//= require chosen-jquery
//
//= require bootstrap/tab
//
Expand Down
253 changes: 134 additions & 119 deletions app/assets/javascripts/orangelight.js
Original file line number Diff line number Diff line change
@@ -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
})
})
3 changes: 1 addition & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* file per style scope.
*
*= require 'blacklight_range_limit'
*= require 'bootstrap-select'
*= require chosen
*= require 'bootstrap-select'
*= require_self
*/

Expand Down
18 changes: 0 additions & 18 deletions app/assets/stylesheets/components/search--advanced.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -104,9 +89,6 @@
margin-bottom: 5px;
}

.chosen-container .chosen-results li.group-result {
cursor: pointer;
}

#advanced_search_facets .dropdown-toggle::after {
position: absolute;
Expand Down

0 comments on commit 5032dbe

Please sign in to comment.