CSS and JavaScript Code Library

 

 

This Code Library is a collection of code snippets gathered for support tickets and libraries using Aspen as a reference. Using CSS and Javascript can make your Aspen catalog less accessible and we cannot guarantee mobile responsiveness. Custom code has the chance to break in future updates. Our first preference when making customizations is to put in a development request so that we can add that feature into our base code. Questions on using these code snippets are best asked in the Aspen Community Slack Channel.

Account

Contact Information

Remove the Home Library selection
/* Remove the home link selection from contact information */
#propertyRowborrower_branchcode {
display: none;
}
#borrower_branchcodeSelect {
display: none;
}
Change the Color of ILS Message Background

The default color of the ILS Message background is blue and controlled by the alert color in Themes & Layout.

To change the color of this message, use:

.ils-message {
    background-color: #FCF4A3;
}

In this example, I changed to a yellow hex but the hex can be updated as needed.

Hide fields on patron account

CSS if you need to apply for just one catalog:

/*** Hide rows on the contact information form in the user account ***/
 #propertyRowidentitySection, #propertyRowmainAddressSection, #propertyRowalternateAddressSection, #propertyRowalternateContactSection {
display: none;
}

Javascript if you need to apply to multiple catalogs in a consortium:

<script>
$( "#propertyRowborrower_sex.form-group" ).hide();
</script>
Update a Tool Tip Field

You can usually update the text on a field in Contact Information with Translation Mode in Aspen. 

For the related tool tips, you can use a JavaScript snippet such as:

<script>
if( $('#MyAccount-ContactInformation').length ) {
  $('label[for="borrower_initials"]').text('Pickup alias: ');
}
</script>

The label is the current field name and the text is what you would like to show instead.

Hide pronouns field in the patron account
<script>
$( "#propertyRowadditionalInfoSection.form-group" ).hide();
</script>
Hide "Reset Username" Links in Your Account
/* Hides the 'Reset Username' links in the user account menus */

div class header-menu-option
href="/MyAccount/ResetUsername"

div class myAccountLink
href="/MyAccount/ResetUsername"

<script>
/*** Hide Reset Username link in account menus ***/
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetUsername']" ).hide();
$( ".myAccountLink a[href='/MyAccount/ResetUsername']" ).hide();
</script>

Your Preferences

Hide Alternate Pickup Locations
/**** Hide alternate pickup locations ****/

#myLocation1 {
display: none;
}
#myLocation2 {
display: none;
}
label[for=”myLocation1”] {
display: none;
}
label[for=”myLocation2”] {
display: none;
}

Messaging Settings

Hide specific checkboxes
/**** Hide checkbox for SMS on item check-in line ****/
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms5{
display: none;
}

JavaScript option for consortia/multiple catalogs (on Ramapo as an example). You only need to adjust the input IDs in the line "const inputIdsToHide" according to what you actually want to hide:

<script>
    // Specify the table ID and the input IDs you want to hide
    const tableId = 'messagingTable';
    const inputIdsToHide = ['sms1', 'sms2', 'sms5', 'sms6', 'sms9', 'phone1', 'phone2', 'phone5', 'phone6', 'phone9'];

    // Get the table by ID
    const table = document.getElementById(tableId);

    // Loop through each input ID and hide if found within the table
    inputIdsToHide.forEach(inputId => {
        const input = table.querySelector(`#${inputId}`);
        if (input) {
            input.style.display = 'none'; // Hide the input
        }
    });
</script>
Hide lines
/**** Hide ILL Ready / ILL Unavailable lines in messaging settings ****/

tr#messageType7Row {
display: none;
}
tr#messageType8Row {
display: none;
}

/**** Hide Auto Renewals line in messaging settings ****/

tr#messageType9Row {
display: none;
}

/*** Hide Hold Reminder line in messaging settings ***/

tr#messageType10Row {
display: none;
}

/*** Hide ILL Update line in messaging settings ***/

tr#messageType11Row {
display: none;
}
Hide Do Not Notify or Checkboxes (Also Info on Hiding Columns)

If you want to hide specific checkboxes in the rows, you can use CSS like this in the theme:

/**** Hide Do Not Modify checkboxes in messaging settings ****/

table#messagingTable.table.table-bordered.table-condensed.table-striped #none1{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none2{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none3{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none4{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none5{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none6{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none7{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none8{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none9{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #none10{
display: none;
}

If you want to hide the entire column, then you can add this javascript:

<script>
// Hide Do Not Notify column
$('th:contains("Do not notify")').hide();
$( "#messageType1Row td:nth-child(6)" ).hide();
$( "#messageType2Row td:nth-child(6)" ).hide();
$( "#messageType4Row td:nth-child(6)" ).hide();
$( "#messageType5Row td:nth-child(6)" ).hide();
$( "#messageType6Row td:nth-child(6)" ).hide();
$( "#messageType9Row td:nth-child(6)" ).hide();
$( "#messageType10Row td:nth-child(6)" ).hide();
</script>

Note: If you want to hid other columns, you can switch out the 6. For example, switching it to 5 would hide all the entire Digests Only column, switching to 2 would hide the entire Advance Notice column.

Hide SMS Checkboxes
/**** Hide SMS Checkboxes in messaging settings ****/

table#messagingTable.table.table-bordered.table-condensed.table-striped #sms1{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms2{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms3{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms4{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms5{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms6{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms7{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms8{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms9{
display: none;
}
table#messagingTable.table.table-bordered.table-condensed.table-striped #sms10{
display: none;
}
Hide SMS Message Columns
<script>
// Hide SMS column
$('th:contains("SMS")').hide();
$( "#messageType1Row td:nth-child(3)" ).hide();
$( "#messageType2Row td:nth-child(3)" ).hide();
$( "#messageType4Row td:nth-child(3)" ).hide();
$( "#messageType5Row td:nth-child(3)" ).hide();
$( "#messageType6Row td:nth-child(3)" ).hide();
$( "#messageType7Row td:nth-child(3)" ).hide();
$( "#messageType8Row td:nth-child(3)" ).hide();
$( "#messageType9Row td:nth-child(3)" ).hide();
$( "#messageType10Row td:nth-child(3)" ).hide();
$( "#messageType11Row td:nth-child(3)" ).hide();
</script>
Hide SMS Provider Row
/**** Hide SMS Provider Row in messaging settings ****/

#smsProviderRow {
display: none;
}
Hide SMS Number Row
/**** Hide SMS Number Row in messaging settings ****/

#smsNumberRow {
display: none;
}
Hide SMS Alert
/**** Hide SMS Alert in messaging settings ****/

#smsNoticeRow {
display: none;
}
Hide ILL Rows
Hide ILL rows on messaging preferences

<script>
$( "tr#messageType7Row" ).hide();
$( "tr#messageType8Row" ).hide();
$( "tr#messageType11Row" ).hide();
</script>

Browse Categories

Change colors of arrow button underneath browse categories
/**** Change colors of arrow button underneath browse categories ****/
#more-browse-results {
background-color:#d35050;
color:#1890cc;
}
Change colors of arrow buttons next to browse categories
/**** Side scrolling arrows - Getting rid of background and making arrows blue ****/

#browse-category-picker .jcarousel-control-prev, #browse-category-picker .jcarousel-control-next {
    background-color: transparent;
    color: #004aad;
    font-size: 50px;
    border: none;
