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