From 2e447f31f3cd379b8323d646be7e10333153f498 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 11 Sep 2013 13:49:07 -0400 Subject: [PATCH] LP#1084758 store staff client tpac (etc) zoom pref Staff client pages loaded via browser.xul which have a name (via internal XUL URL param) now have the ability to store and load a per- page zoom value preference. This includes (at minimum) the embedded TPAC. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../chrome/content/util/browser.js | 34 +++++++++++++++++++ .../chrome/content/util/browser.xul | 6 ++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.js b/Open-ILS/xul/staff_client/chrome/content/util/browser.js index fb0078ac22..20cb4dc4d9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -166,6 +166,39 @@ util.browser.prototype = { } }, + /* + * If the browser page is given a name (e.g. the catalog is "Catalog") + * and the user applies a zoom value (ctrl+ / ctrl-), store the value + * in the oils.util.browser.zoom. pref. On page load, if a value + * is set for the given page, load and apply the value to the page. + */ + 'apply_zoom' : function(val, delta) { + var name = xul_param('name'); + if (!name) return; + var key = 'oils.util.browser.zoom.' + name; // pref key + var viewer = this.controller.view.browser_browser.markupDocumentViewer; + + var prefs = Components.classes[ + '@mozilla.org/preferences-service;1'].getService( + Components.interfaces['nsIPrefBranch']); + + if (!val) { + if (delta) { + val = viewer.fullZoom; + val += delta + } else { + if (prefs.prefHasUserValue(key)) + val = prefs.getCharPref(key); + } + } + + val = Number(val); + if (!val || isNaN(val) || val < 0) return; + + viewer.fullZoom = val; + prefs.setCharPref(key, ''+val); + }, + 'reload' : function() { var obj = this; if (obj.lock_reload) { @@ -465,6 +498,7 @@ util.browser.prototype = { var alert_string = 'document has stopped: ' + new Date() + '\n'; dump(alert_string); try { obj.push_variables(); obj.updateNavButtons(); + obj.apply_zoom(); } catch(E) { var err_msg = 'browser.js STATE_IS_DOCUMENT STATE_STOP error with push_variables or updateNavButtons: ' + E + '\n'; dump(err_msg); diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul index 616c63bfe4..29ab51f4a7 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul @@ -110,9 +110,9 @@ - - - + + + -- 2.43.2