summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-02 11:46:45 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-02 11:46:45 +0300
commit2aa620c25ad2c6386bd454b9678d852ee55e83f8 (patch)
treea6bcbabfe511da1ee4bd703ec2b70564d7441d91 /app
parent6473aaf8777f15c0bf247f509fab5e3f978af1c7 (diff)
downloadgitlab-ce-2aa620c25ad2c6386bd454b9678d852ee55e83f8.tar.gz
move more inline js to handle via dispatcher
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/admin.js.coffee39
-rw-r--r--app/assets/javascripts/commit.js.coffee5
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee12
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--app/views/admin/groups/show.html.haml13
-rw-r--r--app/views/admin/teams/show.html.haml14
-rw-r--r--app/views/commit/show.html.haml7
-rw-r--r--app/views/commits/show.html.haml4
-rw-r--r--app/views/repositories/stats.html.haml10
9 files changed, 46 insertions, 63 deletions
diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee
index 1dafdf4bd8b..8329673258f 100644
--- a/app/assets/javascripts/admin.js.coffee
+++ b/app/assets/javascripts/admin.js.coffee
@@ -1,17 +1,28 @@
-$ ->
- $('input#user_force_random_password').on 'change', (elem) ->
- elems = $('#user_password, #user_password_confirmation')
+@Admin =
+ init: ->
+ $('input#user_force_random_password').on 'change', (elem) ->
+ elems = $('#user_password, #user_password_confirmation')
- if $(@).attr 'checked'
- elems.val('').attr 'disabled', true
- else
- elems.removeAttr 'disabled'
+ if $(@).attr 'checked'
+ elems.val('').attr 'disabled', true
+ else
+ elems.removeAttr 'disabled'
- $('.log-tabs a').click (e) ->
- e.preventDefault()
- $(this).tab('show')
+ $('.log-tabs a').click (e) ->
+ e.preventDefault()
+ $(this).tab('show')
- $('.log-bottom').click (e) ->
- e.preventDefault()
- visible_log = $(".file_content:visible")
- visible_log.animate({ scrollTop: visible_log.find('ol').height() }, "fast")
+ $('.log-bottom').click (e) ->
+ e.preventDefault()
+ visible_log = $(".file_content:visible")
+ visible_log.animate({ scrollTop: visible_log.find('ol').height() }, "fast")
+
+ modal = $('.change-owner-holder')
+
+ $('.change-owner-link').bind "click", ->
+ $(this).hide()
+ modal.show()
+
+ $('.change-owner-cancel-link').bind "click", ->
+ modal.hide()
+ $('.change-owner-link').show()
diff --git a/app/assets/javascripts/commit.js.coffee b/app/assets/javascripts/commit.js.coffee
new file mode 100644
index 00000000000..42af060a58e
--- /dev/null
+++ b/app/assets/javascripts/commit.js.coffee
@@ -0,0 +1,5 @@
+@Commit =
+ init: ->
+ $('.files .file').each ->
+ new CommitFile(this)
+
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index b9e5b87d1c2..cb48fff02e3 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -10,8 +10,10 @@ class Dispatcher
switch page
when 'issues:index' then Issues.init()
when 'dashboard:show' then dashboardPage()
- when 'groups:show' then Pager.init(20, true)
- when 'teams:show' then Pager.init(20, true)
- when 'projects:show' then Pager.init(20, true)
- when 'projects:new' then new Projects()
- when 'projects:edit' then new Projects()
+ when 'commit:show' then Commit.init()
+ when 'groups:show', 'teams:show', 'projects:show'
+ Pager.init(20, true)
+ when 'projects:new', 'projects:edit'
+ new Projects()
+ when 'admin:teams:show', 'admin:groups:show', 'admin:logs:show', 'admin:users:new'
+ Admin.init()
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6bae21cd6d8..703c88975a3 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -191,6 +191,9 @@ module ApplicationHelper
end
def body_data_page
- controller.controller_name + ":" + controller.action_name
+ path = controller.controller_path.split('/')
+ namespace = path.first if path.second
+
+ [namespace, controller.controller_name, controller.action_name].compact.join(":")
end
end
diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml
index e73321a5bab..0e2e144d326 100644
--- a/app/views/admin/groups/show.html.haml
+++ b/app/views/admin/groups/show.html.haml
@@ -118,16 +118,3 @@
.form-actions
= submit_tag 'Move projects', class: "btn btn-create"
-:javascript
- $(function(){
- var modal = $('.change-owner-holder');
- $('.change-owner-link').bind("click", function(){
- $(this).hide();
- modal.show();
- });
- $('.change-owner-cancel-link').bind("click", function(){
- modal.hide();
- $('.change-owner-link').show();
- })
- })
-
diff --git a/app/views/admin/teams/show.html.haml b/app/views/admin/teams/show.html.haml
index abdfada8c5e..bd4d90b607f 100644
--- a/app/views/admin/teams/show.html.haml
+++ b/app/views/admin/teams/show.html.haml
@@ -91,17 +91,3 @@
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn btn-small"
&nbsp;
= 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}"
-
-:javascript
- $(function(){
- var modal = $('.change-owner-holder');
- $('.change-owner-link').bind("click", function(){
- $(this).hide();
- modal.show();
- });
- $('.change-owner-cancel-link').bind("click", function(){
- modal.hide();
- $('.change-owner-link').show();
- })
- })
-
diff --git a/app/views/commit/show.html.haml b/app/views/commit/show.html.haml
index 48fb44a99d5..6cb1a6905ca 100644
--- a/app/views/commit/show.html.haml
+++ b/app/views/commit/show.html.haml
@@ -9,10 +9,3 @@
= render "commits/diffs", diffs: @commit.diffs
= render "notes/notes_with_form"
-
-:javascript
- $(function(){
- $('.files .file').each(function(){
- new CommitFile(this);
- });
- });
diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml
index 586b21dfa5d..cb9ef820d3e 100644
--- a/app/views/commits/show.html.haml
+++ b/app/views/commits/show.html.haml
@@ -11,7 +11,5 @@
- if @commits.count == @limit
:javascript
- $(function(){
- CommitsList.init("#{@ref}", #{@limit});
- });
+ CommitsList.init("#{@ref}", #{@limit});
diff --git a/app/views/repositories/stats.html.haml b/app/views/repositories/stats.html.haml
index d448c669271..6d1fb4686ea 100644
--- a/app/views/repositories/stats.html.haml
+++ b/app/views/repositories/stats.html.haml
@@ -27,9 +27,7 @@
:javascript
- $(function(){
- var labels = [#{@graph.labels.to_json}];
- var commits = [#{@graph.commits.join(', ')}];
- var title = "Commit activity for last #{@graph.weeks} weeks";
- Chart.init(labels, commits, title);
- })
+ var labels = [#{@graph.labels.to_json}];
+ var commits = [#{@graph.commits.join(', ')}];
+ var title = "Commit activity for last #{@graph.weeks} weeks";
+ Chart.init(labels, commits, title);