box-shadow: none;
}
Round browse categories
/*Rounded Browse Category Buttons*/
div.jcarousel>ul>li{border-radius: 7px;}

horizontal-menu-bar-container {
padding: 0 !important;
}
Add Icons to Browse Categories

You can get the browse category name quickly from the URL: https://catalog.darienlibrary.org/?browseCategory=d_trending In this example, you could put -d_trending:before

You can get the Font Awesome icon unicode from here:

 https://fontawesome.com/v5/search?o=r&m=free&s=solid then click on the icon and look for the unicode
Screenshot 2023-07-11 at 5.22.45 PM.png
 /* CSS for all Categories */
div#browse-category-carousel ul li {
    display: inline-block;
}
div#browse-category-carousel ul li:before {
    content: '';
    font-family: 'Font Awesome 5 Free';
    display: inline-block;
    padding-top: 8px;
    font-weight: bolder;
}
/* CSS for icons on specific categories */
#browse-category-picker li#browse-category-{BROWSECATEGORYNAME}:before {
    content: '\{unicode}';
}
#browse-category-picker li#browse-category-{BROWSECATEGORYNAME}:before {
    content: '\{unicode}';
}
#browse-category-picker li#browse-category-{BROWSECATEGORYNAME}:before {
    content: '\{unicode}';
}

Another related code snippet shared by another library:

div#browse-category-carousel.jcarousel ul li {
    display: inline-block;
}
div#browse-category-carousel.jcarousel ul li:before {
    content: '';
    font-family: 'Font Awesome 5 Free';
    display: inline-block;
    padding-top: 5px;
    font-weight: 900;
}
/* CSS for icons on specific categories */
#browse-category-picker li#browse-category-main_new_fiction:before {
    content: '\f005';
}

Font and Text Size

Change weight of font awesome icons

Note: This will only work with the free “regular” font awesome icons on this cheatsheet

/**** Change file icon to lighter font weight ****/
.menu-icon.menu-bar-option > i.fas.fa-file.fa-lg:before {
font-weight: 200;
}

/**** Change question-circle icon to lighter font weight ****/
a#help-menu-trigger.dropdown-toggle.menu-icon.menu-bar-option  > i.fas.fa-question-circle.fa-lg:before {
font-weight: 200;
}
Increase font size for ‘Narrow Your Results’
/**** Increase font size for ‘Narrow Your Results’ ****/
#narrow-search-label.sidebar-label {
font-size: 14pt;
}
Increase the size of the Where is it? Link
/**** Make "Where is it?" link larger ****/
.itemSummary a {
font-size: 18px;
font-weight: bold;
}
Increase font size for all My Account sidebar links
/* Larger font for My Account sidebar links */
.myAccountLink { font-size: 14px; }
Increase font size across the entire catalog
/*** Increase Font Size for Interface Elements ***/

/* body, */
.facetTitle,
.sidebar-links .panel-body,
#descriptionPlaceholder,
#availabilityControl button,
.facetList .panel-title,
.panel-title {
    font-size: 16px!important;
}

#availabilityControl button {
font-weight: bold;
}

.related-manifestation-copies-message,
.result-value,
.result-label {
font-size: 14px;
}

.manifestation-format .btn,
.btn-group-vertical > .btn, .btn-group-vertical > .btn-group, .btn-group-vertical > .btn-group > .btn,
#results-sort {
    font-size: 13px;
}

.itemSummary {
    font-size: 14px;
    font-weight: bold;
    padding-top: 10px;
}

#availabilityControlContainer {
padding-top: 10px;
padding-bottom: 20px;
}

div#categoryValues.row {
display: flex;
  justify-content: center; 
align-items: center;
text-align: center;
}

.col-xs-6 .formatCategoryLabel {
text-align: center;
}

Here is another Code Snippet from a Library (updated 6/12/24 by Sierra/CWMARS to change rem units to px units):

/*----------------------------------------*/
/* Based on code from Sally at the Knox County Public Library */
/* Using rem units conflicts with the NoveList All-in-One panel */
/* Rewritten to use px instead */
/*----------------------------------------*/

body {
font-size: 18px;
overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  margin-bottom: 5px;
  font-weight: 700;
  line-height: 1.2;
}
h1, .h1 {
  font-size: 36px;
}
h2, .h2 {
  font-size: 32px;
}
h3, .h3 {
  font-size: 24px;
}
h4, .h4 {
  font-size: 20px;
}
h5, .h5 {
  font-size: 18px;
}
h6, .h6 {
  font-size: 16px;
}

.fa-search::before, .result-title {
    font-size: 22px;
}

#more-details-accordion .panel-title h2,  .result, .faceValue, .btn-sm, .btn-xs, .related-manifestation-shelf-status,  .sidebar-links .panel-body,  .facetValue, .panel-title, .adminSection .adminPanel .adminActionDescription, .btn-group-sm > .btn,  .adminSection .adminPanel .adminActionLabel, .btn, .form-control, .header-menu-section, .header-menu-option, formatCategoryLabel  {
    font-size: 18px;
    font-weight: 500;
}

.panel-title,  #more-details-accordion .panel-body {
    font-size: 18px;
    font-weight: 500;
}

.small, .smallText,  .full-rating, .itemSummary, .breadcrumb.small, table.tablesorter, table.tablesorter thead tr th, table.tablesorter tfoot tr th {
    font-size: 16px;
}

/*------------------------------*/
/* Main menu                 */
/* turn off caps menu items */
/* set font-size and weight           */
/*------------------------------*/
#horizontal-menu-bar-container .menu-icon .menu-bar-label {
    text-transform: none; /*Delete this text transformation if you want All Caps for Menu Links */
    font-size: 18px; 
    font-weight: 600;
}

 .menu-section-left i, .menuToggleButton i.fa-bars, div.dropdown.menuToggleButton.accountMenu i, .menu-section-right i.fa-sign-in-alt {
    font-size: 18px;
 }

 /* Search results forward and back carets*/
.search-results-navigation .fa-caret-right::before, .search-results-navigation .fa-caret-left::before  {
    font-size: 16px;
}

/*------------------------------*/
/* End of Sally's Code */
/*Minor addition from KStapp in Springfield*/
/* Search box height */
/*------------------------------*/

.form-control {
    height: 2.2em;
}

#horizontal-search-box #lookfor {
    height: 2.2em;
}



Original version of the above snippet using rem units for text size:

IMPORTANT! The below CSS snippet is not compatible with the NoveList One content enrichment. If you plan to use NoveList One, do not use the below CSS.

/*----------------------------------------*/
/* Default text styles                    */
/* Resetting the base font-size to        */
/* 62.5% sets it to 10px for most browsers*/
/* Rems are simple to calculate from here */
/* 10px = 1rem, 14px = 1.4rem, 20px = 2rem*/
/*----------------------------------------*/
html {
    font-size: 62.5%;
    overflow-x: hidden;
}

body {
font-size: 1.6rem;
overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  margin-bottom: 0.5rem;
  font-weight: 700;
  line-height: 1.2;
}
h1, .h1 {
  font-size: 4rem;
}
h2, .h2 {
  font-size: 3.2rem;
}
h3, .h3 {
  font-size: 2.4rem;
}
h4, .h4 {
  font-size: 1.8rem;
}
h5, .h5 {
  font-size: 1.6rem;
}
h6, .h6 {
  font-size: 1.6rem;
}

