From 5de35ae6390d34d8d851996ac4f97d1d00aba9c1 Mon Sep 17 00:00:00 2001 From: maimairel Date: Tue, 13 Nov 2012 13:34:46 +0700 Subject: [PATCH] Cleaner and portable function to get pixelratio This patch is intended the make getPixelRatio function portable and cleaner :) Previous indentation issue has also been fixed. Thanks :) --- jquery.flot.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 5413e48..e179a94 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -724,12 +724,15 @@ // therefore has a pixel ratio of 2, while most normal devices have a ratio of 1. function getPixelRatio(cctx) { - if (window.devicePixelRatio > 1 && - (cctx.webkitBackingStorePixelRatio === undefined || - cctx.webkitBackingStorePixelRatio < 2)) - return window.devicePixelRatio; - - return 1; + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = + cctx.webkitBackingStorePixelRatio || + cctx.mozBackingStorePixelRatio || + cctx.msBackingStorePixelRatio || + cctx.oBackingStorePixelRatio || + cctx.backingStorePixelRatio || 1; + + return devicePixelRatio / backingStoreRatio; } function makeCanvas(skipPositioning, cls) {