From 3f9a4d42f7bf0c90c38834fdb20c3f8361695573 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Tue, 13 Aug 2013 16:14:26 -0700 Subject: [PATCH] Better JS for Differential File Collapsing Undo Summary: take epriestley's feedback 'cuz its good Test Plan: collapse, expand, use undo like a rockstar. observe proper behavior Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T2258 Differential Revision: https://secure.phabricator.com/D6748 --- .../differential/behavior-toggle-files.js | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/webroot/rsrc/js/application/differential/behavior-toggle-files.js b/webroot/rsrc/js/application/differential/behavior-toggle-files.js index a680e69c3a..296b6f91b2 100644 --- a/webroot/rsrc/js/application/differential/behavior-toggle-files.js +++ b/webroot/rsrc/js/application/differential/behavior-toggle-files.js @@ -18,26 +18,28 @@ JX.behavior('differential-toggle-files', function(config) { } var diff = e.getData().diff[0], - data = JX.Stratcom.getData(diff), - undo; + data = JX.Stratcom.getData(diff); if (data.hidden) { data.hidden = false; JX.DOM.show(diff); - undo = JX.DOM.find(diff.parentNode, - 'div', - 'differential-collapse-undo-div'); - JX.DOM.remove(undo); + JX.DOM.remove(data.undo); + data.undo = null; } else { data.hidden = true; + data.undo = render_collapse_undo(); JX.DOM.hide(diff); - undo = render_collapse_undo(); - JX.DOM.listen(undo, 'click', 'differential-collapse-undo', function(e) { - e.kill(); - data.hidden = false; - JX.DOM.show(diff); - JX.DOM.remove(undo); - }); - JX.DOM.appendContent(diff.parentNode, undo); + JX.DOM.listen( + data.undo, + 'click', + 'differential-collapse-undo', + function(e) { + e.kill(); + data.hidden = false; + JX.DOM.show(diff); + JX.DOM.remove(data.undo); + data.undo = null; + }); + JX.DOM.appendContent(diff.parentNode, data.undo); } JX.Stratcom.invoke('differential-toggle-file-toggled'); });