From a3e46cb6e6de63bbde839fb7f5008c0a4aca2d30 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Mon, 23 Apr 2012 05:50:11 -0400 Subject: [PATCH] Use 245$a for title, and use Title Case Shift to using 245$a for title in record detail summary. Use Title Case for both search results and record detail. Signed-off-by: Jeff Godin --- Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js | 23 ++++++++++++++++++++++ Open-ILS/web/opac/skin/tadlv4/js/result_common.js | 1 + Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml | 1 + .../skin/tadlv4/xml/rdetail/rdetail_summary.xml | 7 ++++++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js b/Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js index 70dad80047..03af07d6d2 100644 --- a/Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js +++ b/Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js @@ -22,3 +22,26 @@ function getHoldCount(id){ return holdCount.responseText; } + +/* + * To Title Case 2.0.1 – http://individed.com/code/to-title-case/ + * Copyright © 2008–2012 David Gouch. Licensed under the MIT License. + */ + +String.prototype.toTitleCase = function () { + var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|vs?\.?|via)$/i; + + return this.replace(/([^\W_]+[^\s-]*) */g, function (match, p1, index, title) { + if (index > 0 && index + p1.length !== title.length && + p1.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && + title.charAt(index - 1).search(/[^\s-]/) < 0) { + return match.toLowerCase(); + } + + if (p1.substr(1).search(/[A-Z]|\../) > -1) { + return match; + } + + return match.charAt(0).toUpperCase() + match.substr(1); + }); +}; diff --git a/Open-ILS/web/opac/skin/tadlv4/js/result_common.js b/Open-ILS/web/opac/skin/tadlv4/js/result_common.js index 39177b53dd..35686a76fe 100644 --- a/Open-ILS/web/opac/skin/tadlv4/js/result_common.js +++ b/Open-ILS/web/opac/skin/tadlv4/js/result_common.js @@ -550,6 +550,7 @@ function resultDisplayRecord(rec, pos, is_mr) { buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id()); buildTitleDetailLink(rec, title_link); + title_link.innerHTML = title_link.innerHTML.replace(/^\s+/, '').toTitleCase(); var args = {}; args.page = RDETAIL; args[PARAM_OFFSET] = 0; diff --git a/Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml b/Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml index 9c1812ac54..2fb2d79632 100644 --- a/Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml +++ b/Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml @@ -4,6 +4,7 @@ + diff --git a/Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml b/Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml index f07ef475f8..222cda5a1c 100644 --- a/Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml +++ b/Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml @@ -31,8 +31,13 @@ var out = ''; var list = dojo.query( 'subfield', item ); for (var i = 0; i < list.length; i++) { - out += BT.textContent(list[i]) + ' '; + var sub_code = list[i].getAttribute('code'); + if (sub_code.match(/a/i)) { + out += BT.textContent(list[i]) + ' '; + } } + out = out.replace(/\s*\/\s*/, ''); + out = out.toTitleCase(); document.title += ': ' + out; return out; ]]> -- 2.11.0