Widget:BcaSearch: Difference between revisions
(Run a search given in the address on arrival) |
(Search: whole-row links, filter the results, start panel styles, title weight 500) |
||
| Line 19: | Line 19: | ||
.bcas__hit{padding:.85rem 1.15rem;border-top:1px solid rgba(177,175,169,.35)} | .bcas__hit{padding:.85rem 1.15rem;border-top:1px solid rgba(177,175,169,.35)} | ||
.bcas__hit:first-child{border-top:0} | .bcas__hit:first-child{border-top:0} | ||
.bcas__hit-title{font-size:1. | .bcas__hit-title{font-size:1.3rem;font-weight:500;font-family:'Cormorant Garamond',serif} | ||
.bcas__hit-meta{font-size:.82rem;color:#666;margin-top:.15rem} | .bcas__hit-meta{font-size:.82rem;color:#666;margin-top:.15rem} | ||
.bcas__hit-meta > span + span::before{content:'·';margin:0 .4rem;opacity:.45} | .bcas__hit-meta > span + span::before{content:'·';margin:0 .4rem;opacity:.45} | ||
| Line 25: | Line 25: | ||
.bcas__pills{margin:.2rem 0 .8rem} | .bcas__pills{margin:.2rem 0 .8rem} | ||
.bcas__empty{padding:1.2rem;color:#666} | .bcas__empty{padding:1.2rem;color:#666} | ||
/* Start panel (in the page below the widget) */ | |||
.bcas-start{max-width:1100px;margin:1.5rem auto 3rem} | |||
.bcas-start__grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(320px,100%),1fr));gap:1.2rem} | |||
.bcas-start__card{background:#fffcf5;border-radius:8px;border-top:2px solid #BA1B1D;padding:1rem 1.2rem 1.1rem;box-shadow:0 1px 2px rgba(0,0,0,.06),0 6px 16px rgba(60,40,10,.08)} | |||
.bcas-start__h{font-family:'Cormorant Garamond',serif;font-size:1.45rem;font-weight:500;margin:0 0 .6rem} | |||
.bcas-start__links a{display:block;padding:.45rem .6rem;margin:0 -.6rem;border-radius:6px;color:#113651;text-decoration:none} | |||
.bcas-start__links a:hover{background:rgba(191,150,89,.1)} | |||
.bcas-start__links b{font-weight:600;display:block} | |||
.bcas-start__links span{font-size:.85rem;color:#666} | |||
.bcas-start__chips{display:flex;flex-wrap:wrap;gap:.4rem} | |||
.bcas-start__chips a{display:inline-flex;align-items:center;gap:.4rem;padding:.3rem .8rem;border:1px solid #d6d0c2;border-radius:999px;background:#fff;color:#113651;font-size:.9rem;text-decoration:none} | |||
.bcas-start__chips a:hover{border-color:#bf9659;background:rgba(191,150,89,.08)} | |||
.bcas-start__chips a span{color:#888;font-size:.8rem} | |||
.bcas-start__chips--small{margin-top:.6rem} | |||
.bcas-start__chips--small a{padding:.15rem .6rem;font-size:.82rem} | |||
.bcas-start__more{margin-top:.7rem;font-size:.85rem;color:#666} | |||
/* Whole row is the link: hover tint and a gold edge, as on PLL's lists */ | |||
.bcas__list .topic-biblio-row,.bcas__hit{cursor:pointer;position:relative;transition:background-color .15s ease,box-shadow .15s ease} | |||
.bcas__list .topic-biblio-row:hover,.bcas__hit:hover{background:rgba(191,150,89,.09);box-shadow:inset 3px 0 0 #bf9659} | |||
.bcas__list .topic-biblio-row:focus-within,.bcas__hit:focus-within{box-shadow:inset 3px 0 0 #bf9659} | |||
.bcas__refine{display:flex;align-items:center;gap:.8rem;margin:.2rem 0 .6rem} | |||
.bcas__refine input{flex:0 1 22rem;padding:.45rem 1rem;border:1px solid #d6d0c2;border-radius:2em;background:#fffcf5;font-size:.92rem} | |||
.bcas__refine input:focus{outline:none;border-color:#bf9659;box-shadow:0 0 0 3px rgba(191,150,89,.22)} | |||
.bcas__refine .bcas__status{margin:0} | |||
</style> | </style> | ||
<div class="bcas noglossary" id="bcas"> | <div class="bcas noglossary" id="bcas"> | ||
| Line 35: | Line 59: | ||
<div class="bcas__tabs" id="bcas-tabs" role="tablist" hidden></div> | <div class="bcas__tabs" id="bcas-tabs" role="tablist" hidden></div> | ||
<div class="bcas__pills topic-biblio-pills" id="bcas-pills" hidden></div> | <div class="bcas__pills topic-biblio-pills" id="bcas-pills" hidden></div> | ||
<div class="bcas__status" id="bcas-status" aria-live="polite"></div> | <div class="bcas__refine" id="bcas-refine" hidden><input id="bcas-filter" type="search" placeholder="Filter these results…" aria-label="Filter the results shown"><div class="bcas__status" id="bcas-status" aria-live="polite"></div></div> | ||
<div class="bcas__list" id="bcas-list"></div> | <div class="bcas__list" id="bcas-list"></div> | ||
<button class="bcas__more" id="bcas-more" type="button" hidden>Show more results</button> | <button class="bcas__more" id="bcas-more" type="button" hidden>Show more results</button> | ||
| Line 200: | Line 224: | ||
$('#bcas-list').append(html); | $('#bcas-list').append(html); | ||
state.offset += PAGE; | state.offset += PAGE; | ||
window.setTimeout(refine, 0); | |||
var shown = Math.min(state.offset, total); | var shown = Math.min(state.offset, total); | ||
$('#bcas-status').text('Showing ' + fmt(shown) + ' of ' + fmt(total) + ' in ' + g.label.toLowerCase() + (state.cls ? ' · ' + state.cls : '') + '.'); | $('#bcas-status').text('Showing ' + fmt(shown) + ' of ' + fmt(total) + ' in ' + g.label.toLowerCase() + (state.cls ? ' · ' + state.cls : '') + '.'); | ||
| Line 208: | Line 233: | ||
$('#bcas-status').text('The search could not run just now. Please try again in a moment.'); | $('#bcas-status').text('The search could not run just now. Please try again in a moment.'); | ||
}); | }); | ||
} | |||
// Narrow the rows already shown, without a new search (accents ignored). | |||
function fold(s) { return String(s).normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase(); } | |||
function refine() { | |||
var v = fold($('#bcas-filter').val().trim()), shown = 0, all = 0; | |||
$('#bcas-list').children('.topic-biblio-row, .bcas__hit').each(function () { | |||
var ok = !v || fold($(this).text()).indexOf(v) > -1; | |||
$(this).toggle(ok); all++; if (ok) shown++; | |||
}); | |||
$('#bcas-filtered').remove(); | |||
if (v) $('#bcas-status').append('<span id="bcas-filtered"> ' + fmt(shown) + ' of the ' + fmt(all) + ' shown match the filter.</span>'); | |||
} | } | ||
| Line 214: | Line 251: | ||
writeUrl(); | writeUrl(); | ||
shortcut(); | shortcut(); | ||
if (!state.q) { $('#bcas-tabs,#bcas-pills,#bcas-more').prop('hidden', true); $('#bcas-list,#bcas-status').empty(); $('#bcas-hint').show(); return; } | if (!state.q) { $('#bcas-tabs,#bcas-pills,#bcas-more,#bcas-refine').prop('hidden', true); $('#bcas-list,#bcas-status').empty(); $('#bcas-hint, #bcas-start').show(); return; } | ||
$('#bcas-hint').hide(); | $('#bcas-hint, #bcas-start').hide(); | ||
$('#bcas-refine').prop('hidden', false); $('#bcas-filter').val(''); | |||
counts = {}; | counts = {}; | ||
renderTabs(); | renderTabs(); | ||
| Line 244: | Line 282: | ||
$('#bcas-pills').on('click', '.topic-biblio-pill', function () { state.cls = $(this).attr('data-cls') || ''; $('#bcas-pills .topic-biblio-pill').removeClass('is-active'); $(this).addClass('is-active'); writeUrl(); loadList(false); }); | $('#bcas-pills').on('click', '.topic-biblio-pill', function () { state.cls = $(this).attr('data-cls') || ''; $('#bcas-pills .topic-biblio-pill').removeClass('is-active'); $(this).addClass('is-active'); writeUrl(); loadList(false); }); | ||
$('#bcas-more').on('click', function () { loadList(true); }); | $('#bcas-more').on('click', function () { loadList(true); }); | ||
if ($('#bcas-q').val()) run(); else $('#bcas-q').trigger('focus'); | $('#bcas-filter').on('input', refine); | ||
// Whole row opens its first link, unless a link inside it was clicked or text selected. | |||
$('#bcas-list').on('click', '.topic-biblio-row, .bcas__hit', function (e) { | |||
if ($(e.target).closest('a').length || String(window.getSelection())) return; | |||
var a = $(this).find('a').get(0); if (!a) return; | |||
if (e.metaKey || e.ctrlKey) window.open(a.href, '_blank'); else location.href = a.href; | |||
}); | |||
// The start panel (in the page) can launch searches too. | |||
$(document).on('click', '#bcas-start [data-q]', function (e) { e.preventDefault(); $('#bcas-q').val($(this).attr('data-q')); state.cls = $(this).attr('data-class') || ''; state.tab = $(this).attr('data-tab') || 'library'; run(); window.scrollTo({ top: $('#bcas').offset().top - 90, behavior: 'smooth' }); }); | |||
if ($('#bcas-q').val()) run(); else { $('#bcas-start').show(); $('#bcas-q').trigger('focus'); } | |||
}); | }); | ||
}]); | }]); | ||
</script></includeonly> | </script></includeonly> | ||
Revision as of 19:20, 2 October 2026
Site search for the Bodhicitta wiki (preview). Used on Advanced Search/Preview. Full-text search through CirrusSearch, results grouped (library, passages in the aligned texts, essays, topics, people), class filters with counts, the library's bibliographic rows, and the search kept in the page address so it can be shared.