From 65cf372b67a0a7e6633af02317ae40fabf4b6d2d Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 14 May 2012 12:14:30 -0400 Subject: [PATCH] text rotation macro for receipts/slips %ROTATE(degrees)% %ROTATE(degrees,'extra CSS')% %ROTATE_END% Degrees is an integer, but typically you'd use values like 90, -90, 180, 45 etc. The things between %ROTATE% and %ROTATE_END% macros will be rotated by the specified number of degrees. Negative values rotate counter-clockwise. Except for very minimal receipts with judicious use of line breaks, simple rotation will probably truncate part of whatever is being rotated. So, there's an 'extra CSS' variant where you can specify more CSS to fine tune positioning of the rotated text/objects. For an example, try this for a hold_slip template: Header: This item needs to be routed to %route_to%:
Barcode: %item_barcode%
Title: %item_title%

%ROTATE(90,'position: absolute; top: 150px; left: 100px')% %hold_for_msg%
Barcode: %PATRON_BARCODE%
Notify by phone: %notify_by_phone%
Notified by text: %notify_by_text%
Notified by email: %notify_by_email%
%ROTATE_END% %ROTATE(760,'position: absolute; top: 150px; left: 50px')% Line Item: %formatted_note%
Footer: %ROTATE_END%











Request date: %request_date%
Slip Date: %TODAY_TRIM%
Printed by %STAFF_FIRSTNAME% at %SHORTNAME%

And then try replacing the %ROTATE(90,'position: absolute; top: 150px; left: 100px')% with a mere %ROTATE(90)% and note how the text starts overlapping and becomes truncated. Signed-off-by: Jason Etheridge --- .../xul/staff_client/chrome/content/util/print.js | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index 166b4867f6..ccd3a7d797 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -459,6 +459,34 @@ util.print.prototype = { s = s.replace(/\s*%-TRIM%/g,''); } catch(E) { dump(E+'\n'); } + // Text rotation + try { + var rotate_patt=/%ROTATE\(\s*(-?\d+)\s*\)%/; + while(match = rotate_patt.exec(s)) { + var degrees = parseInt(match[1]); + s = s.replace( + match[0], + '' + ); + } + var ex_rotate_patt=/%ROTATE\(\s*(-?\d+)\s*,\s*'(.*?)'\s*\)%/; + while(match = ex_rotate_patt.exec(s)) { + var degrees = parseInt(match[1]); + var extra_css = match[2]; // things like position: absolute; top: 150px; etc. + s = s.replace( + match[0], + '' + ); + } + var end_rotate_patt=/%ROTATE_END%/; + while(match = end_rotate_patt.exec(s)) { + s = s.replace( + match[0], + '' + ); + } + } catch(E) { dump(E+'\n'); } + return s; } catch(E) { alert('Error in print.js, template_sub(): ' + E); -- 2.11.0