.fa-search::before, .result-title {
    font-size: 2rem;
}

#more-details-accordion .panel-title h2, #more-details-accordion .panel-body, .result, .faceValue, .btn-sm, .btn-xs, .related-manifestation-shelf-status,  .sidebar-links .panel-body,  .facetValue, .panel-title, .adminSection .adminPanel .adminActionDescription, .btn-group-sm > .btn,  .adminSection .adminPanel .adminActionLabel, .btn, .form-control  {
    font-size: 1.6rem;
    font-weight: 400;
}

.small, .smallText,  .itemSummary, .breadcrumb.small, table.tablesorter, table.tablesorter thead tr th, table.tablesorter tfoot tr th {
    font-size: 1.4rem;
}

/*------------------------------*/
/* Main menu                 */
/* turn off caps menu items */
/* set font-size and weight           */
/*------------------------------*/
#horizontal-menu-bar-container .menu-icon .menu-bar-label {
    text-transform: none; 
    font-size: 2.8rem; 
    font-weight: 600;
}

 .menu-section-left i, .menuToggleButton i.fa-bars, div.dropdown.menuToggleButton.accountMenu i, .menu-section-right i.fa-sign-in-alt {
    font-size: 2.8rem;
 }

 /* Search results forward and back carets*/
.search-results-navigation .fa-caret-right::before, .search-results-navigation .fa-caret-left::before  {
    font-size: 1.6rem;
}
Add CSS to translations

Note: The example below is to make the text bold, but the text could be adjusted many other ways with this method. The text should be added directly into where the text is translated.

<span style='font-weight: bold !important'>put your text here</span>

This is what it looks like adding the above in translation mode:

Give Format Buttons Larger Font
.manifestation-format > a.btn-primary {
font-size: 15px !important; }
Give Show Editions Button Larger Font
.btn-editions {
font-size: 15px !important;
}

Grouped Work Display

Change color of grouped work format backgrounds
.row.related-manifestation.grouped {
background-color:#68ffea;
}

.row.related-manifestation.grouped .row.displayed.striped-odd {
background-color:#68ffea;
}
Add Underlines to Hyperlinks
.result-value > a {
  text-decoration: underline;
}
Change color of Add to List button
/**** Change color of Add to List button ****/

button.btn.btn-sm.btn-tools.addToListBtn {
background-color:#68ffea;
}
Hide Pinterest Sharing
i.fab.fa-pinterest-square.fa-2x.fa-fw {
display: none;
}
Change color of status labels
/*** change color of green status labels ***/
.label-success {
background-color: #YOURHEXHERE;
}

/*** change color of red status labels ***/
.label-danger {
background-color: #YOURHEXHERE;
}

/*** change color of yellow status labels ***/
.label-warning {
background-color: #YOURHEXHERE;
}
Change color of text in status labels

NB consider accessibility when styling text colors in relation to the background colors of these labels

/*** change color of text in green status labels ***/
.label-success {
color: #YOURHEXHERE;
}
/*** change color of text in red status labels ***/
.label-danger {
color: #YOURHEXHERE;
}
/*** change color of text in yellow status labels ***/
.label-warning {
color: #YOURHEXHERE;
}
Automatically open “Show All Holdings” button in detailed display
<script>
$(document).ready(function() {
   $("button#showOtherMarcHoldings").trigger('click');
});
</script>
Automatically open/expand the “Show All Copies” button
<script
$("document").ready(function() {
    setTimeout(function() {
        $("div#holdings-section-In_this_library.accordion-body a.btn.btn-default.btn-sm").trigger('click');
    },5);
});
</script>

They wanted to show all copies by default when viewing a record

Note: the “In_this_library” portion of the div may be different depending on the library!

Here is a script that will expand "Other Locations" copies AND automatically click the "Show All Copies" button so that all copies from all locations are shown without having to click anything. This is in use on MCFLS (Milwaukee County).

/*** Request from ticket #127898 ***/

<script>
jQuery(document).ready(function() {
        $('#copiesPanel').addClass('active');

        const container = document.querySelector("#copiesPanelBody div.panel-body");
        const accordionGroups = container.querySelectorAll("div.accordion-group");

        if(accordionGroups.length > 1) {
          let otherLocationsGroup = accordionGroups[1];

          const header = otherLocationsGroup.querySelector('#holdings-header-Other_Locations');
          $(header).removeClass('accordion-heading');

          const toggle = header.querySelector('.accordion-toggle');
          $(toggle).removeClass('accordion-toggle');
          var dataset = toggle.dataset;
          for (var key in dataset) {
            toggle.removeAttribute("data-" + key.split(/(?=[A-Z])/).join("-").toLowerCase());
          }

          const section = otherLocationsGroup.querySelector('#holdings-section-Other_Locations');
          $(section).removeClass('accordion-body');
          $(section).removeClass('collapse');
        }
    }
);
</script>
<script>
$("document").ready(function() {
    setTimeout(function() {
        $("div#holdings-section-Other_Locations a.btn.btn-default.btn-sm").trigger('click');
    },5);
});
</script>

Materials Requests

Hide specific fields on the Materials Request form

If it's one library catalog, use CSS:

/*** Hide rows on the materials request form ***/
 #propertyRowcopyrightdate, #propertyRowisbn, #propertyRowalternateAddressSection, #propertyRowpublishercode, #propertyRowplace, #propertyRowquantity, #propertyRowitemtype, #propertyRowbranchcode, #propertyRownote, #propertyRowpatronreason {
display: none;
}

If this needs to be applied to multiple catalogs across a consortium, use JS:

<script>
$( "#propertyRowcopyrightdate" ).hide();
$( "#propertyRowisbn" ).hide();
$( "#propertyRowpublishercode" ).hide();
$( "#propertyRowcollectiontitle" ).hide();
$( "#propertyRowplace" ).hide();
$( "#propertyRowquantity" ).hide();
$( "#propertyRowitemtype" ).hide();
$( "#propertyRowbranchcode" ).hide();
$( "#propertyRownote" ).hide();
$( "#propertyRowpatronreason" ).hide();
</script>

In either case, use the Inspect tool in the browser to find the row/property ID.

Change a text input field into a dropdown menu
<script>
$(document).ready(function () {
$("#collectiontitle.form-control")
.replaceWith('<select id="collectiontitle" name="collectiontitle" class="form-control">' +
'<option value="None">None Specified</option>' +
'<option value="ADULT">Adult</option>' +
'<option value="JUVENILE">Juvenile</option>' +
'<option value="YOUNGADULT">Young Adult</option>' +
'</select>');
});
</script>

In this example, change Collection text input to a dropdown with collection codes as options

Change Default Selected Button from "Yes" to "No"

This is for some of the form fields that provide the "Yes" and "No" radio button options.

Reference: https://pcpls.aspendiscovery.org/MaterialsRequest/NewRequest and ticket #127371

The default selection is the "Yes" button. To change the default to "No":

<script>
var value = 0;
$("input[name=placeHoldWhenAvailable][value=" + value + "]").attr('checked', 'checked');
</script>


The "name" value comes from the "name" of the radio button group when you use the Inspector tool in your browser.

Force alphanumeric entry for a field (no special characters)
<script>
$(document).ready(function () {
$('#isbn.form-control').keyup(function() {
if (this.value.match(/[^a-zA-Z0-9 ]/g)) {
this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
}
});
});
</script>

