From caaaed0af113f3fc87718cbe6ffde842e035bef1 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Wed, 1 Aug 2018 23:57:02 +0200 Subject: [PATCH] Move privileged public functions to Z.Utilities --- chrome/content/zotero/xpcom/utilities.js | 57 ++++++++++++++++++++++++ chrome/content/zotero/xpcom/zotero.js | 54 ++-------------------- 2 files changed, 60 insertions(+), 51 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index d82c445fa7..4a6e12be88 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1343,6 +1343,63 @@ Zotero.Utilities = { return strings.join(delimiter !== undefined ? delimiter : ", "); }, + /* + * Sets font size based on prefs -- intended for use on root element + * (zotero-pane, note window, etc.) + */ + "setFontSize": function (rootElement) { + var size = Zotero.Prefs.get('fontSize'); + rootElement.style.fontSize = size + 'em'; + if (size <= 1) { + size = 'small'; + } + else if (size <= 1.25) { + size = 'medium'; + } + else { + size = 'large'; + } + // Custom attribute -- allows for additional customizations in zotero.css + rootElement.setAttribute('zoteroFontSize', size); + }, + + /* + * Flattens mixed arrays/values in a passed _arguments_ object and returns + * an array of values -- allows for functions to accept both arrays of + * values and/or an arbitrary number of individual values + */ + "flattenArguments": function (args){ + // Put passed scalar values into an array + if (args === null || typeof args == 'string' || typeof args.length == 'undefined') { + args = [args]; + } + + var returns = []; + for (var i=0; i