Use 245$a for title, and use Title Case
authorJeff Godin <jgodin@tadl.org>
Mon, 23 Apr 2012 09:50:11 +0000 (05:50 -0400)
committerJeff Godin <jgodin@tadl.org>
Mon, 23 Apr 2012 09:50:11 +0000 (05:50 -0400)
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 <jgodin@tadl.org>
Open-ILS/web/opac/skin/tadlv4/js/grpl_utils.js
Open-ILS/web/opac/skin/tadlv4/js/result_common.js
Open-ILS/web/opac/skin/tadlv4/xml/page_rresult.xml
Open-ILS/web/opac/skin/tadlv4/xml/rdetail/rdetail_summary.xml

index 70dad80..03af07d 100644 (file)
@@ -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);
+  });
+};
index 39177b5..35686a7 100644 (file)
@@ -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;
index 9c1812a..2fb2d79 100644 (file)
@@ -4,6 +4,7 @@
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/tadlv4/js/result_common.js'></script>
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/tips.js'></script>
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/holds.js'></script>   
+       <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/tadlv4/js/grpl_utils.js'></script>
        <!--#include virtual="result/result_common.xml"-->
 </div>
 
index f07ef47..222cda5 100644 (file)
                         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;
                     ]]></script>