Commit 6791fa1bf1ed46678d7ec6e1a21fd49f9bab0199
Committed by
Heitor
1 parent
1708d1ea
Exists in
colab
and in
4 other branches
fill_options repository form JS refactored into Branch class
Showing
2 changed files
with
12 additions
and
9 deletions
Show diff stats
app/assets/javascripts/repository/branch.js.coffee
| @@ -17,4 +17,13 @@ class Repository.Branch | @@ -17,4 +17,13 @@ class Repository.Branch | ||
| 17 | cancel_request: -> | 17 | cancel_request: -> |
| 18 | if @request != null | 18 | if @request != null |
| 19 | @request.abort() | 19 | @request.abort() |
| 20 | - @request = null | ||
| 21 | \ No newline at end of file | 20 | \ No newline at end of file |
| 21 | + @request = null | ||
| 22 | + | ||
| 23 | + # private method | ||
| 24 | + #fill_options = (options, el) -> | ||
| 25 | + fill_options: (options, el) -> | ||
| 26 | + for option in options | ||
| 27 | + do -> | ||
| 28 | + el.append($("<option></option>") | ||
| 29 | + .attr("value", option) | ||
| 30 | + .text(option)) |
app/views/repositories/_form.html.erb
| @@ -125,7 +125,7 @@ | @@ -125,7 +125,7 @@ | ||
| 125 | el.empty(); // remove old options | 125 | el.empty(); // remove old options |
| 126 | 126 | ||
| 127 | if(repository_branch.names[address] != null) { | 127 | if(repository_branch.names[address] != null) { |
| 128 | - fill_options(repository_branch.names[address], el); | 128 | + repository_branch.fill_options(repository_branch.names[address], el); |
| 129 | return; | 129 | return; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| @@ -140,16 +140,10 @@ | @@ -140,16 +140,10 @@ | ||
| 140 | options = data["branches"]; | 140 | options = data["branches"]; |
| 141 | if (options != null) { | 141 | if (options != null) { |
| 142 | repository_branch.names[address] = options; | 142 | repository_branch.names[address] = options; |
| 143 | - fill_options(options, el); | 143 | + repository_branch.fill_options(options, el); |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | })); | 146 | })); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | - function fill_options (options, el) { | ||
| 150 | - $.each(options, function(index, value) { | ||
| 151 | - el.append($("<option></option>") | ||
| 152 | - .attr("value", value).text(value)); | ||
| 153 | - }); | ||
| 154 | - } | ||
| 155 | </script> | 149 | </script> |