From 7afb6285b57df950cb74fa9027ef9c59d4293515 Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 5 May 2011 15:42:00 +0000 Subject: [PATCH] Add a feature authored by Joscha Filius for the International Institue of Social History: a diacritical palette for the MARC editor! Afelonne Doek of IISH wants the community to benefit from this code. To try it out, press control S in the marc editor (reguarly non-flat-text view). You can insert the characters you see, and you can right click on entries in your palette to customize. Customizations /should/ persist through staff client restart (untested by me so far). This should make cataloging in multiple (Western-ish) languages at once easier. Below I copy and paste some of Joscha's message to the list where he introduced this code: > *Bugs:* > A known bug is that is you switch marc edit styles back and forth the > listener trigger won't work anymore. Also for a far as I know there is at > least another bug concerning layout which is as far as I know not the result > of my doing. > > *Here comes a possibly nasty part*, to ensure that the diacriticals remain > intact throughout the persist I've changed global_util.js to URL encode and > URL decode all stored values. This might cause backwards incompatibility > with values that are already stored for other purposes without encoding. > This needs to be checked. git-svn-id: svn://svn.open-ils.org/ILS/trunk@20425 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 14 +- .../staff_client/server/OpenILS/symbol_overlay.js | 37 ++ .../staff_client/server/OpenILS/symbol_overlay.xul | 373 +++++++++++++++++++++ Open-ILS/xul/staff_client/server/cat/marcedit.xul | 3 +- Open-ILS/xul/staff_client/server/skin/global.css | 26 ++ 5 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.js create mode 100644 Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.xul diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index 8250caedcd..c1c104c7a5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -231,10 +231,13 @@ dump('on_oils_persist: <<< ' + target.nodeName + '.id = ' + target.id + '\t' + bk + '\n'); for (var j = 0; j < attribute_list.length; j++) { var key = base_key + attribute_list[j]; - var value = target.getAttribute( attribute_list[j] ); + var value = encodeURI(target.getAttribute( attribute_list[j] )); if ( attribute_list[j] == 'checked' && ['checkbox','toolbarbutton'].indexOf( target.nodeName ) > -1 ) { value = target.checked; dump('\t' + value + ' <== .' + attribute_list[j] + '\n'); + } else if ( attribute_list[j] == 'value' && ['menulist'].indexOf( target.nodeName ) > -1 ) { + value = target.value; + dump('\t' + value + ' <== .' + attribute_list[j] + '\n'); } else if ( attribute_list[j] == 'value' && ['textbox'].indexOf( target.nodeName ) > -1 ) { value = target.value; dump('\t' + value + ' <== .' + attribute_list[j] + '\n'); @@ -278,7 +281,7 @@ for (var j = 0; j < attribute_list.length; j++) { var key = base_key + attribute_list[j]; var has_key = prefs.prefHasUserValue(key); - var value = has_key ? prefs.getCharPref(key) : null; + var value = has_key ? decodeURI(prefs.getCharPref(key)) : null; if (value == 'true') { value = true; } if (value == 'false') { value = false; } if (has_key) { @@ -292,6 +295,9 @@ } else if ( attribute_list[j] == 'value' && ['textbox'].indexOf( nodes[i].nodeName ) > -1 ) { nodes[i].value = value; dump('\t' + value + ' ==> .' + attribute_list[j] + '\n'); + } else if ( attribute_list[j] == 'value' && ['menulist'].indexOf( nodes[i].nodeName ) > -1 ) { + nodes[i].value = value; + dump('\t' + value + ' ==> .' + attribute_list[j] + '\n'); } else if ( attribute_list[j] == 'sizemode' && ['window'].indexOf( nodes[i].nodeName ) > -1 ) { switch(value) { case window.STATE_MAXIMIZED: @@ -356,7 +362,9 @@ } } else { if (node.nodeName == 'textbox') { - event_types.push('change'); + event_types.push('change'); + } else if (node.nodeName == 'menulist') { + event_types.push('select'); } else if (node.nodeName == 'window') { event_types.push('resize'); node = window; // xul window is an element of window.document diff --git a/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.js b/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.js new file mode 100644 index 0000000000..f84a702250 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.js @@ -0,0 +1,37 @@ +dump('entering symbol/clipboard.js\n'); + +function $(id) { return document.getElementById(id); } + +var el = {}; + +dojo.addOnLoad( + function(){ + dojo.query('.plain').forEach(function(node,index,arr){ + node.addEventListener("keypress", function(event) { + if (event.charCode == 115 && event.ctrlKey){ + setNod(node); + $('symbol-panel').openPopup(node, 'after_pointer' ); + } + }, true); + }); + } +); + +function setNod(elm){ + el = elm; +} + +function ret(ins, e){ + if (e.button == 0){ + $('symbol-panel').hidePopup(); + n = el; + + if (n.getAttribute('readonly')=='true') return; + + var v = n.value; + var start = n.selectionStart; + var end = n.selectionEnd; + n.value = v.substring(0, start) + ins + v.substring(end, v.length); + n.setSelectionRange(start + ins.length,start + ins.length); + } +} diff --git a/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.xul b/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.xul new file mode 100644 index 0000000000..d9a478029b --- /dev/null +++ b/Open-ILS/xul/staff_client/server/OpenILS/symbol_overlay.xul @@ -0,0 +1,373 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +