Commit fb8eaf514b963354c4367cc7d2851c192f18ef9d
Committed by
Heitor
1 parent
293f1ad6
Exists in
colab
and in
4 other branches
Extracted JS cancel_previous_request into a method for Brach class
Signed off by: Diego Araujo <diegoamc90@gmail.com>
Showing
2 changed files
with
7 additions
and
9 deletions
Show diff stats
app/assets/javascripts/repository/branch.js.coffee
| @@ -12,4 +12,9 @@ class Repository.Branch | @@ -12,4 +12,9 @@ class Repository.Branch | ||
| 12 | $("#branches").show() | 12 | $("#branches").show() |
| 13 | fetch_branches (document.getElementById("repository_address")) | 13 | fetch_branches (document.getElementById("repository_address")) |
| 14 | else | 14 | else |
| 15 | - $("#branches").hide() | ||
| 16 | \ No newline at end of file | 15 | \ No newline at end of file |
| 16 | + $("#branches").hide() | ||
| 17 | + | ||
| 18 | + cancel_request: -> | ||
| 19 | + if @request != null | ||
| 20 | + @request.abort() | ||
| 21 | + @request = null | ||
| 17 | \ No newline at end of file | 22 | \ No newline at end of file |
app/views/repositories/_form.html.erb
| @@ -134,7 +134,7 @@ | @@ -134,7 +134,7 @@ | ||
| 134 | <script> | 134 | <script> |
| 135 | var repository_branch = new Repository.Branch; | 135 | var repository_branch = new Repository.Branch; |
| 136 | function fetch_branches (address_field) { | 136 | function fetch_branches (address_field) { |
| 137 | - cancel_previous_request(); | 137 | + repository_branch.cancel_request(); |
| 138 | var address = address_field.value; | 138 | var address = address_field.value; |
| 139 | 139 | ||
| 140 | var el = $("#repository_branch"); | 140 | var el = $("#repository_branch"); |
| @@ -160,13 +160,6 @@ | @@ -160,13 +160,6 @@ | ||
| 160 | } | 160 | } |
| 161 | } | 161 | } |
| 162 | })); | 162 | })); |
| 163 | - | ||
| 164 | - function cancel_previous_request() { | ||
| 165 | - if (repository_branch.request != null) { | ||
| 166 | - repository_branch.request.abort(); | ||
| 167 | - repository_branch.request = null; | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | } | 163 | } |
| 171 | 164 | ||
| 172 | function fill_options (options, el) { | 165 | function fill_options (options, el) { |