www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit d6064cfeba25da503afb85a5326c0d41e4481bde
parent 71d79e1f08bd768b6819106a167570411d375add
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed,  6 Apr 2016 01:09:14 -0400

Add Zotero.hiDPISuffix to avoid "@2x" logic each time

Can use Zotero.hiDPISuffix directly in URLs to automatically substitute
"@2x" on HiDPI displays.

Diffstat:
Mchrome/content/zotero/browser.js | 7++-----
Mchrome/content/zotero/overlay.js | 3++-
Mchrome/content/zotero/xpcom/collectionTreeView.js | 2+-
Mchrome/content/zotero/xpcom/data/cachedTypes.js | 2+-
Mchrome/content/zotero/xpcom/data/collection.js | 3+--
Mchrome/content/zotero/xpcom/data/library.js | 3+--
6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js @@ -874,13 +874,11 @@ Zotero_Browser.Tab.prototype.getCaptureState = function () { * current page, or false if the page cannot be scraped */ Zotero_Browser.Tab.prototype.getCaptureIcon = function (hiDPI) { - var suffix = hiDPI ? "@2x" : ""; - switch (this.getCaptureState()) { case this.CAPTURE_STATE_TRANSLATABLE: var itemType = this.getPageObject().translators[0].itemType; return (itemType === "multiple" - ? "chrome://zotero/skin/treesource-collection" + suffix + ".png" + ? "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png" : Zotero.ItemTypes.getImageSrc(itemType)); default: @@ -890,8 +888,7 @@ Zotero_Browser.Tab.prototype.getCaptureIcon = function (hiDPI) { // TODO: Show icons for images, PDFs, etc.? Zotero_Browser.Tab.prototype.getWebPageCaptureIcon = function (hiDPI) { - var suffix = hiDPI ? "@2x" : ""; - return "chrome://zotero/skin/treeitem-webpage" + suffix + ".png"; + return "chrome://zotero/skin/treeitem-webpage" + Zotero.hiDPISuffix + ".png"; } Zotero_Browser.Tab.prototype.getCaptureTooltip = function() { diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -87,8 +87,9 @@ var ZoteroOverlay = new function() observerService.addObserver(zoteroObserver, "browser-delayed-startup-finished", false); - // Set a flag for hi-res displays + // Set flags for hi-res displays Zotero.hiDPI = window.devicePixelRatio > 1; + Zotero.hiDPISuffix = Zotero.hiDPI ? "@2x" : ""; // Clear old Zotero icon pref var prefBranch = Components.classes["@mozilla.org/preferences-service;1"] diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -711,7 +711,7 @@ Zotero.CollectionTreeView.prototype.getCellText = function(row, column) Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col) { - var suffix = Zotero.hiDPI ? "@2x" : ""; + var suffix = Zotero.hiDPISuffix; var treeRow = this.getRow(row); var collectionType = treeRow.type; diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -441,7 +441,7 @@ Zotero.ItemTypes = new function() { } this.getImageSrc = function (itemType) { - var suffix = Zotero.hiDPI ? "@2x" : ""; + var suffix = Zotero.hiDPISuffix; if (this.isCustom(itemType)) { var id = this.getID(itemType) - this.customIDOffset; diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js @@ -91,8 +91,7 @@ Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewID', { Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewImage', { get: function () { - var suffix = Zotero.hiDPI ? "@2x" : ""; - return "chrome://zotero/skin/treesource-collection" + suffix + ".png"; + return "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png"; } }); diff --git a/chrome/content/zotero/xpcom/data/library.js b/chrome/content/zotero/xpcom/data/library.js @@ -182,8 +182,7 @@ Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewID', { Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewImage', { get: function () { - var suffix = Zotero.hiDPI ? "@2x" : ""; - return "chrome://zotero/skin/treesource-library" + suffix + ".png"; + return "chrome://zotero/skin/treesource-library" + Zotero.hiDPISuffix + ".png"; } });