[gitg/wip/patch-stage: 3/11] Move expand/collapse in separate function



commit e747a32400bc8545121afbabea0ce2d72230945c
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Dec 28 15:50:22 2013 +0100

    Move expand/collapse in separate function

 libgitg/resources/diff-view.js |   42 ++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index d77b75a..0b7054b 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -123,6 +123,27 @@ function write_commit(commit)
 var html_builder_worker = 0;
 var html_builder_tick = 0;
 
+function expand_collapse()
+{
+       var expander = $(this);
+
+       // If expanded, will be true
+       var toExpand = expander.text() == "+";
+
+       if (toExpand)
+       {
+               // next step to close it
+               expander.text("-");
+       }
+       else
+       {
+               // next step is to open it
+               expander.text("+");
+       }
+
+       expander.closest('tbody').toggleClass("collapsed");
+}
+
 function update_diff(id, lsettings)
 {
        if (html_builder_worker)
@@ -192,26 +213,7 @@ function update_diff(id, lsettings)
 
                        content.html(event.data.diff_html);
 
-                       $(".expander").click(function()
-                       {
-                               var expander = $(this);
-
-                               // If expanded, will be true
-                               var toExpand = expander.text() == "+";
-
-                               if (toExpand)
-                               {
-                                       // next step to close it
-                                       expander.text("-");
-                               }
-                               else
-                               {
-                                       // next step is to open it
-                                       expander.text("+");
-                               }
-
-                               expander.closest('tbody').toggleClass("collapsed");
-                       });
+                       $(".expander").click(expand_collapse);
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]