call_number.label
location.name
+Line-wrapping may be done with the | wrap filter. The first
+parameter is the number of characters to target for the string
+width. The second parameter is the wrapping algorithm to use.
+The third parameter is the prefix to use for the second and
+subsequent wrapped lines. One use for this is indentation
+with spaces.
+
+Available wrapping algorithms:
+
+once = Wraps a line just once
+default = Keeps wrapping a line until no more wraps are possible
+
+-->
+<!--
+Edit the height: in the following style attribute to set the
+label height.
+-->
+<table style="page-break-after: always; height: 1in" ng-repeat="copy in copies">
+<tr valign="top">
+<!--
+Edit the following width attribute to set the width for the
+spine label.
+-->
+<td style="width: 1in">
+<!-- Spine Label contents -->
+<pre style="border:none">{{copy['call_number.label']}}</pre></td>
+<!--
+Edit the following width attribute to specify the space between
+the spine label and the pocket label.
+-->
+<td style="width: 0in"></td>
+<!--
+Edit the following width attribute to set the width for the
+pocket label. To hide the pocket label, add style="display:none"
-->
-<div style="page-break-after: always;" class="row" ng-repeat="copy in copies">
-<div class="col-md-4"><pre>{{copy['call_number.label']}}</pre></div>
-<div class="col-md-8"><pre>
-{{copy['call_number.record.simple_record.title']}}
+<td style="width: 3in">
+<!-- Pocket Label contents -->
+<pre style="border:none">
+{{copy.barcode}}
+{{copy['call_number.label']}}
{{copy['call_number.record.simple_record.author']}}
-</pre></div>
-</div>
+{{copy['call_number.record.simple_record.title'] | wrap:28:'once':' '}}
+</pre></td>
+</tr>
+</table>
};
}])
+.filter('wrap', function() {
+ return function(input, w, wrap_type, indent) {
+ var output;
+
+ if (!w) return input;
+ if (!indent) indent = '';
+
+ function wrap_on_space(
+ text,
+ length,
+ wrap_just_once,
+ if_cant_wrap_then_truncate,
+ idx
+ ) {
+ if (idx>10) {
+ console.log('possible infinite recursion, aborting');
+ return '';
+ }
+ if (String(text).length <= length) {
+ return text;
+ } else {
+ var truncated_text = String(text).substr(0,length);
+ var pivot_pos = truncated_text.lastIndexOf(' ');
+ var left_chunk = text.substr(0,pivot_pos).replace(/\s*$/,'');
+ var right_chunk = String(text).substr(pivot_pos+1);
+
+ var wrapped_line;
+ if (left_chunk.length == 0) {
+ if (if_cant_wrap_then_truncate) {
+ wrapped_line = truncated_text;
+ } else {
+ wrapped_line = text;
+ }
+ } else {
+ wrapped_line =
+ left_chunk + '\n'
+ + indent + (
+ wrap_just_once
+ ? right_chunk
+ : (
+ right_chunk.length > length
+ ? wrap_on_space(
+ right_chunk,
+ length,
+ false,
+ if_cant_wrap_then_truncate,
+ idx+1)
+ : right_chunk
+ )
+ )
+ ;
+ }
+ return wrapped_line;
+ }
+ }
+
+ switch(wrap_type) {
+ case 'once':
+ console.log('wrap: once');
+ output = wrap_on_space(input,w,true,false,0);
+ break;
+ default:
+ console.log('wrap: default');
+ output = wrap_on_space(input,w,false,false,0);
+ break;
+ }
+
+ return output;
+ }
+})