From be7b87a91e6417c772d1d855ceaa8c4885554c68 Mon Sep 17 00:00:00 2001 From: Rogan Creswick Date: Mon, 17 Jun 2013 16:40:26 -0700 Subject: moved the oldStyle storage into a closure around the show/hide problem displays --- src/js/fiveui/injected/ui.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/js/fiveui/injected/ui.js b/src/js/fiveui/injected/ui.js index d75cf20..a61b122 100644 --- a/src/js/fiveui/injected/ui.js +++ b/src/js/fiveui/injected/ui.js @@ -62,30 +62,23 @@ }, 10); }; - /** - * Temp storage for the old in-line styles on elements. - * - * XXX account for marking multiple elements at once. - * (or use a different approach for marking elements) - */ - core.oldStyle = ''; - core.highlightProblem = function(elt) { core.maskRules(function() { - core.oldStyle = elt.attr('style'); - console.log('old style: '+core.oldStyle); + var oldStyle = elt.attr('style'); elt.attr('style', 'background-color: rgba(255,0,0,0.3); background-image: none;'); elt.addClass('uic-problem'); + + return oldStyle; }); }; - core.maskProblem = function(elt) { + core.maskProblem = function(elt, oldStyle) { core.maskRules(function() { - if (core.oldStyle == undefined) { + if (oldStyle == undefined) { elt.removeAttr('style'); } else { - elt.attr('style', core.oldStyle); + elt.attr('style', oldStyle); } elt.removeClass('uic-problem'); @@ -150,17 +143,18 @@ prExpand.click( function() { + var oldStyle; var elt = $(this); if(elt.is('.prExpand-down')) { elt.removeClass('prExpand-down') .addClass('prExpand-right'); prDetails.hide(); - core.maskProblem(fiveui.query('.' + prob.hash)); + core.maskProblem(fiveui.query('.' + prob.hash), oldStyle); } else { elt.addClass('prExpand-down') .removeClass('prExpand-right'); prDetails.show(); - core.highlightProblem(fiveui.query('.' + prob.hash)); + oldStyle = core.highlightProblem(fiveui.query('.' + prob.hash)); } return false; @@ -218,7 +212,10 @@ $('#problemList').children().remove(); port.emit('ClearProblems'); core.renderStats(fiveui.stats.zero); - core.maskProblem(fiveui.query('.uic-problem')); + $('prExpand-down').click(); + + // Just in case the click event on prExpand-down missde anything: + core.maskProblem(fiveui.query('.uic-problem'), undefined); }); /////////////////////////////////////////// -- cgit v1.2.3