From ee8fcf051ca41be9cdf0dec5329b6f616f205992 Mon Sep 17 00:00:00 2001
From: Thomas Berezansky <tsbere@mvlc.org>
Date: Thu, 17 May 2012 12:19:48 -0400
Subject: [PATCH] Switch to XUL for printer settings editor

Because in later versions of XULRunner we apparently can't do bindings
outside of XUL documents, and messagecatalogs are binding-based.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
---
 Open-ILS/web/opac/locale/en-US/lang.dtd            |  2 +-
 .../xul/staff_client/chrome/content/main/menu.js   |  2 +-
 Open-ILS/xul/staff_client/server/admin/index.xhtml |  2 +-
 .../server/admin/printer_settings.html             | 61 -------------------
 .../staff_client/server/admin/printer_settings.xul | 68 ++++++++++++++++++++++
 5 files changed, 71 insertions(+), 64 deletions(-)
 delete mode 100644 Open-ILS/xul/staff_client/server/admin/printer_settings.html
 create mode 100644 Open-ILS/xul/staff_client/server/admin/printer_settings.xul

diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd
index 8180820806..3fe1a14632 100644
--- a/Open-ILS/web/opac/locale/en-US/lang.dtd
+++ b/Open-ILS/web/opac/locale/en-US/lang.dtd
@@ -3681,7 +3681,7 @@
 <!ENTITY staff.printing.advanced.custom_print.warning.header "Note on Custom/External Print">
 <!ENTITY staff.printing.advanced.custom_print.warning.text "This print strategy will ignore the printer settings in the &quot;Normal Settings&quot; section. Advanced templates using Javascript may not work, even if the external tool can take the receipt.html file.">
 <!ENTITY staff.printing.advanced.html_templates.warning.header "Also...">
-<!ENTITY staff.printing.advanced.html_templates.warning.text "If using Receipt Templates with either the DOS LPT1 Print strategy or the Custom/External Print strategy (with &quot;receipt.txt&quot;), the client will try to translate any HTML markup to text, but this process may be imperfect, and for the best fidelity you should consider reworking your templates to be plain text if you are using a plain text print strategy.  However, if using a plain text print strategy with HTML markup, you may include special character codes in 2-digit hexadecimal in a &quot;hex&quot; attribute for any given element.  Such codes will be converted to actual characters and inserted at the place of the tag.  For example, &amp;lt;p hex=&amp;quot;0C&amp;quot;&amp;gt;Hello World&amp;lt;/p&amp;gt; will translate to form feed control character + Hello World. &amp;lt;p&amp;gt;Hello World&amp;lt;/p hex=&amp;quot;0C&amp;quot;&amp;gt; will translate to Hello World + form feed control character.">
+<!ENTITY staff.printing.advanced.html_templates.warning.text "If using Receipt Templates with either the DOS LPT1 Print strategy or the Custom/External Print strategy (with &quot;receipt.txt&quot;), the client will try to translate any HTML markup to text, but this process may be imperfect, and for the best fidelity you should consider reworking your templates to be plain text if you are using a plain text print strategy.  However, if using a plain text print strategy with HTML markup, you may include special character codes in 2-digit hexadecimal in a &quot;hex&quot; attribute for any given element.  Such codes will be converted to actual characters and inserted at the place of the tag.  For example, &lt;p hex=&quot;0C&quot;&gt;Hello World&lt;/p&gt; will translate to form feed control character + Hello World. &lt;p&gt;Hello World&lt;/p hex=&quot;0C&quot;&gt; will translate to Hello World + form feed control character.">
 <!ENTITY staff.client.portal.title "Evergreen Staff Client Portal">
 <!ENTITY staff.client.portal.welcome "Welcome to Evergreen">
 <!ENTITY staff.client.portal.circpatron "Circulation and Patrons">
diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js
index a3bd477063..d7fb3b4c21 100644
--- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js
+++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js
@@ -705,7 +705,7 @@ main.menu.prototype = {
             ],
             'cmd_local_admin_printer' : [
                 ['oncommand'],
-                function(event) { open_admin_page('printer_settings.html', 'menu.cmd_local_admin_printer.tab', true, event); }
+                function(event) { open_admin_page('printer_settings.xul', 'menu.cmd_local_admin_printer.tab', false, event); }
             ],
             'cmd_local_admin_do_not_auto_attempt_print_setting' : [
                 ['oncommand'],
diff --git a/Open-ILS/xul/staff_client/server/admin/index.xhtml b/Open-ILS/xul/staff_client/server/admin/index.xhtml
index 1e410980d3..ea4a3f1447 100644
--- a/Open-ILS/xul/staff_client/server/admin/index.xhtml
+++ b/Open-ILS/xul/staff_client/server/admin/index.xhtml
@@ -56,7 +56,7 @@
                                 <a href='javascript:_l("font_settings.xul");'>&staff.server.admin.index.fonts_and_sounds;</a>
                             </div>
                             <div style='padding: 8px;'>
-                                <a href='javascript:_l("printer_settings.html");'>&staff.server.admin.index.printer;</a>
+                                <a href='javascript:_l("printer_settings.xul");'>&staff.server.admin.index.printer;</a>
                             </div>
                         </td><td>
                             <div style='padding: 8px;'>
diff --git a/Open-ILS/xul/staff_client/server/admin/printer_settings.html b/Open-ILS/xul/staff_client/server/admin/printer_settings.html
deleted file mode 100644
index 4998ba7769..0000000000
--- a/Open-ILS/xul/staff_client/server/admin/printer_settings.html
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-
-<!DOCTYPE html PUBLIC
-    "-//W3C//DTD XHTML 1.0 Transitional//EN"
-    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
-    <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
-]>
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-    <style type='text/css'>
-        .messagecatalog { -moz-binding: url( /xul/server/main/bindings.xml#messagecatalog ) }
-    </style>
-    <script type="text/javascript" src="/opac/common/js/utils.js"></script>
-    <script type="text/javascript" src="/opac/common/js/CGI.js"></script>
-    <script type="text/javascript" src="/opac/common/js/md5.js"></script>
-    <script type="text/javascript" src="/opac/common/js/JSON_v1.js"></script>
-    <script type="text/javascript" src="/opac/common/js/fmall.js"></script>
-    <script type="text/javascript" src="/opac/common/js/fmgen.js"></script>
-    <script type="text/javascript" src="/opac/common/js/RemoteRequest.js"></script>
-    <script type='text/javascript' src='/opac/common/js/<!--#echo var="locale"-->/OrgTree.js'></script>
-    <script type="text/javascript" src="/opac/common/js/org_utils.js"></script>
-
-    <script type="text/javascript" src="/xul/server/OpenILS/global_util.js"></script>
-    <script type="text/javascript" src="/xul/server/main/constants.js"></script>
-    <script type="text/javascript" src="/xul/server/main/JSAN.js"></script>
-    <script type="text/javascript" src="printer_settings.js"></script>
-</head><body onload="try { my_init(); } catch(E) { alert(E); }" style="background: white;">
-    <div class="messagecatalog" id="offlineStrings" src="/xul/server/locale/<!--#echo var='locale'-->/offline.properties" />
-    <h1>&staff.printing.context.header;</h1>
-    <p>&staff.printing.context.desc;</p>
-    <form>
-        <input type="radio" name="context" value="default" checked="checked" onclick="g.set_printer_context('default');">&staff.printing.context.radio.default.label;</input>
-        <input type="radio" name="context" value="receipt" onclick="g.set_printer_context('receipt');">&staff.printing.context.radio.receipt.label;</input>
-        <input type="radio" name="context" value="label" onclick="g.set_printer_context('label');">&staff.printing.context.radio.label.label;</input>
-        <input type="radio" name="context" value="mail" onclick="g.set_printer_context('mail');">&staff.printing.context.radio.mail.label;</input>
-        <input type="radio" name="context" value="offline" onclick="g.set_printer_context('offline');">&staff.printing.context.radio.offline.label;</input>
-    </form> 
-    <h1>&staff.printing.normal_settings.header;</h1>
-    <iframe id="sample" src="printer_settings.txt" oils_force_external="true"></iframe><br />
-    <button onclick="try { g.printer_settings(); } catch(E) { alert(E); }">&staff.printing.set_default;</button>
-    <button onclick="try { g.page_settings(); } catch(E) { alert(E); }">&staff.printing.page_settings;</button><br />
-    <h1>&staff.printing.advanced_settings.header;</h1>
-    <form>
-        <input type='checkbox' id='print_silent' onclick='g.toggle_silent_print(event);'>&staff.printing.advanced.mozilla_print.print_silent;</input>
-    </form>
-    <button onclick="try { g.set_print_strategy('webBrowserPrint'); } catch(E) { alert(E); }">&staff.printing.advanced.mozilla_print;</button>
-    <button onclick="try { g.set_print_strategy('dos.print'); } catch(E) { alert(E); }">&staff.printing.advanced.dos_print;</button>
-    <button onclick="try { g.set_print_strategy('custom.print'); } catch(E) { alert(E); }">&staff.printing.advanced.custom_print;</button>
-    <p>
-        <dl>
-            <dt><b>&staff.printing.advanced.dos_print.warning.header;</b></dt>
-            <dd>&staff.printing.advanced.dos_print.warning.text;</dd>
-            <dt><b>&staff.printing.advanced.custom_print.warning.header;</b></dt>
-            <dd>&staff.printing.advanced.custom_print.warning.text;</dd>
-            <dt><b>&staff.printing.advanced.html_templates.warning.header;</b></dt>
-            <dd>&staff.printing.advanced.html_templates.warning.text;</dd>
-        </dl>
-    </p>
-</body></html>
-
diff --git a/Open-ILS/xul/staff_client/server/admin/printer_settings.xul b/Open-ILS/xul/staff_client/server/admin/printer_settings.xul
new file mode 100644
index 0000000000..e8f61aed0a
--- /dev/null
+++ b/Open-ILS/xul/staff_client/server/admin/printer_settings.xul
@@ -0,0 +1,68 @@
+<?xml version='1.0' encoding="UTF-8"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+    <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<window id="workstation_printer_settings_edit" onload="try { my_init(); } catch(E) { alert(E); }" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+    <script type="text/javascript" src="/opac/common/js/utils.js"></script>
+    <script type="text/javascript" src="/opac/common/js/CGI.js"></script>
+    <script type="text/javascript" src="/opac/common/js/md5.js"></script>
+    <script type="text/javascript" src="/opac/common/js/JSON_v1.js"></script>
+    <script type="text/javascript" src="/opac/common/js/fmall.js"></script>
+    <script type="text/javascript" src="/opac/common/js/fmgen.js"></script>
+    <script type="text/javascript" src="/opac/common/js/RemoteRequest.js"></script>
+    <script type='text/javascript' src='/opac/common/js/<!--#echo var="locale"-->/OrgTree.js'></script>
+    <script type="text/javascript" src="/opac/common/js/org_utils.js"></script>
+
+    <script type="text/javascript" src="/xul/server/OpenILS/global_util.js"></script>
+    <script type="text/javascript" src="/xul/server/main/constants.js"></script>
+    <script type="text/javascript" src="/xul/server/main/JSAN.js"></script>
+    <script type="text/javascript" src="printer_settings.js"></script>
+    <messagecatalog id="offlineStrings" src="/xul/server/locale/<!--#echo var='locale'-->/offline.properties" />
+    <groupbox>
+        <caption label="&staff.printing.context.header;" />
+        <vbox>
+            <description>&staff.printing.context.desc;</description>
+            <radiogroup orient="horizontal">
+                <radio value="default" checked="checked" oncommand="g.set_printer_context('default');" label="&staff.printing.context.radio.default.label;" />
+                <radio value="receipt" oncommand="g.set_printer_context('receipt');" label="&staff.printing.context.radio.receipt.label;" />
+                <radio value="label" oncommand="g.set_printer_context('label');" label="&staff.printing.context.radio.label.label;" />
+                <radio value="mail" oncommand="g.set_printer_context('mail');" label="&staff.printing.context.radio.mail.label;" />
+                <radio value="offline" oncommand="g.set_printer_context('offline');" label="&staff.printing.context.radio.offline.label;" />
+            </radiogroup>
+        </vbox>
+    </groupbox>
+    <groupbox>
+        <caption label="&staff.printing.normal_settings.header;" />
+        <vbox>
+            <iframe id="sample" src="printer_settings.txt" oils_force_external="true" type="content" style="background-color: white;" />
+            <hbox>
+                <button oncommand="try { g.printer_settings(); } catch(E) { alert(E); }" label="&staff.printing.set_default;" />
+                <button oncommand="try { g.page_settings(); } catch(E) { alert(E); }" label="&staff.printing.page_settings;" />
+            </hbox>
+        </vbox>
+    </groupbox>
+    <groupbox>
+        <caption value="&staff.printing.advanced_settings.header;" />
+        <checkbox id='print_silent' oncommand='g.toggle_silent_print(event);' label="&staff.printing.advanced.mozilla_print.print_silent;" />
+        <hbox>
+            <button oncommand="try { g.set_print_strategy('webBrowserPrint'); } catch(E) { alert(E); }" label="&staff.printing.advanced.mozilla_print;" />
+            <button oncommand="try { g.set_print_strategy('dos.print'); } catch(E) { alert(E); }" label="&staff.printing.advanced.dos_print;" />
+            <button oncommand="try { g.set_print_strategy('custom.print'); } catch(E) { alert(E); }" label="&staff.printing.advanced.custom_print;" />
+        </hbox>
+        <label value="&staff.printing.advanced.dos_print.warning.header;" style="font-weight: bold" />
+        <description>&staff.printing.advanced.dos_print.warning.text;</description>
+        <label value="&staff.printing.advanced.custom_print.warning.header;" style="font-weight: bold" />
+        <description>&staff.printing.advanced.custom_print.warning.text;</description>
+        <label value="&staff.printing.advanced.html_templates.warning.header;" style="font-weight: bold" />
+        <description>&staff.printing.advanced.html_templates.warning.text;</description>
+    </groupbox>
+</window>
-- 
2.11.0