Commit 466a15b467531324469690c6e7aa98e3945d6383
Committed by
Heitor
1 parent
55d11857
Exists in
colab
and in
4 other branches
Repository.Branch JS using full JQuery potential
Showing
2 changed files
with
5 additions
and
10 deletions
Show diff stats
app/assets/javascripts/repository/branch.js.coffee
@@ -4,13 +4,9 @@ class Repository.Branch | @@ -4,13 +4,9 @@ class Repository.Branch | ||
4 | @request = null | 4 | @request = null |
5 | 5 | ||
6 | toggle: -> | 6 | toggle: -> |
7 | - scm_type_field = document.getElementById("repository_scm_type") | ||
8 | - index = scm_type_field.selectedIndex | ||
9 | - option = scm_type_field.options[index] | ||
10 | - | ||
11 | - if option.value != "SVN" | 7 | + if $("#repository_scm_type").val() != "SVN" |
12 | $("#branches").show() | 8 | $("#branches").show() |
13 | - @fetch(document.getElementById("repository_address")) | 9 | + @fetch($("#repository_address").val()) |
14 | else | 10 | else |
15 | $("#branches").hide() | 11 | $("#branches").hide() |
16 | 12 | ||
@@ -32,9 +28,8 @@ class Repository.Branch | @@ -32,9 +28,8 @@ class Repository.Branch | ||
32 | .attr("value", option) | 28 | .attr("value", option) |
33 | .text(option)) | 29 | .text(option)) |
34 | 30 | ||
35 | - fetch: (address_field) -> | 31 | + fetch: (address) -> |
36 | @cancel_request() | 32 | @cancel_request() |
37 | - address = address_field.value | ||
38 | 33 | ||
39 | # Prevent a call with blank address | 34 | # Prevent a call with blank address |
40 | if address == "" | 35 | if address == "" |
@@ -47,7 +42,7 @@ class Repository.Branch | @@ -47,7 +42,7 @@ class Repository.Branch | ||
47 | @fill_options(@names[address], el) | 42 | @fill_options(@names[address], el) |
48 | return | 43 | return |
49 | 44 | ||
50 | - scm_type = $("#repository_scm_type option:selected").text() | 45 | + scm_type = $("#repository_scm_type").val() |
51 | 46 | ||
52 | context = this | 47 | context = this |
53 | @request = $.get '/repository_branches', | 48 | @request = $.get '/repository_branches', |
app/views/repositories/_form.html.erb
@@ -55,7 +55,7 @@ | @@ -55,7 +55,7 @@ | ||
55 | <div class="form-row"> | 55 | <div class="form-row"> |
56 | <div class="field-container"> | 56 | <div class="field-container"> |
57 | <%= f.label :address, class: 'control-label' %> | 57 | <%= f.label :address, class: 'control-label' %> |
58 | - <%= f.text_field :address, :required => true, class: 'text-field form-control', onchange: "_repository_branch.fetch(this);" %> | 58 | + <%= f.text_field :address, :required => true, class: 'text-field form-control', onchange: "_repository_branch.fetch(this.value);" %> |
59 | </div> | 59 | </div> |
60 | <div class="help-container"> | 60 | <div class="help-container"> |
61 | <p> | 61 | <p> |