增加了自动记录当前“显示原文”状态的功能,以便在切换到其它页时保存状态。
This commit is contained in:
parent
0ee5264d19
commit
23eb2191b1
|
@ -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);
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue