summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-02 11:18:29 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-02 11:18:29 +0300
commitca225d92c38d955f3c39fd80e031396fee7723a3 (patch)
tree9c313571cd56eb6a2bf7dfc36e671a75952ead13 /app
parent4f5aae1d26ac66f8baf0574a2e457597a3e7cc33 (diff)
downloadgitlab-ce-ca225d92c38d955f3c39fd80e031396fee7723a3.tar.gz
Replace inline document.ready with dispatcher
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee17
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/views/dashboard/show.html.haml3
-rw-r--r--app/views/groups/show.html.haml3
-rw-r--r--app/views/issues/index.html.haml5
-rw-r--r--app/views/layouts/admin.html.haml2
-rw-r--r--app/views/layouts/application.html.haml2
-rw-r--r--app/views/layouts/group.html.haml2
-rw-r--r--app/views/layouts/profile.html.haml2
-rw-r--r--app/views/layouts/project_resource.html.haml2
-rw-r--r--app/views/layouts/user_team.html.haml2
-rw-r--r--app/views/projects/edit.html.haml3
-rw-r--r--app/views/projects/new.html.haml3
-rw-r--r--app/views/projects/show.html.haml2
-rw-r--r--app/views/teams/show.html.haml3
15 files changed, 27 insertions, 28 deletions
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
new file mode 100644
index 00000000000..b9e5b87d1c2
--- /dev/null
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -0,0 +1,17 @@
+$ ->
+ new Dispatcher()
+
+class Dispatcher
+ constructor: () ->
+ page = $('body').attr('data-page')
+
+ console.log(page)
+
+ 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()
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d5e94204d86..6bae21cd6d8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -189,4 +189,8 @@ module ApplicationHelper
css_class << " multiselect" if opts[:multiple]
hidden_field_tag(id, '', class: css_class)
end
+
+ def body_data_page
+ controller.controller_name + ":" + controller.action_name
+ end
end
diff --git a/app/views/dashboard/show.html.haml b/app/views/dashboard/show.html.haml
index ff2db0e3180..2305eae1f71 100644
--- a/app/views/dashboard/show.html.haml
+++ b/app/views/dashboard/show.html.haml
@@ -7,6 +7,3 @@
- else
= render "zero_authorized_projects"
-
-:javascript
- dashboardPage();
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index e90abc71c0c..1ce008f7e85 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -24,6 +24,3 @@
%hr
= render 'shared/promo'
-
-:javascript
- $(function(){ Pager.init(20, true); });
diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml
index 81777869f4a..bf33769349a 100644
--- a/app/views/issues/index.html.haml
+++ b/app/views/issues/index.html.haml
@@ -23,8 +23,3 @@
= render 'filter', entity: 'issue'
.span9.issues-holder
= render "issues"
-
-:javascript
- $(function(){
- Issues.init();
- })
diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml
index abe3f2ea854..3a23cbdb376 100644
--- a/app/views/layouts/admin.html.haml
+++ b/app/views/layouts/admin.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: "Admin area"
- %body{class: "#{app_theme} admin"}
+ %body{class: "#{app_theme} admin", :'data-page' => body_data_page}
= render "layouts/head_panel", title: "Admin area"
= render "layouts/flash"
%nav.main-nav
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 4e6831406e3..792fe5e4a28 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: "Dashboard"
- %body{class: "#{app_theme} application"}
+ %body{class: "#{app_theme} application", :'data-page' => body_data_page }
= render "layouts/head_panel", title: "Dashboard"
= render "layouts/flash"
%nav.main-nav
diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml
index 8296b8ae9a8..0e955d59ff8 100644
--- a/app/views/layouts/group.html.haml
+++ b/app/views/layouts/group.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: "#{@group.name}"
- %body{class: "#{app_theme} application"}
+ %body{class: "#{app_theme} application", :'data-page' => body_data_page}
= render "layouts/head_panel", title: "group: #{@group.name}"
= render "layouts/flash"
%nav.main-nav
diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml
index 535f94c4ef6..30a0532bc2b 100644
--- a/app/views/layouts/profile.html.haml
+++ b/app/views/layouts/profile.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: "Profile"
- %body{class: "#{app_theme} profile"}
+ %body{class: "#{app_theme} profile", :'data-page' => body_data_page}
= render "layouts/head_panel", title: "Profile"
= render "layouts/flash"
%nav.main-nav
diff --git a/app/views/layouts/project_resource.html.haml b/app/views/layouts/project_resource.html.haml
index 7b0d4789f8e..f6c5b166ed2 100644
--- a/app/views/layouts/project_resource.html.haml
+++ b/app/views/layouts/project_resource.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: @project.name_with_namespace
- %body{class: "#{app_theme} project"}
+ %body{class: "#{app_theme} project", :'data-page' => body_data_page}
= render "layouts/head_panel", title: project_title(@project)
= render "layouts/flash"
- if can?(current_user, :download_code, @project)
diff --git a/app/views/layouts/user_team.html.haml b/app/views/layouts/user_team.html.haml
index f2ead9d242a..e64e68d2446 100644
--- a/app/views/layouts/user_team.html.haml
+++ b/app/views/layouts/user_team.html.haml
@@ -1,7 +1,7 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head", title: "#{@team.name}"
- %body{class: "#{app_theme} application"}
+ %body{class: "#{app_theme} application", :'data-page' => body_data_page}
= render "layouts/head_panel", title: "team: #{@team.name}"
= render "layouts/flash"
%nav.main-nav
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index c050f9454a5..e215ad6fd73 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -8,6 +8,3 @@
%center
= image_tag "ajax_loader.gif"
%h3 Saving project. Please wait a moment, this page will automatically refresh when ready.
-
-:javascript
- $(function(){ new Projects(); });
diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml
index eb4ef5979cf..8ff873aac65 100644
--- a/app/views/projects/new.html.haml
+++ b/app/views/projects/new.html.haml
@@ -7,6 +7,3 @@
%center
= image_tag "ajax_loader.gif"
%h3 Creating project &amp; repository. Please wait a moment, this page will automatically refresh when ready.
-
-:javascript
- $(function(){ new Projects(); });
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 2fe7daf8bb1..6edfd2ed401 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -17,5 +17,3 @@
%p Repo Size: #{@project.repository.size} MB
%p Created at: #{@project.created_at.stamp('Aug 22, 2013')}
%p Owner: #{link_to @project.owner_name, @project.owner}
-:javascript
- $(function(){ Pager.init(20); });
diff --git a/app/views/teams/show.html.haml b/app/views/teams/show.html.haml
index 4b9ff61203f..2ad7f743010 100644
--- a/app/views/teams/show.html.haml
+++ b/app/views/teams/show.html.haml
@@ -23,6 +23,3 @@
%hr
= render 'shared/promo'
-
-:javascript
- $(function(){ Pager.init(20, true); });