In this example, they wanted to force users to only input numbers in ISBN field

Hide options in a dropdown
<script>
$("#propertyRowitemtype option[value='BAGCOLLKIT']").css('display', 'none');
$("#propertyRowitemtype option[value='BOOKSTOGO']").css('display', 'none');
$("#propertyRowitemtype option[value='CIRCREF']").css('display', 'none');
$("#propertyRowitemtype option[value='DEVICE']").css('display', 'none');
$("#propertyRowitemtype option[value='EQUIPMENT']").css('display', 'none');
$("#propertyRowitemtype option[value='IMAGE']").css('display', 'none');
$("#propertyRowitemtype option[value='LIT']").css('display', 'none');
$("#propertyRowitemtype option[value='MAPS']").css('display', 'none');
$("#propertyRowitemtype option[value='NEWAUDIO']").css('display', 'none');
$("#propertyRowitemtype option[value='NEWBOOK']").css('display', 'none');
$("#propertyRowitemtype option[value='NEWVIDEO']").css('display', 'none');
$("#propertyRowitemtype option[value='PERIODICAL']").css('display', 'none');
$("#propertyRowitemtype option[value='REF']").css('display', 'none');
$("#propertyRowitemtype option[value='SD BOOK']").css('display', 'none');
$("#propertyRowitemtype option[value='SOUNDREC']").css('display', 'none');
$("#propertyRowitemtype option[value='VHS']").css('display', 'none');
</script>

In this example, they wanted to hide specific item types from their purchase request for one library only

Change input for Publication Date to MM-DD-YYYY
<script>

$("#copyrightdate").attr('maxlength','10');

document.querySelector("label[for='copyrightdate']").innerHTML = "Publication Date (MM-DD-YYYY)";

$('#copyrightdate').on('input', function(){
    var filteredValue = this.value;
    $(this).val(filteredValue
      .replace(/(\d{0,2})\-?(\d{0,2})\-?(\d{0,4}).*/,'$1-$2-$3')
      .replace(/\-+$/, '')
      .replace(/(\d{2})\-?(\d{0,2})\-?(\d{4})/,'$1-$2-$3'))
});

const target = document.querySelector("div.form-group button[value='Submit your suggestion']");

target.addEventListener("click", submitClick, false);

function submitClick(event) {

let copyrightValue = $('#copyrightdate').val();
let noteValue = $('#note').val();

$('#note').val( noteValue + '\n\nPublication Date: ' + copyrightValue);

copyrightValue = copyrightValue.replace(/(\d{0,2})\-?(\d{0,2})\-?(\d{0,4}).*/,'$3')
$('#copyrightdate').val(copyrightValue);

this.form.submit();
}

</script>

In this example, publication date will be copied into notes field and the publication date field on the form will only pass the year value (Koha only accepts 4 digit value)

Repurpose materials request field and validate input on submission
<script> // make the field required to force user to make a choice
$(document).ready(function () {
$('#propertyRowisbn').attr('required', 'required');
}
</script>

<script> // repurpose the label
if ( $('#propertyRowisbn').length ) {
    $('label[for="isbn"]').text('Audience: ')
    $('#isbn').replaceWith(`
      <select id="isbn" name="isbn" class="form-control valid" aria-invalid="false">
                <option value="">-- Choose --</option>
        <option value="Children">Children</option>
                <option value="Teen">Teen</option>
                <option value="Adult">Adult</option>
      </select>
    `);
}

// validate form so -- Choose -- option is not valid

const target = document.querySelector("div.form-group button[value='Submit your suggestion']");

target.addEventListener("click", submitClick, false);

function submitClick(event) {
var select = document.getElementById('isbn');

if (select.value == "") {
event.preventDefault();
    alert("You must choose an audience");
    return false;
  }
}

</script>
Move Notes Field Below 'Reason for Purchase' Field

Reference: Fayetteville, ticket #127492

This snippet moves the Notes field below the "Reason for Purchase" field and adds some padding so there's space between the two.

<script>
$("#propertyRownote").appendTo("#propertyRowpatronreason");
$("#propertyRownote").css("margin-top", "15px");
</script>
Repurpose a field on the materials request form and add a dropdown
<script> // repurpose the place label
if ( $('#propertyRowplace').length ) {
    $('label[for="place"]').text('Interlibrary Loan ok (Yes or No): ')
    $('#place').replaceWith(`
      <select id="place" name="place" class="form-control valid" aria-invalid="false" required="required">
     <option value="" selected="selected"></option>
     <option value="Yes">Yes, try ILL</option>
     <option value="No">No, do not try ILL</option>
      </select>
    `);
}
</script>
Remove Materials Request Notice Related to Limits
/**Hide Materials Request Notice**/
div#materialsRequestSummary {
display: none;
}
Hide or Update the Materials Request or ILL Summary Block

Remove box:

div#materialsRequestSummary {
display: none;
}

Make background clear:

div.materialsRequestExplanation {
background-color: transparent;
}

Remove ILL information (might be used for a self-check or kiosk type set up):

/*Hide ILL Info*/
#illSearchResultsNote {
display: none;
}

/*Hide More ILL Info*/
#illSearchResultsFooter {
display: none;
}

Remove DPLA (might be used for a self-check or kiosk type set up):

/*Hide DPLA*/
#dplaSearchResults {
display: none;
}
Insert a Blank Value into a Dropdown

To insert a blank or none option into a dropdown use the following javascript:

<script>
// Add default blank option to the purchase reason dropdown
$('#patronreasonSelect').prepend('<option value="NONE" selected> </option>');
</script>

Swap out the patronreasonSelect above for the field that you want by inspecting to find the element.

Menus

Sentence case for menu links
/* --------- Use Sentence Case for Menu Links -------- */
#horizontal-menu-bar-container .menu-icon .menu-bar-label {
text-transform: inherit;
}
Hide certain menu links in the account dropdown
/*** Hide Certain Links in Account Dropdown ***/
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ReadingHistory'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/Fines'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/MyRatings'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/SuggestedTitles'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/Lists'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/LibraryCard'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/MyPreferences'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ContactInformation'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetPinPage'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetUsername'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/OverDriveOptions'],
#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/HooplaOptions'],
#account-menu.dropdown-menu.dropdownMenu a[href='/Search/History?require_login'] {
display:none;
}


The Javascript version of this (in case you need to apply to many libraries at once):

<script>
/*** Hide Certain Links in Account Dropdown ***/
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ReadingHistory']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/Fines']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/MyRatings']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/SuggestedTitles']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/Lists']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/LibraryCard']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/MyPreferences']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ContactInformation']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetPinPage']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetUsername']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/OverDriveOptions']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/HooplaOptions']" ).hide();
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/Search/History?require_login']" ).hide();
</script>

Delete/Add lines as needed.

**Don't forget! If it's something in Account Settings, you may also need to hide the links from inside the user account, not just the dropdown menu. That might look something like this:

<script>
/*** Hide Certain Links in Account Dropdown ***/
$( "#account-menu.dropdown-menu.dropdownMenu a[href='/MyAccount/ResetUsername']" ).hide();
$( ".myAccountLink a[href='/MyAccount/ResetUsername']" ).hide();
</script>
Hide menu links based on IP

Use case: hide menu links based on the user's accessing IP address. For example, on the OPACs I want to hide menu links that would take users outside of Aspen.

