[open-ils-commits] [GIT] Evergreen ILS branch master updated. 2d28a7aa88394c8167e30e683f7e3b01b7a5c939

Evergreen Git git at git.evergreen-ils.org
Tue Oct 4 13:32:11 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  2d28a7aa88394c8167e30e683f7e3b01b7a5c939 (commit)
       via  ef3742e255ca87755cae467fdc67b2c71f6e9be7 (commit)
       via  4894c8f25d5a59dbd5d830c28fc9f50fe31cb92f (commit)
       via  865c23330a9e891024e2df3696dfe5a827ed545c (commit)
      from  3891ba9abdf39dd079472e5213e7db1407e47b8d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2d28a7aa88394c8167e30e683f7e3b01b7a5c939
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Tue Oct 4 13:20:41 2011 -0400

    pin version for upgrade script
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 9004611..368668a 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0632', :eg_version); -- tsbere/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0633', :eg_version); -- tsbere/phasefx
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql b/Open-ILS/src/sql/Pg/upgrade/0633.new_print_method.sql
similarity index 85%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql
rename to Open-ILS/src/sql/Pg/upgrade/0633.new_print_method.sql
index bb7d8da..9298aaf 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0633.new_print_method.sql
@@ -1,3 +1,8 @@
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0633', :eg_version);
+
 INSERT into config.org_unit_setting_type
 ( name, grp, label, description, datatype ) VALUES
 (
@@ -18,3 +23,5 @@ INSERT into config.org_unit_setting_type
         ),
         'string'
     );
+
+COMMIT;

commit ef3742e255ca87755cae467fdc67b2c71f6e9be7
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Mon Sep 12 12:43:59 2011 -0400

    Switch to Modal printing
    
    Prevents an OS-level race condition on window focus.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

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 320152c..49fa358 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/print.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js
@@ -174,16 +174,15 @@ util.print.prototype = {
                         print_url += '<script src="' + this.data.hash.aous['print.custom_js_file'] + '"></script>';
                     }
                     print_url += '</head><body onload="try{print_init(\'' + params.type + '\');}catch(E){alert(E);}">' + window.escape(msg.replace(/<script[^>]*>.*?<\/script>/gi,'')) + '</body></html>';
