From e9e6a8313d32f3c64bbc1a7c15f30795b8e52880 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Thu, 2 Aug 2018 11:59:58 +0200 Subject: [PATCH] Move prviliged public methods to Utilities.Internal Moving flattenArguments, setFontSize and getAncestorByTagName --- chrome/content/zotero/xpcom/utilities.js | 56 ------------------ .../zotero/xpcom/utilities_internal.js | 58 ++++++++++++++++++- chrome/content/zotero/xpcom/zotero.js | 30 +++------- 3 files changed, 65 insertions(+), 79 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 4a6e12be88..cde6edbb44 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1343,62 +1343,6 @@ 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 Zotero.Utilities.Internal.defineProperty(...args); - + this.extendClass = (...args) => Zotero.Utilities.Internal.extendClass(...args); - + this.getLocaleCollation = function () { - return Zotero.Intl.collation; - }; + return Zotero.Intl.collation; + } this.localeCompare = function (...args) { return Zotero.Intl.compare(...args); - }; + } function setFontSize(rootElement) { return Zotero.Utilities.setFontSize(rootElement); } - function flattenArguments(args){ - return Zotero.Utilities.flattenArguments(args); + return Zotero.Utilities.Internal.flattenArguments(args); } - function getAncestorByTagName(elem, tagName){ - return Zotero.Utilities.getAncestorByTagName(elem, tagName); + return Zotero.Utilities.Internal.getAncestorByTagName(elem, tagName); } - function randomString(len, chars) { - return Zotero.Utilities.randomString(len, chars); + return Zotero.Utilities.Internal.randomString(len, chars); }