In "Define your IP Range," you can enter in the first and last ip. If there's only one IP, just enter the same ip in both places.

Then, in "Define parts of the urls that should trigger hiding," enter in the unique parts of the URLs for the menu links. 

<script>
        // Function to convert IP address to a numerical value
        function ipToNum(ip) {
            return ip.split('.').reduce((acc, octet) => (acc << 8) + parseInt(octet, 10), 0) >>> 0;
        }

        // Function to check if IP is within a specific range
        function isInIPRange(ip, start, end) {
            const ipNum = ipToNum(ip);
            return ipNum >= ipToNum(start) && ipNum <= ipToNum(end);
        }

        // Define your IP range
        const startIP = 'XX.XXX.X.XX';
        const endIP = 'XX.XXX.X.XX';

        // Define parts of the URLs that should trigger hiding
        const urlPartsToHide = ['testPoll', 'other-link', 'another-link'];

        // Get user's IP from a third-party service
        fetch('https://ipapi.co/json/')
            .then(response => response.json())
            .then(data => {
                const userIP = data.ip;

                if (isInIPRange(userIP, startIP, endIP)) {
                    // Hide links containing specific URLs
                    document.querySelectorAll('a').forEach(link => {
                        urlPartsToHide.forEach(part => {
                            if (link.href.includes(part)) {
                                link.classList.add('hidden');
                            }
                        });
                    });
                }
            })
            .catch(error => {
                console.error('Error fetching IP address:', error);
            });
    </script>
Rounded corners for menu links
/**** Rounded corners for menu links *****/
#account-menu-dropdown {
border-radius: 10px 10px 0px 0px;
}

#browseLink {
border-radius: 10px 10px 0px 0px;
}

#homeLink {
border-radius: 10px 10px 0px 0px;
}

#header-menu-dropdown {
border-radius: 10px 10px 0px 0px;
}

a.menu-icon.menu-bar-option {
border-radius: 10px 10px 0px 0px;
}
Change color of Administration Options menu panel
/**** Change color of Administration Options menu panel ****/
#account-menu-label.sidebar-label.row {
background-color:#25160A;
}
Rounded corners for facet menus
/**** Rounded top corners for facets****/
#narrow-search-label.sidebar-label {
  border-radius: 15px 15px 0px 0px;
  Padding: 10px 10px;
}
Change onclick function to open window in current location (no new tab)

<script>

document.querySelector('#moreResultsFromIllSystem button').setAttribute("onclick","window.open ('https://hmcpl.org/ill', '_self');");

</script>
Open Library Home link in new tab

<script>
$(document).ready(function(){
   $("#home-page-home-button a").attr("target", "_blank");
});
</script>
Expand Account Settings Menu in My Account Automatically
<script>
//---------- Account Settings panel open by default ----------//
document.getElementById("mySettingsPanel").className = "panel-collapse in";
$("#mySettingsPanel").parent().addClass("active");
</script>
Add a menu link to the Hours & Location Pop-up Modal

Add this text for the URL in the menu link:

/AJAX/JSON?method=getHoursAndLocations" class="modalDialogTrigger menu-icon menu-bar-option

When clicked, this will open the same pop-up modal that clicking the Hours & Location link in the side menu does.

Example: Fallsburg Library (Ramapo)

Placards

Change background color of all placards
/** Change background color of all placards **/

.placard {
background-color: #FFFFFF;
}
Change individual placard backgrounds
/** Change background of specific placard ** /

div#placard1.placard {
background-color: #FFFFFF;
}

You would need the specific id of that placard

Remove Placard Borders
.placard {
  border-width: 0;
}
Add a button to a placard
.myButton {
    background-color:#004d71;
    border-radius:3px;
    border:1px solid #124d77;
    display:inline-block;
    cursor:pointer;
    color:#ffffff;
    font-family:Montserrat;
    font-size:13px;
    padding:6px 24px;
    text-decoration:none;
}
.myButton:hover {
    background-color:#ffffff;
        text-decoration:none;
}
.myButton:active {
    position:relative;
    top:1px;
}

This would go into the specific placard CSS

More Like This Placard

This code was created by MAIN to produce a More Like This placard for popular titles. This example uses the trigger word Fourth Wing.

Create a New Placard, give it a name, assign trigger words.

Add this to the body box <> source code updating the groupedworkID to the title you want more like this recommendations for (i.e. the grouped work ID of Fourth Wing) and replace any header text in the h2 style section:

<div hidden="hidden" id="placardGroupedWork">
ead36282-883a-ac78-2e14-16cc19e295a6-eng
</div>
<div hidden="hidden">
<h2 style="text-align: center;">More Like This Placard Test: Fourth Wing</h2>
<div class="jcarousel-wrapper moreLikeThisWrapper">
<div id="moreLikeThisCarousel" data-jcarousel="true"></div>
<a href="#" class="jcarousel-control-prev" aria-label="Previous Item" data-jcarouselcontrol="true" style="display: flex;">
<i class="fas fa-caret-left"></i></a>
<a href="#" class="jcarousel-control-next" aria-label="Next Item" data-jcarouselcontrol="true" style="display: flex;">
<i class="fas fa-caret-right"></i></a></div>
</div>

Add this to the css box:

a.jcarousel-control-prev, a.jcarousel-control-next {
    background-color: #2454b5 !important;
    color: whitesmoke !important;
    opacity: 80%;
    border-radius: 8px;
    margin-left: -16px;
    margin-right: -16px;
    width: 36px;
}

a.jcarousel-control-prev:hover, a.jcarousel-control-next:hover {
    background-color: #2454b5 !important;
    color: #49deed !important;
    opacity: 88%;
    border: solid 1px #49deed;
}

Add this as a JavaScript Snippet:

<script>
(function(){
var mltc = document.querySelector(".placard #moreLikeThisCarousel");
if (location.pathname == '/Union/Search' &&  mltc !== null) {
    var gwId = document.getElementById('placardGroupedWork').innerText;
    AspenDiscovery.GroupedWork.loadMoreLikeThis(gwId, true);
    var i = 0;
    var mltCheck = setInterval(function() { 
        if (mltc.innerHTML == "") {
            if (i == 8) {
                document.querySelector("section.placard").remove();
                clearInterval(mltCheck);
            }
            i++;
        } else {
            mltc.classList.add("jcarousel","horizontalCarouselSpotlight");
            AspenDiscovery.initCarousels();
            mltc.parentElement.parentElement.hidden = false;
            clearInterval(mltCheck);
        }
    }, 500);
}
})();
</script>

Search

Hide elements in search source menu
/** HIDE ELEMENTS IN SEARCH SOURCE MENU **/
#searchSource option[data-catalog_type='ebsco_eds'] {
display:none;
}
Change Cursor to Arrow in Predictive Search
.ui-autocomplete .ui-menu-item > a.ui-corner-all:hover { cursor: default }

Rounded corners for search box
/**** Rounded corners for search box ****/
#horizontal-search-box.row {
  border-radius: 25px;
  Padding: 15px 15px;
}
Hide Description Under Grouped Work Display
/* Removes the title descriptions from search results page */
[id^="descriptionValue"]{
display: none !important;
}
Add an Advanced Search Link under the Search Bar

Update with your library's URL:

