From eb0f59fb49063b75ac30363b2e663c0293d0f5a7 Mon Sep 17 00:00:00 2001 From: pines Date: Fri, 22 Sep 2006 04:38:06 +0000 Subject: [PATCH] text utilities git-svn-id: svn://svn.open-ils.org/ILS/trunk@6187 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/text.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Open-ILS/xul/staff_client/chrome/content/util/text.js diff --git a/Open-ILS/xul/staff_client/chrome/content/util/text.js b/Open-ILS/xul/staff_client/chrome/content/util/text.js new file mode 100644 index 0000000000..6556eb29f7 --- /dev/null +++ b/Open-ILS/xul/staff_client/chrome/content/util/text.js @@ -0,0 +1,27 @@ +dump('entering util/text.js\n'); + +if (typeof util == 'undefined') var util = {}; +util.text = {}; + +util.text.EXPORT_OK = [ + 'wrap_on_space', +]; +util.text.EXPORT_TAGS = { ':all' : util.text.EXPORT_OK }; + +util.text.wrap_on_space = function( text, length ) { + try { + if (text.length <= length) return [ text, '' ]; + + var truncated_text = text.substr(0,length); + + var pivot_pos = truncated_text.lastIndexOf(' '); + + return [ text.substr(0,pivot_pos).replace(/\s*$/,''), text.substr(pivot_pos+1) ]; + + } catch(E) { + alert('FIXME: util.text.wrap_on_space( "' + text + '", ' + length + ")"); + return [ text.substr(0,length), text.substr(length) ]; + } +} + +dump('exiting util/text.js\n'); -- 2.11.0