From 89336ea737028d8bb0df0bbc8241632a069d888d Mon Sep 17 00:00:00 2001 From: Sneezry Date: Thu, 30 Apr 2015 13:04:03 +0800 Subject: [PATCH] fixed issue #12 --- css/popup.css | 1 + javascript/popup.js | 30 ++++++++++++++++++++++++++++++ manifest.json | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/css/popup.css b/css/popup.css index 04b408e..3178e56 100644 --- a/css/popup.css +++ b/css/popup.css @@ -108,6 +108,7 @@ body { font-family: arial, 'Microsoft YaHei'; cursor: default; -webkit-user-select: none; + transform-origin: left top; } #header, diff --git a/javascript/popup.js b/javascript/popup.js index 78570a5..a437971 100644 --- a/javascript/popup.js +++ b/javascript/popup.js @@ -881,6 +881,34 @@ function getNewHotpCode() { }); } +function getZoom() { + var zoomList = [25, 33, 50, 67, 75, 90, 100, 110, 125, 150, 175, 200, 250, 300, 400, 500]; + var zoom = Math.round(((window.outerWidth) / window.innerWidth)*100); + console.log(zoom) + var zoomDiff = -1; + for (var i = 0; i < zoomList.length; i++) { + if (zoomDiff < 0 || Math.abs(zoom - zoomList[i]) < zoomDiff) { + zoomDiff = Math.abs(zoom - zoomList[i]); + } else { + zoom = zoomList[i - 1]; + break; + } + } + if (zoomList.indexOf(zoom) === -1) { + zoom = 500; + } + return zoom; +} + +function rezoom() { + var zoom = getZoom(); + if (zoom > 100) { + document.body.style.height = 480 * 100 / zoom + 'px'; + document.body.style.marginRight = 320 * (100 / zoom - 1) + 'px'; + document.body.style.transform = 'scale(' + (100 / zoom) + ')'; + } +} + (function () { var clientTime = new Date(); clientTime = Math.floor(clientTime.getTime() / 1000 / 3600 / 24); @@ -909,3 +937,5 @@ function getNewHotpCode() { } } })(); + +setTimeout(rezoom, 200); diff --git a/manifest.json b/manifest.json index 32bf80e..d04fe1c 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extName__", "short_name": "__MSG_extShortName__", - "version": "4.10", + "version": "4.11", "default_locale": "en", "description": "__MSG_extDesc__", "icons": {