<script>
$('div#horizontal-search-box').append('<div><a id="advancedSearch" href="https://{YOURLIBRARY}.aspendiscovery.org/Union/Search?view=list&showCovers=on&lookfor=&searchIndex=advanced&searchSource=local">Advanced Search</a></div>');
</script>

If the search bar is a darker color, add this to the CSS in the theme also:

#advancedSearch {
  color: white;
  margin-left: 35px;
}
Hide In Lists Dropdown

If you are not using Lists... you can hide the In Lists dropdown

/** Hide Lists search **/
#searchSource option[value="lists"] {
     display: none;
}
Hide magnifying glass next to search bar and resize to fill bar
//** HIDE MAGNIFYING GLASS NEXT TO SEARCH BAR AND RESIZE TO FILL BAR **//
#lookfor-label .fa-search {display:none;}

#searchForm #lookfor {width:97%;}
Hide Sort by Holds in Search Dropdown
/*Hide Sort by Holds in Dropdown*/
select#results-sort.input-medium option[value*="&sort=total_holds+desc"] {
display: none;
}
Hide Sort by Rating in search when library isn't using ratings
/*Hide Sort by Rating in Dropdown*/
select#results-sort.input-medium option[value*="&sort=rating+desc"] {
display: none;
}

or 

//** HIDE SORT BY RATING in SEARCH WHEN LIBRARY ISN’T USING RATINGS **//

select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=Keyword&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=Title&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=StartOfTitle&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=Series&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=Author&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=Subject&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
select#results-sort.input-medium option[value='/Search/Results?lookfor=&searchIndex=LocalCallNumber&sort=rating+desc&view=list&searchSource=local'] {
display: none;
}
Modify/Center Text For Format Icons at Top of Search
/*** Format Icon Images ***/ 
div#formatCategories.top-facet.formatCategories.top-facet {
margin-left: 5px;
padding-bottom:0px;
padding-top: 0px;
}
div#categoryValues.row {
color: #08aee5;
}
div.col-xs-6.formatCategoryLabel {
float: unset;
text-align: center;
}

/***Compatibility on all devices***/

/*** Facets Container (left-side menu) ***/
h3#narrow-search-label.sidebar-label {
background-image: linear-gradient(to bottom, rgba(035,030,090), rgba(000,175,230));
line-height:30px;
font-size:16px;
}
div#side-bar.col-tn-12.col-xs-12.col-sm-4.col-md-3.col-lg-3 {
position: relative;
min-height: 1px;
padding-left: 30px;
padding-right: 25px;
width: 240px;
}
div.facetTitle.panel-title.collapsed {
border-bottom-color: #ffffff;
border-bottom-width: 4px;
border-left: solid 1px;
border-left-color: #bebebe;
color: linear-gradient(to bottom, rgba(211,238,251), rgba(255,255,255));
}
Change text color of search dropdowns
/*** change text color of search dropdowns ***/
.form-control {
color: #000000;
}
Hide by Total Checkouts in Search Dropdown
/*Hide Sort by Total Checkouts Dropdown*/
select#results-sort.input-medium option[value*="&sort=popularity+desc"] {
display: none;
}
Select a different search option as the default
<script>
function setSelectedIndex(s, i)
{
s.options[i-1].selected = true;
return;
}

setSelectedIndex(document.getElementById("searchSource"),3);

</script>

Example, change the default search from in Library Catalog to in Library Website.

**where the number 3 is the position of the item in the dropdown menu you want to become the default

Remove the "Remember This" checkbox in the Select Catalog Search Interface
// ** REMOVE THE CHECKBOX IN SELECT INTERFACE **//

#rememberThis { display:none }
label[for="rememberThis"] {
display:none;
}
Hide Explore More
.exploreMoreBar {
  display: none;
}

Self Registration

Remove the background from the Self Registration form summary
//** REMOVE THE BACKGROUND FROM THE SELF REGISTRATION FORM **//

#selfRegDescription {
background-color: transparent;
}
Remove the Self Registration link from the login box when Self Registration is enabled
//** REMOVE THE SELF REGISTRATION LINK FROM THE LOGIN BOX WHEN SELF REGISTRATION IS ENABLED **//
#loginForm #loginPasswordRow .help-block {
  display: none;
}
Hide username on Self Registration form
<script>
$( "p#selfRegUsername" ).hide();
</script>
Hide password from displaying on self registration confirmation page
<script>
$( "p#selfRegPassword" ).hide();
</script>
Hide username and account registration disclaimer / "barcode not provided" message

To hide this whole box (everything outlined in red):

Use this:

div#selfRegAccountInfo {
    display: none;
}
Hide Pronouns (additional patron attribute) on Self Registration form
<script>
$( "div#accordion_Additional_Information" ).hide();
</script>
Change a text input field into a dropdown menu
<script>
$(document).ready(function () {
$("#borrower_othernames")
.replaceWith('<select id="borrower_othernames" name="borrower_othernames" class="form-control">' +
'<option value="None">None Specified</option>' +
'<option value="She/Her">She/Her</option>' +
'<option value="Him/His">Him/His</option>' +
'<option value="They/Them">They/Them</option>' +
'</select>');
});
</script>
Change a dropdown menu into a text field
<script>
$(document).ready(function () {
$("#borrower_attribute_PrivExcepSelect").replaceWith('<input/>',{'type':'text', ‘id’:borrower});
});
</script>
Add a Blank Value to the Dropdown Menu

To add a blank value to the dropdown use this code by substituting out the borrower_attribute value.

This is example is for signing up for a newsletter Yes, No and adding a blank as the default option.

<script>
$('#borrower_attribute_NEWSSelect').prepend('<option value="NONE" selected> </option>');
function submitClick(event) {
var select = document.getElementById('borrower_attribute_NEWSSelect');
}
</script>

To do this with a required field, use this code by substituting out the borrower_attribute value.

<script>
// Add default blank option to printed voter registration dropdown
$('#borrower_attribute_VOTESelect').prepend('<option value="NONE" selected> </option>');

// validate form so default blank option is not valid
const target = document.querySelector("div.form-group button[value='Register']");

target.addEventListener("click", submitClick, false);

function submitClick(event) {
var select = document.getElementById('borrower_attribute_VOTESelect');

if (select.value == "NONE") {
event.preventDefault();
    alert("You must inform the library of your printed voter registration preference.");
    return false;
  }
}
</script>
Add "Choose Location" as default value and force selection

Sample: El Dorado County

<script>
// Check if URL is the self reg form
document.addEventListener('DOMContentLoaded', function() {
    if (window.location.pathname.includes('/MyAccount/SelfReg')) {

// Add default option to Home Library selection dropdown
$('#borrower_branchcodeSelect').prepend('<option value="NONE" selected>Choose a Location</option>');

// validate form so default blank option is not valid
const target = document.querySelector("div.form-group button[value='Register']");

target.addEventListener("click", submitClick, false);

function submitClick(event) {
var select = document.getElementById('borrower_branchcodeSelect');

if (select.value == "NONE") {
event.preventDefault();
    alert("You must select a home library location.");
    return false;
  }
}
}});
</script>
Hide Library selection field on Self Registration form
<script>
$( "div#propertyRowlibrarySection.form-group" ).hide();
</script>
Hide Library title/salutation (ms, miss, dr, mrs) field on Self Registration form
<script>
$( "div#propertyRowborrower_title.form-group" ).hide();
</script>
Validate specific phone format +1 xxx-xxx-xxxx
<script>
$('#borrower_phone.form-control.required').on('input', function(){
    var filteredValue = this.value.replace('+1 ', '').match(/\d*/g).join('');
    $(this).val(filteredValue
      .replace(/(\d{0,3})\-?(\d{0,3})\-?(\d{0,4}).*/,'$1-$2-$3')
      .replace(/\-+$/, '')
      .replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'+1 $1-$2-$3'))
});
</script>

