Commit 466a15b467531324469690c6e7aa98e3945d6383

Authored by Rafael Manzo
Committed by Heitor
1 parent 55d11857

Repository.Branch JS using full JQuery potential

app/assets/javascripts/repository/branch.js.coffee
... ... @@ -4,13 +4,9 @@ class Repository.Branch
4 4 @request = null
5 5  
6 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 8 $("#branches").show()
13   - @fetch(document.getElementById("repository_address"))
  9 + @fetch($("#repository_address").val())
14 10 else
15 11 $("#branches").hide()
16 12  
... ... @@ -32,9 +28,8 @@ class Repository.Branch
32 28 .attr("value", option)
33 29 .text(option))
34 30  
35   - fetch: (address_field) ->
  31 + fetch: (address) ->
36 32 @cancel_request()
37   - address = address_field.value
38 33  
39 34 # Prevent a call with blank address
40 35 if address == ""
... ... @@ -47,7 +42,7 @@ class Repository.Branch
47 42 @fill_options(@names[address], el)
48 43 return
49 44  
50   - scm_type = $("#repository_scm_type option:selected").text()
  45 + scm_type = $("#repository_scm_type").val()
51 46  
52 47 context = this
53 48 @request = $.get '/repository_branches',
... ...
app/views/repositories/_form.html.erb
... ... @@ -55,7 +55,7 @@
55 55 <div class="form-row">
56 56 <div class="field-container">
57 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 59 </div>
60 60 <div class="help-container">
61 61 <p>
... ...