From: phasefx Date: Wed, 7 Jan 2009 20:16:13 +0000 (+0000) Subject: roll our own textbox context menu for clipboard functions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=28ade26f432be90b86988fc8859efb3079e52e70;p=Evergreen.git roll our own textbox context menu for clipboard functions git-svn-id: svn://svn.open-ils.org/ILS/trunk@11758 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay.xul b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay.xul deleted file mode 100644 index a990666a16..0000000000 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay.xul +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/Open-ILS/xul/staff_client/chrome/content/util/clipboard.js b/Open-ILS/xul/staff_client/chrome/content/util/clipboard.js new file mode 100644 index 0000000000..0c402cb31b --- /dev/null +++ b/Open-ILS/xul/staff_client/chrome/content/util/clipboard.js @@ -0,0 +1,72 @@ +dump('entering util/clipboard.js\n'); + +if (typeof util == 'undefined') var util = {}; +util.clipboard = {}; + +util.clipboard.EXPORT_OK = [ + 'cut', 'copy', 'paste' +]; +util.clipboard.EXPORT_TAGS = { ':all' : util.clipboard.EXPORT_OK }; + +util.clipboard.cut = function() { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var n = document.popupNode; + var v = n.value; + var start = n.selectionStart; + var end = n.selectionEnd; + var clip = v.substring( start, end ); + n.value = v.substring(0, start) + v.substring(end, v.length); + const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] + .getService(Components.interfaces.nsIClipboardHelper); + gClipboardHelper.copyString(clip); + n.setSelectionRange(start,start); + dump('Copied ' + clip + '\n'); + } catch(E) { + alert(E); + } +} + +util.clipboard.copy = function() { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var n = document.popupNode; + var v = n.value; + var start = n.selectionStart; + var end = n.selectionEnd; + var clip = v.substring( start, end ); + const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] + .getService(Components.interfaces.nsIClipboardHelper); + gClipboardHelper.copyString(clip); + dump('Copied ' + clip + '\n'); + } catch(E) { + alert(E); + } +} + +util.clipboard.paste = function() { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var n = document.popupNode; + var v = n.value; + var start = n.selectionStart; + var end = n.selectionEnd; + var cb = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard); + if (!cb) return false; + var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); + if (!trans) return false; + trans.addDataFlavor("text/unicode"); + cb.getData(trans, cb.kGlobalClipboard); + var str = {}; var strLength = {}; + trans.getTransferData("text/unicode",str,strLength); + if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString); + var clip; if (str) clip = str.data.substring(0, strLength.value / 2); + n.value = v.substring(0, start) + clip + v.substring(end, v.length); + n.setSelectionRange(start + clip.length,start + clip.length); + dump('Pasted ' + clip + '\n'); + } catch(E) { + alert(E); + } +} + +dump('exiting util/clipboard.js\n'); diff --git a/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul b/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul index 0dfbb47e80..b404d3f707 100644 --- a/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul +++ b/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul @@ -1,12 +1,14 @@ - - + +]> - + + + + + + + + diff --git a/Open-ILS/xul/staff_client/server/cat/copy_notes.xul b/Open-ILS/xul/staff_client/server/cat/copy_notes.xul index 55d6302fe3..b7bfb924c3 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_notes.xul +++ b/Open-ILS/xul/staff_client/server/cat/copy_notes.xul @@ -159,8 +159,8 @@ \ \ \ - \ - \ + \ + \ \