-                    w = obj.win.openDialog(print_url,'receipt_temp','chrome,resizable,minimizable', null, { "data" : params.data, "list" : params.list}, function() { 
+                    obj.win.openDialog(print_url,'receipt_temp','chrome,resizable,modal', null, { "data" : params.data, "list" : params.list}, function(w) { 
                         try {
                             obj.NSPrint(w, silent, params);
                         } catch(E) {
                             obj.error.standard_unexpected_error_alert("Print Error in util.print.simple.  After this dialog we'll try a second print attempt. content_type = " + content_type,E);
                             w.print();
                         }
-                        w.minimize(); w.close();
+                        w.close();
                     });
-                    w.minimize();
                 break;
                 default:
                     w = obj.win.open('data:' + content_type + ',' + window.escape(msg),'receipt_temp','chrome,resizable');
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print_win.js b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js
index 136b3bf..76f53f5 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/print_win.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js
@@ -14,7 +14,7 @@ function print_init(type) {
         print_check_noprint();
     }
     if (do_print) {
-        go_print();
+        go_print(window);
     } else {
         window.close();
     }

commit 4894c8f25d5a59dbd5d830c28fc9f50fe31cb92f
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Wed Aug 24 11:32:15 2011 -0400

    Unwrapped upgrade script for print.custom_js_file
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql
new file mode 100644
index 0000000..bb7d8da
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_print_method.sql
@@ -0,0 +1,20 @@
+INSERT into config.org_unit_setting_type
+( name, grp, label, description, datatype ) VALUES
+(
+        'print.custom_js_file', 'circ',
+        oils_i18n_gettext(
+            'print.custom_js_file',
+            'Printing: Custom Javascript File',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'print.custom_js_file',
+            'Full URL path to a Javascript File to be loaded when printing. Should'
+            || ' implement a print_custom function for DOM manipulation. Can change'
+            || ' the value of the do_print variable to false to cancel printing.',
+            'coust',
+            'description'
+        ),
+        'string'
+    );

commit 865c23330a9e891024e2df3696dfe5a827ed545c
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Wed Aug 24 11:31:59 2011 -0400

    Remove in-template javascript, add script files
    
    Adds support for a print_custom.js file and an org unit specified file.
    
    If either exists and contains a print_custom function it will be called
    before printing to allow for DOM manipulation.
    
    If neither exists the print_win.js file will call all functions it has
    defined.
    
    In addition, if any code sets do_print to false the window will close
    instead of attempting to print.
    
    The print_custom function will receive the type of template used, if any.
    This only applies to "Receipt Template" based print jobs, and the type in
    question is the "Type" that shows in the template editor.
    
    Functions defined in print_win.js:
    
    print_init
        Main function, checks for print_custom and does final printing
    
    print_do_sums
        Does summing of values.
    
    print_check_alt
        Does swapping out of template blocks with display:none styling.
    
    print_check_noprint
        Disables printing under certain circumstances.
    
    For more information about usage of the print_do_sums, print_check_alt,
    and print_check_noprint functions check the comments in print_win.js.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index e605528..1c84e97 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -3734,6 +3734,17 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'bool', null)
 
+,( 'print.custom_js_file', 'circ',
+    oils_i18n_gettext('print.custom_js_file',
+        'Printing: Custom Javascript File',
+        'coust', 'label'),
+    oils_i18n_gettext('print.custom_js_file',
+        'Full URL path to a Javascript File to be loaded when printing. Should'
+        || ' implement a print_custom function for DOM manipulation. Can change'
+        || ' the value of the do_print variable to false to cancel printing.',
+        'coust', 'description'),
+    'string', null)
+
 ,( 'serial.prev_issuance_copy_location', 'serial',
     oils_i18n_gettext('serial.prev_issuance_copy_location',
         'Previous Issuance Copy Location',
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 a4222fa..320152c 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/print.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js
@@ -155,10 +155,25 @@ util.print.prototype = {
 
             switch(content_type) {
                 case 'text/html' :
-                    var jsrc = 'data:text/javascript,' + window.escape('var params = window.arguments[0]; window.go_print = window.arguments[1];');
-                    var print_url = 'data:text/html,'
-                        + '<html id="top"><head><script src="/xul/server/main/JSAN.js"></script><script src="' + window.escape(jsrc) + '"></script></head>'
-                        + '<body onload="try{go_print();}catch(E){alert(E);}">' + window.escape(msg) + '</body></html>';
+                    if(!params.type) {
+                        params.type = '';
+                    }
+                    var my_prefix = '/xul/server/';
+                    if(window.location.protocol == "chrome:") {
+                        // Likely in offline interface
+                        my_prefix = 'chrome://open_ils_staff_client/content/';
+                    } else {
+                        if(xulG && xulG.url_prefix) {
+                            my_prefix = xulG.url_prefix(my_prefix);
+                        }
+                    }
+                    var print_url = 'data:text/html,<html id="top"><head>'
+                        + '<script src="' + my_prefix + 'util/print_win.js"></script>'
+                        + '<script src="' + my_prefix + 'util/print_custom.js"></script>';
+                    if(this.data.hash.aous['print.custom_js_file']) {
+                        print_url += '<script src="' + this.data.hash.aous['print.custom_js_file'] + '"></script>';
+                    }
+                    print_url += '</head><body onload="try{print_init(\'' + params.type + '\');}catch(E){alert(E);}">' + window.escape(msg.replace(/<script[^>]*>.*?<\/script>/gi,'')) + '</body></html>';
                     w = obj.win.openDialog(print_url,'receipt_temp','chrome,resizable,minimizable', null, { "data" : params.data, "list" : params.list}, function() { 
                         try {
                             obj.NSPrint(w, silent, params);
@@ -265,6 +280,12 @@ util.print.prototype = {
         }
         if (params.footer) s += this.template_sub( params.footer, cols, params );
 
+        // Sanity check, no javascript in templates
+        // Note: [\s\S] is a workaround for . not including newlines.
+        s=s.replace(/<script[^>]*>[\s\S]*?<\/script[^>]*>/gi,'')
+        s=s.replace(/onload\s*=\s*"[^"]*"/gi,'');
+        s=s.replace(/onload\s*=\s*'[^']*'/gi,'');
+
         if (params.sample_frame) {
             var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '};');
             params.sample_frame.setAttribute('src','data:text/html,<html id="top"><head><script src="' + window.escape(jsrc) + '"></script></head><body>' + window.escape(s) + '</body></html>');
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print_win.js b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js
new file mode 100644
index 0000000..136b3bf
--- /dev/null
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js
@@ -0,0 +1,165 @@
+// Print Window Functions
+// Loaded when print.js creates a window for printing
+
+var params = window.arguments[0];
+window.go_print = window.arguments[1];
+var do_print = true;
+
+function print_init(type) {
+    if (typeof print_custom == "function") {
+        print_custom(type);
+    } else {
+        print_do_sums();
+        print_check_alt();
+        print_check_noprint();
+    }
+    if (do_print) {
+        go_print();
+    } else {
+        window.close();
+    }
+}
+
+/* Example "swap slip" code
+ * Use example:
+ * <div altgroup="print1" altid="main">
+ * <span altcheck="print1">%some_replace%</span>
+ * <!-- Other slip stuff -->
+ * </div>
+ * <div altgroup="print1" altid="alt1" style="display: none">
+ * <!-- Alt slip stuff -->
+ * </div>
+ * <div altgroup="print1" altid="alt2" style="display: none">
+ * <!-- Second alt slip stuff -->
+ * </div>
+ * <div style="display: none">
+ * <span alt="print1" altshow="alt1">Code1</span>
+ * <span alt="print1" altshow="alt2">Code2</span>
+ * </div>
+ */
+function print_check_alt() {
+    var spans = document.getElementsByTagName('span');
+    if(!spans) return;
+    var groups_check = {};
+    var foundgroups = false;
+    for (var i = 0; i < spans.length; i++) {
+        var group = spans[i].getAttribute('altcheck');
+        if(group) {
+            groups_check[group] = spans[i].textContent;
+            foundgroups = true;
+        }
+    }
+    if(!foundgroups) return;
+    foundgroups = false;
+    var groups_show = {};
+    for (var i = 0; i < spans.length; i++) {
+        var group = spans[i].getAttribute('alt');
+        if(group && groups_check[group] && spans[i].textContent == groups_check[group]) {
+            groups_show[group] = spans[i].getAttribute('altshow');
+            foundgroups = true;
+        }
+    }
+    if(!foundgroups) return;
+    for (var i = 0; i < spans.length; i++) {
+        var group = spans[i].getAttribute('altgroup');
+        if(group && groups_check[group]) {
+            spans[i].style.display = (groups_show[group] == spans[i].getAttribute('altid') ? '' : 'none');
+        }
+    }
+    var divs = document.getElementsByTagName('div');
+    if (!divs) return;
+    for (var i = 0; i < divs.length; i++) {
+        var group = divs[i].getAttribute('altgroup');
+        if(group && groups_check[group]) {
+            divs[i].style.display = (groups_show[group] == divs[i].getAttribute('altid') ? '' : 'none');
+        }
+    }
+}
+
+/* Example "don't print" code
+ * Use example:
+ * <!-- blah blah -->
+ * <span noprintcheck="noprint1">%some_replace%</span>
+ * <span noprintcheck="noprint2">%some_other_replace%</span>
+ * <!-- blah blah -->
+ * <div style="display: none">
+ * <span noprint="noprint1">Code1</span>
+ * <span noprint="noprint2">Code2</span>
+ * </div>
+ */
+function print_check_noprint() {
+    var spans = document.getElementsByTagName('span');
+    if(!spans) return;
+    var noprints = {};
+    var foundnoprints = false;
+    for (var i = 0; i < spans.length; i++) {
+        var noprint = spans[i].getAttribute('noprintcheck');
+        if(noprint) {
+            noprints[noprint] = spans[i].textContent;
+            foundnoprints = true;
+        }
+    }
+    if(!foundnoprints) return;
+    for (var i = 0; i < spans.length; i++) {
+        var noprint = spans[i].getAttribute('noprint');
+        if(noprint) {
+            if(noprints[noprint] == spans[i].textContent) {
+                do_print = false;
+            }
+        }
+    }
+}
+
+/* Example "sum up" code
+ * Use example:
+ * <!-- blah blah -->
+ * <!-- Probably as line_item entries: -->
+ * <span sum="sum1">$5.00</span>
+ * <span sum="sum1">$15.00</span>
+ * <span sum="sum1">$25.00</span>
+ * <!-- blah blah -->
+ * $<span sumout="sum1" fixed="2"></span>
+ */
+function print_do_sums() {
+    var spans = document.getElementsByTagName('span');
+    if(!spans) return;
+    var sums = {};
+    var foundsums = false;
+    for (var i = 0; i < spans.length; i++) {
+        var sumset = spans[i].getAttribute("sum");
+        if(sumset) {
+            if(typeof sums[sumset] == 'undefined') {
+                sums[sumset] = 0.0;
+                foundsums = true;
+            }
+            var newVal = spans[i].textContent;
+            // strip off a single non-digit character
+            // Don't want to assume dollar sign
+            // But don't strip a -
+            newVal = newVal.replace(/^[^-0-9]/,'');
+            newVal = parseFloat(newVal);
+            if(!isNaN(newVal)) {
+                sums[sumset] += newVal;
+            }
+        }
+    }
+    if(!foundsums) return;
+    for (var i = 0; i < spans.length; i++) {
+        var sumset = spans[i].getAttribute("sumout");
+        if(sumset) {
+            if(typeof sums[sumset] == 'undefined') {
+                sums[sumset] = 0;
+            }
+            var fixed = spans[i].getAttribute("fixed");
+            if(fixed) {
+                fixed = parseInt(fixed);
+                if(isNaN(fixed)) {
+                    fixed = 0;
+                }
+                spans[i].textContent=sums[sumset].toFixed(fixed);
+            } else {
+                spans[i].textContent = sums[sumset];
+            }
+        }
+    }
+}

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   11 ++
 .../src/sql/Pg/upgrade/0633.new_print_method.sql   |   27 ++++
 .../xul/staff_client/chrome/content/util/print.js  |   34 ++++-
 .../staff_client/chrome/content/util/print_win.js  |  165 ++++++++++++++++++++
 5 files changed, 231 insertions(+), 8 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0633.new_print_method.sql
 create mode 100644 Open-ILS/xul/staff_client/chrome/content/util/print_win.js


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list