From 23eb2191b1f99767b0b6d6b52d5416eabdc79770 Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Sun, 15 May 2016 22:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BD=93=E5=89=8D=E2=80=9C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8E=9F=E6=96=87=E2=80=9D=E7=8A=B6=E6=80=81=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BB=A5=E4=BE=BF=E5=9C=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=88=B0=E5=85=B6=E5=AE=83=E9=A1=B5=E6=97=B6=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/resources/js/controllers/app-controller.js | 3 ++- public/resources/js/translate.js | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/public/resources/js/controllers/app-controller.js b/public/resources/js/controllers/app-controller.js index 246b695bcb..ba34cd9cc2 100644 --- a/public/resources/js/controllers/app-controller.js +++ b/public/resources/js/controllers/app-controller.js @@ -63,7 +63,7 @@ angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', funct // TRIGGER PRETTYPRINT AFTER DIGEST LOOP COMPLETE $timeout(prettyPrint, 1); - vm.sourceVisible = debugging; + vm.sourceVisible = sourceVisible; vm.toggleSource = function ($event) { $event.preventDefault(); vm.sourceVisible = !vm.sourceVisible; @@ -74,5 +74,6 @@ angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', funct } else { $nodes.addClass('hidden'); } + localStorage.setItem('source-visible', vm.sourceVisible); }; }]); diff --git a/public/resources/js/translate.js b/public/resources/js/translate.js index 5e850fb97e..2cae2ed980 100644 --- a/public/resources/js/translate.js +++ b/public/resources/js/translate.js @@ -1,4 +1,12 @@ +// TODO: refactor me! var debugging = location.hostname === 'localhost'; +var sourceVisible = localStorage.getItem('source-visible'); +if (_.isUndefined(sourceVisible)) { + sourceVisible = debugging; +} else { + sourceVisible = sourceVisible === 'true'; +} + (function ($) { var nodes = document.querySelectorAll('p, li, h1, h2, h3, h4, h5, h6, header, a, button, small'); _.each(nodes, function (node) { @@ -18,7 +26,7 @@ var debugging = location.hostname === 'localhost'; } $prevNode.removeAttr('id'); $prevNode.addClass('original-english'); - if (!debugging) { + if (!sourceVisible) { $prevNode.addClass('hidden'); } if (node.tagName !== 'A' && node.tagName !== 'BUTTON') {