<script>
$('#SMSnumber.form-control').on('input', function(){
    var filteredValue = this.value.replace('+1 ', '').match(/\d*/g).join('');
    $(this).val(filteredValue
      .replace(/(\d{0,3})\-?(\d{0,3})\-?(\d{0,4}).*/,'$1-$2-$3')
      .replace(/\-+$/, '')
      .replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'+1 $1-$2-$3'))
});
</script>

+1 will be prepended to the phone number and dashes will be added as well. Users will not be able to enter their own special characters.

Validate specific phone format xxx-xxx-xxxx
<script>
$('#borrower_phone.form-control.required').on('input', function(){
    var filteredValue = this.value.replace('').match(/\d*/g).join('');
    $(this).val(filteredValue
      .replace(/(\d{0,3})\-?(\d{0,3})\-?(\d{0,4}).*/,'$1-$2-$3')
      .replace(/\-+$/, '')
      .replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'$1-$2-$3'))
});
</script>

Dashes will be added and users will not be able to enter their own special characters.

Validate specific phone format 1xxxxxxxxxx
<script>
$('#SMSnumber.form-control').on('input', function(){
    var filteredValue = this.value.replace('1', '').match(/\d*/g).join('');
    $(this).val(filteredValue
      .replace(/(\d{0,10}).*/,'$1')
      .replace(/\-+$/, '')
      .replace(/(\d{10})/,'1$1'))
});
</script>

1 will be prepended to the phone number and only numeric characters will be allowed. Users will not be able to enter their own special characters.

Validate specific phone number format XXXXXXXXXX
<script>
$('#phone.form-control').on('input', function(){
    var filteredValue = this.value.match(/\d*/g).join('');
    $(this).val(filteredValue
      .replace(/(\d{0,10}).*/,'$1')
      .replace(/\-+$/, '')
      .replace(/(\d{10})/,'$1'))
});
</script>

Users will only be able to enter numeric characters and no special characters, limited to 10 characters.

**If the above doesn't work, replace #phone.form-control with #borrower_phone.form-control

Add a user agreement checkbox/text to the registration form
<script type="text/javascript">
//-----------Create new div to put checkbox and text in-----------//
var div = document.createElement('div');

//-----------Create checkbox and set attributes-----------//
var x = document.createElement('INPUT');
x.setAttribute("type", "checkbox");
x.setAttribute("id", "PolicyCheck");

//-----------Create hyperlink text and set attributes-----------//
var label = document.createElement('label');
label.htmlFor = "PolicyCheck";
label.innerHTML = ' &nbsp <font color="#FF0000">Check here to indicate that you have read and agree to the </font> <a href="https://www.pueblolibrary.org/030201Library%20Accounts" target = "_blank" title="Privacy Policy">PCCLD Library Accounts Policy</a>.&nbsp <span class="label label-danger" style="margin-right: .5em">Required</span>';

//-----------Set target as Register button-----------//
const target = document.querySelector("div.form-group button[value='Register']");

//-----------Insert checkbox above Register button (target)-----------//
    //start by inserting a div so the checkbox is on a line above the button
target.parentNode.insertBefore(div, target); 

    //add checkbox
target.parentNode.insertBefore(x, div); 

    //add label (text and hyperlink)
target.parentNode.insertBefore(label, div);

//-----------Verify  checkbox is checked before allowing form submission-----------//
   //page loaded with disabled submit button
target.disabled = true;

   //toggle submit button enabled/disabled with checkbox
x.onclick = function() {
      if (x.checked) {
           target.disabled = false;}
      else {
          target.disabled = true;}
}
</script>

This will add a checkbox above the “Register”/”Submit” button on the self registration form. To customize the link/words edit the label.innerHTML line.

Force first letter of every word to be capitalized aka force case

<script>
if ( $('#MyAccount-SelfReg').length ) {
    $('#borrower_surname, #borrower_firstname, #borrower_middle_name, #borrower_othernames, #borrower_address, #borrower_city').blur( function() {
        let this_value = $(this).val();
        this_value = this_value.toLowerCase()
        .split(' ')
        .map((s) => s.charAt(0).toUpperCase() + s.substring(1))
        .join(' ');
        $(this).val(this_value);
    });
    $('#borrower_email, #borrower_repeat_email').blur( function() {
        let this_value = $(this).val().toLowerCase();
        $(this).val(this_value);
    });
}
</script>
Remove Register for a Library Card Header From Form
<script>
$("h1:contains('Register for a Library Card')").hide();
</script>

System Messages

Remove background color from System Message
/* ----------- REMOVE BACKGROUND COLOR FROM SYSTEM MESSAGE ------------- */
#system-message-header {
background-color: transparent;
}
Move system message underneath the search box row
<script>
$("#system-message-header").appendTo("#horizontal-search-container");
</script>
Add a message to the Koha OPAC

Add a message in the Koha header when a library is launching their new Aspen catalog.

Put this in the Koha OPACUserJS and change out the text and the URL. 

$('#header-region').prepend('<div class="alert alert-warning">We are launching a new catalog! Get a sneak peek of our <a href="https://aspendiscovery.org/">New Catalog</a>.</div>'); 

Theme & Layout

Align header logo image to the right or center of the page
//** ALIGN HEADER LOGO IMAGE TO THE RIGHT OF PAGE **//

#header-logo {
horizontal-align: right;
}

//** ALIGN HEADER LOGO IMAGE TO THE CENTER OF PAGE **//

#header-logo-container { 
width: 100%; 
text-align: center 
}
Remove or Add Header Image Padding
/**** Remove Logo Image Padding ****/
div#header-logo-container {
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}

/****Add Header Image Padding****/

div#header-logo-container {
padding-top: 50px;
}
Remove breadcrumb links
/**** Remove Breadcrumbs ****/
.breadcrumb.small {
display: none;
}
.row.breadcrumbs {
display: none;
}

If you want to remove from a specific page, you can reference that with “body#WebBuilder-PortalPage-11” -or whatever the specific page ID is - example:

/**** Remove Breadcrumbs ****/
body#WebBuilder-PortalPage-2
.breadcrumb.small {
display: none;
}
.row.breadcrumbs {
display: none;
}
Change Narrow Your Results Box and Text

Narrow Your Results pulls from the Primary Theme colors but if you want to seperate this out from the Primary Theme color and change it to it's own color, then update with colors or hex codes with this snippet:

#narrow-search-label {
    background: blue;
    color: yellow;
}
Remove Book icon
/**** Remove Browse (Book) Icon from Menu ****/
a#browseLink.menu-icon.menu-bar-option {
display: none;
}
Move the Top of Page button above the chat widget
/*move top of page button above Webchat widget*/
.top-link {
position: fixed;
bottom: 50px; }
Hide the Home icon
/**** Don't display home (house) icon ****/
a#homeLink.menu-icon.menu-bar-option {
display:none!important;
}

If that doesn't work, try:

