Commit 2aa620c25ad2c6386bd454b9678d852ee55e83f8
1 parent
6473aaf8
Exists in
master
and in
4 other branches
move more inline js to handle via dispatcher
Showing
9 changed files
with
46 additions
and
63 deletions
Show diff stats
app/assets/javascripts/admin.js.coffee
| 1 | -$ -> | |
| 2 | - $('input#user_force_random_password').on 'change', (elem) -> | |
| 3 | - elems = $('#user_password, #user_password_confirmation') | |
| 1 | +@Admin = | |
| 2 | + init: -> | |
| 3 | + $('input#user_force_random_password').on 'change', (elem) -> | |
| 4 | + elems = $('#user_password, #user_password_confirmation') | |
| 4 | 5 | |
| 5 | - if $(@).attr 'checked' | |
| 6 | - elems.val('').attr 'disabled', true | |
| 7 | - else | |
| 8 | - elems.removeAttr 'disabled' | |
| 6 | + if $(@).attr 'checked' | |
| 7 | + elems.val('').attr 'disabled', true | |
| 8 | + else | |
| 9 | + elems.removeAttr 'disabled' | |
| 9 | 10 | |
| 10 | - $('.log-tabs a').click (e) -> | |
| 11 | - e.preventDefault() | |
| 12 | - $(this).tab('show') | |
| 11 | + $('.log-tabs a').click (e) -> | |
| 12 | + e.preventDefault() | |
| 13 | + $(this).tab('show') | |
| 13 | 14 | |
| 14 | - $('.log-bottom').click (e) -> | |
| 15 | - e.preventDefault() | |
| 16 | - visible_log = $(".file_content:visible") | |
| 17 | - visible_log.animate({ scrollTop: visible_log.find('ol').height() }, "fast") | |
| 15 | + $('.log-bottom').click (e) -> | |
| 16 | + e.preventDefault() | |
| 17 | + visible_log = $(".file_content:visible") | |
| 18 | + visible_log.animate({ scrollTop: visible_log.find('ol').height() }, "fast") | |
| 19 | + | |
| 20 | + modal = $('.change-owner-holder') | |
| 21 | + | |
| 22 | + $('.change-owner-link').bind "click", -> | |
| 23 | + $(this).hide() | |
| 24 | + modal.show() | |
| 25 | + | |
| 26 | + $('.change-owner-cancel-link').bind "click", -> | |
| 27 | + modal.hide() | |
| 28 | + $('.change-owner-link').show() | ... | ... |
app/assets/javascripts/dispatcher.js.coffee
| ... | ... | @@ -10,8 +10,10 @@ class Dispatcher |
| 10 | 10 | switch page |
| 11 | 11 | when 'issues:index' then Issues.init() |
| 12 | 12 | when 'dashboard:show' then dashboardPage() |
| 13 | - when 'groups:show' then Pager.init(20, true) | |
| 14 | - when 'teams:show' then Pager.init(20, true) | |
| 15 | - when 'projects:show' then Pager.init(20, true) | |
| 16 | - when 'projects:new' then new Projects() | |
| 17 | - when 'projects:edit' then new Projects() | |
| 13 | + when 'commit:show' then Commit.init() | |
| 14 | + when 'groups:show', 'teams:show', 'projects:show' | |
| 15 | + Pager.init(20, true) | |
| 16 | + when 'projects:new', 'projects:edit' | |
| 17 | + new Projects() | |
| 18 | + when 'admin:teams:show', 'admin:groups:show', 'admin:logs:show', 'admin:users:new' | |
| 19 | + Admin.init() | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -191,6 +191,9 @@ module ApplicationHelper |
| 191 | 191 | end |
| 192 | 192 | |
| 193 | 193 | def body_data_page |
| 194 | - controller.controller_name + ":" + controller.action_name | |
| 194 | + path = controller.controller_path.split('/') | |
| 195 | + namespace = path.first if path.second | |
| 196 | + | |
| 197 | + [namespace, controller.controller_name, controller.action_name].compact.join(":") | |
| 195 | 198 | end |
| 196 | 199 | end | ... | ... |
app/views/admin/groups/show.html.haml
| ... | ... | @@ -118,16 +118,3 @@ |
| 118 | 118 | .form-actions |
| 119 | 119 | = submit_tag 'Move projects', class: "btn btn-create" |
| 120 | 120 | |
| 121 | -:javascript | |
| 122 | - $(function(){ | |
| 123 | - var modal = $('.change-owner-holder'); | |
| 124 | - $('.change-owner-link').bind("click", function(){ | |
| 125 | - $(this).hide(); | |
| 126 | - modal.show(); | |
| 127 | - }); | |
| 128 | - $('.change-owner-cancel-link').bind("click", function(){ | |
| 129 | - modal.hide(); | |
| 130 | - $('.change-owner-link').show(); | |
| 131 | - }) | |
| 132 | - }) | |
| 133 | - | ... | ... |
app/views/admin/teams/show.html.haml
| ... | ... | @@ -91,17 +91,3 @@ |
| 91 | 91 | = link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn btn-small" |
| 92 | 92 | |
| 93 | 93 | = link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn btn-remove small", id: "relegate_project_#{project.id}" |
| 94 | - | |
| 95 | -:javascript | |
| 96 | - $(function(){ | |
| 97 | - var modal = $('.change-owner-holder'); | |
| 98 | - $('.change-owner-link').bind("click", function(){ | |
| 99 | - $(this).hide(); | |
| 100 | - modal.show(); | |
| 101 | - }); | |
| 102 | - $('.change-owner-cancel-link').bind("click", function(){ | |
| 103 | - modal.hide(); | |
| 104 | - $('.change-owner-link').show(); | |
| 105 | - }) | |
| 106 | - }) | |
| 107 | - | ... | ... |
app/views/commit/show.html.haml
app/views/commits/show.html.haml
app/views/repositories/stats.html.haml
| ... | ... | @@ -27,9 +27,7 @@ |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | :javascript |
| 30 | - $(function(){ | |
| 31 | - var labels = [#{@graph.labels.to_json}]; | |
| 32 | - var commits = [#{@graph.commits.join(', ')}]; | |
| 33 | - var title = "Commit activity for last #{@graph.weeks} weeks"; | |
| 34 | - Chart.init(labels, commits, title); | |
| 35 | - }) | |
| 30 | + var labels = [#{@graph.labels.to_json}]; | |
| 31 | + var commits = [#{@graph.commits.join(', ')}]; | |
| 32 | + var title = "Commit activity for last #{@graph.weeks} weeks"; | |
| 33 | + Chart.init(labels, commits, title); | ... | ... |