Clear the patch filter when hidden, if it contained anything
authorMagnus Hagander <magnus@hagander.net>
Tue, 15 Jul 2014 10:05:47 +0000 (12:05 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 15 Jul 2014 10:05:47 +0000 (12:05 +0200)
pgcommitfest/commitfest/static/commitfest/js/commitfest.js
pgcommitfest/commitfest/templates/commitfest.html

index 579ad1840cb1bdbdc131f32924adb1f5fb45ac5a..0ca6316ff60b681110b9f9cbb90b47529204c4fb 100644 (file)
@@ -129,3 +129,16 @@ function toggleButtonCollapse(buttonId, collapseId) {
    $('#' + buttonId).button('toggle');
    $('#' + collapseId).toggleClass('in')
 }
+
+function togglePatchFilterButton(buttonId, collapseId) {
+   /* Figure out if we are collapsing it */
+   if ($('#' + collapseId).hasClass('in')) {
+       /* Go back to ourselves without a querystring to reset the form, unless it's already empty */
+       if (document.location.href.indexOf('?') > -1) {
+          document.location.href = '.';
+          return;
+       }
+   }
+
+   toggleButtonCollapse(buttonId, collapseId);
+}
index b0849628abbf3831daa5fe41d1b17b0c5b651f38..4896e7156fb29e578f709e0fc9e504401fb404d3 100644 (file)
@@ -2,7 +2,7 @@
 {%load commitfest %}
 {%block contents%}
 
-<button type="button" class="btn btn-default{%if has_filter%} active{%endif%}" id="filterButton" onClick="toggleButtonCollapse('filterButton', 'collapseFilters')">Search/filter</button>
+<button type="button" class="btn btn-default{%if has_filter%} active{%endif%}" id="filterButton" onClick="togglePatchFilterButton('filterButton', 'collapseFilters')">Search/filter</button>
 <div class="btn-group">
   <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">Shortcuts <span class="caret"></span></a>
   <ul class="dropdown-menu">