/**** Don't display home button ****/
a#browseLink {
display:none!important;
}
Rainbow Header
/*rainbow header!*/
div#horizontal-search-box.row{
background: linear-gradient(90deg, rgba(0,185,202,1) 0%, rgba(112,201,159,1) 50%, rgba(231,230,27,1) 100%);
}

div#header-wrapper.row{
background: linear-gradient(90deg, rgba(0,185,202,1) 0%, rgba(112,201,159,1) 50%, rgba(231,230,27,1) 100%);
}
Gradient background for interface elements

Generate CSS here: https://cssgradient.io/

div#header-wrapper.row{
background: linear-gradient(90deg, rgba(0,185,202,1) 0%, rgba(112,201,159,1) 50%, rgba(231,230,27,1) 100%);
}
Add repeating background image
/*Add repeating background image*/
body {
background: url(INSERT YOUR IMAGE URL HERE);
}
When using Full Header and Footer width, don't shift all elements
#horizontal-search-container:before {
  content:""; 
 background: transparent linear-gradient(270deg, #6c97b0 0%, #6c97b0 100%) 0% 0% no-repeat padding-box;
  width: 200vw;
  position: absolute;
  margin-left: -50vw;
  height: 100%;
  z-index: -1;
  overflow-x: hidden;
}

div#page-header.container-fluid {
width: 80%;
margin: auto;
}

div#page-menu-bar.container-fluid {
width: 80%;
margin: auto;
}

div#horizontal-menu-bar-container {
border-bottom-width: 0px;
}

Remove color of striped tables
table-striped > tbody > tr:nth-child(2n+1) > td, .table-striped > tbody > tr:nth-child(2n+1) > th {
   background-color:transparent !important;
}
Hide mini format icons from Recommendation System modals
/* Hide mini format icons from Recommendation System modals */
.formatIcons { display: none; }
Move footer down so it can expand up to full width
<script>
$("#footer-custom-text").appendTo(".navbar-inner");
</script>

This is the footer text/images that are entered in Library System settings > Basic Display

Example: https://discovery.fultoncountylibrary.org/

Hide Footer
/* hide footer area */
#page-footer { display: none; 
} 
Open the Header Logo in New Tab
<script>

$(document).ready(function(){
  $('#header-logo-container a').attr('target', '_blank');
});

</script>
Change the Color of Masquerade Mode
/* Masquerade Mode Red Mask */
.fas.fa-theater-masks.fa-lg {
  color: red;
}
Disable Title Links

Code like this might be used for a Self-Checkout or Kiosk Mode set up

.result-title.notranslate { /* disable title links */
  pointer-events: none;
  cursor: default;
  text-decoration: none; 
  color: #44484a;
  } 
Disable Author Links

Code like this might be used for a Self-Checkout or Kiosk Mode set up

.result-value { /* disable author links */
  pointer-events: none;
  cursor: default;
  text-decoration: none; 
  color: #44484a !important;
  } 

Web Builder

Remove search bar from a specific web builder page
/**** Remove Search Bar from Welcome Page ****/
body#WebBuilder-PortalPage-11 #horizontal-search-container {
    display: none;
}
Apply CSS to specific web builder pages

Add this to JavaScript Snippets:

<script type="text/javascript">
// Get url suffix and make it an html ID on custom pages
var custom_page = $("body").attr('id');
if (custom_page = "WebBuilder-PortalPage") {
var get_url_suffix = window.location.pathname;
var create_html_id = get_url_suffix.replace("/", "customPageId-");
$("#main-content").attr('id', create_html_id);
}
</script>

It applies only to custom pages. It takes the URL suffix (in my case /home) and makes that a unique HTML ID. It overwrites the ID of #main-content with the new ID.

Then in CSS apply the background color to this specific custom page:

#customPageId-home {background-color: #dedede;}
Select library location from a dropdown list in a web builder page

Select library location from dropdown list on web builder page

For Franklin County’s web builder pages, ex: https://discovery.fclspa.org/coyle

<script>
var h2 = document.querySelector('div[role="main"] h2');
h2 = h2.innerText;

var select = document.getElementById("selectLibrary");
for(var i = 0;i < select.options.length;i++){
    if(select.options[i].label == h2 ){
        select.options[i].selected = true;
        AspenDiscovery.showLocationHoursAndMap();
    } 
}
</script>
Insert a div on the Web Resources page only

Ex: https://discovery.fclspa.org/WebBuilder/ResourcesList

<script>
if (window.location.href.indexOf("ResourcesList") != -1) {
var block_to_insert ;
var container_block ;

block_to_insert = document.createElement( 'div' );
block_to_insert.id = 'power_eresource_footer' ;
block_to_insert.innerHTML = 'text goes here. Can also use html for formatting' ;

container_block = document.getElementById( 'main-content');
container_block.appendChild( block_to_insert );
}
</script>

Note: you need to add CSS to the theme setting if you want to style the div. In this case I used this so it wouldn’t fill the entire width of the page:

div#power_eresource_footer {
width: 80%;
margin: auto;
}
Automatically open menus in Custom Pages

Where it says ‘/music’, insert the page path - this snippet will automatically open all menus on the page

<script>
jQuery(document).ready(function() {
      if (window.location.pathname == '/music') {
$('.customAccordionRow').addClass('active');
$('.panel-collapse').addClass('in');
}
});
</script>

Where it says the #Cell-#, insert the specific panels you want - this snippet will automaticaly open those menus on the page

<script>
jQuery(document).ready(function() {
$('#Cell-59-Panel, #Cell-61-Panel, #Cell-62-Panel').addClass("active");
$('#Cell-59-PanelBody, #Cell-61-PanelBody, #Cell-62-PanelBody').addClass("in");
});
</script>
Automatically open menus in web resources

Use the section color in closed panel background color

<script>
jQuery(document).ready(function() {
      if (window.location.pathname == '/WebBuilder/ResourcesList') {
$('.customAccordionRow').addClass('active');
$('.panel-collapse').addClass('in');
}
});
</script>

Use the section color in open panel background color

<script>
jQuery(document).ready(function() {
      if (window.location.pathname == '/WebBuilder/ResourcesList') {
$('.panel').addClass('active');
$('.customAccordionRow').addClass('active');
$('.panel-collapse').addClass('in');
}
});
</script>
Increase Size of Accordion Panels on Web Builder Pages
/*** Adjust font size of accordion panel titles ***/
.module_WebBuilder .panel-title {
    font-size: 1.2em;
}

Other

Hide Email Field on Pin/Password Reset Form
/*Hide Email field on Reset Pin Form*/
#emailResetPin div.form-group:nth-child(2) {
    display:none;
}
Hide the Load Default Bib Format Mappings Button in the ILS Indexing Settings
a[href*="?objectAction=loadDefaultBibFormatMappings"] { display: none; }
Show User Account Expiration Notice on Smaller Screens/Mobile Devices
@media (max-width: 767px) {
   body.module_MyAccount #side-bar {
       display: block !important;
   }
   body.module_MyAccount #side-bar .panel.active {
       border: 0px;
   }

   body.module_MyAccount #side-bar .panel-body {
       margin-bottom: -4px;
       padding-bottom: 0px;
   }   

   body.module_MyAccount #side-bar a[aria-label="Your Account Menu"],
   body.module_MyAccount #side-bar a[aria-label="Account Settings Menu"],
}