From: dbs Date: Fri, 27 Aug 2010 14:10:27 +0000 (+0000) Subject: Split spine labels between the alpha and numeric part of the LC subclass X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=983db89874b51e0daaab5c5fe8486ba54ecbf7a5;p=evergreen%2Fbjwebb.git Split spine labels between the alpha and numeric part of the LC subclass Some sites jam the alpha and numberic parts of the LC subclass together; for example "QA76.76" instead of "QA 76.76". Without the space, Evergreen was not inserting a line break. This commit will insert a line break automatically if the first element of a call number contains 1 to 3 alpha characters followed immediately by 1 or more numbers. This should not affect Dewey or most other classification systems, but will have the effect of making call numbers split as follows: Given "QA76.76 S93 1998", generate: QA 76.76 S93 1998 git-svn-id: svn://svn.open-ils.org/ILS/trunk@17359 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/cat/spine_labels.js b/Open-ILS/xul/staff_client/server/cat/spine_labels.js index dd88df46c..e9192a96e 100644 --- a/Open-ILS/xul/staff_client/server/cat/spine_labels.js +++ b/Open-ILS/xul/staff_client/server/cat/spine_labels.js @@ -153,6 +153,9 @@ names = String(volume.label()).split(/\s+/); } var j = 0; + var name_cnt = 0; + /* for LC, split between classification subclass letters and numbers */ + var lc_class_re = /^([A-Z]{1,3})([0-9]+.*?$)/i; while (j < label_cfg.spine_length || j < label_cfg.pocket_length) { var hb2 = document.createElement('hbox'); label_node.appendChild(hb2); @@ -171,9 +174,21 @@ tb.setAttribute('name','spine'); var spine_row_id = 'acn_' + volume.id() + '_spine_' + j; tb.setAttribute('id',spine_row_id); + var name = names.shift(); if (name) { name = String( name ); + + /* Split LC subclass between alpha and numeric part */ + if (name_cnt == 0) { + var lc_class_match = lc_class_re.exec(name); + if (lc_class_match && lc_class_match.length > 1) { + name = lc_class_match[1]; + names = [lc_class_match[2]].concat(names); + } + name_cnt = 1; + } + /* if the name is greater than the label width... */ if (name.length > label_cfg.spine_width) { /* then try to split it on periods */