Commit ca225d92c38d955f3c39fd80e031396fee7723a3
1 parent
4f5aae1d
Exists in
master
and in
4 other branches
Replace inline document.ready with dispatcher
Showing
15 changed files
with
27 additions
and
28 deletions
Show diff stats
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +$ -> | ||
2 | + new Dispatcher() | ||
3 | + | ||
4 | +class Dispatcher | ||
5 | + constructor: () -> | ||
6 | + page = $('body').attr('data-page') | ||
7 | + | ||
8 | + console.log(page) | ||
9 | + | ||
10 | + switch page | ||
11 | + when 'issues:index' then Issues.init() | ||
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() |
app/helpers/application_helper.rb
@@ -189,4 +189,8 @@ module ApplicationHelper | @@ -189,4 +189,8 @@ module ApplicationHelper | ||
189 | css_class << " multiselect" if opts[:multiple] | 189 | css_class << " multiselect" if opts[:multiple] |
190 | hidden_field_tag(id, '', class: css_class) | 190 | hidden_field_tag(id, '', class: css_class) |
191 | end | 191 | end |
192 | + | ||
193 | + def body_data_page | ||
194 | + controller.controller_name + ":" + controller.action_name | ||
195 | + end | ||
192 | end | 196 | end |
app/views/dashboard/show.html.haml
app/views/groups/show.html.haml
app/views/issues/index.html.haml
app/views/layouts/admin.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: "Admin area" | 3 | = render "layouts/head", title: "Admin area" |
4 | - %body{class: "#{app_theme} admin"} | 4 | + %body{class: "#{app_theme} admin", :'data-page' => body_data_page} |
5 | = render "layouts/head_panel", title: "Admin area" | 5 | = render "layouts/head_panel", title: "Admin area" |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | %nav.main-nav | 7 | %nav.main-nav |
app/views/layouts/application.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: "Dashboard" | 3 | = render "layouts/head", title: "Dashboard" |
4 | - %body{class: "#{app_theme} application"} | 4 | + %body{class: "#{app_theme} application", :'data-page' => body_data_page } |
5 | = render "layouts/head_panel", title: "Dashboard" | 5 | = render "layouts/head_panel", title: "Dashboard" |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | %nav.main-nav | 7 | %nav.main-nav |
app/views/layouts/group.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: "#{@group.name}" | 3 | = render "layouts/head", title: "#{@group.name}" |
4 | - %body{class: "#{app_theme} application"} | 4 | + %body{class: "#{app_theme} application", :'data-page' => body_data_page} |
5 | = render "layouts/head_panel", title: "group: #{@group.name}" | 5 | = render "layouts/head_panel", title: "group: #{@group.name}" |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | %nav.main-nav | 7 | %nav.main-nav |
app/views/layouts/profile.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: "Profile" | 3 | = render "layouts/head", title: "Profile" |
4 | - %body{class: "#{app_theme} profile"} | 4 | + %body{class: "#{app_theme} profile", :'data-page' => body_data_page} |
5 | = render "layouts/head_panel", title: "Profile" | 5 | = render "layouts/head_panel", title: "Profile" |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | %nav.main-nav | 7 | %nav.main-nav |
app/views/layouts/project_resource.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: @project.name_with_namespace | 3 | = render "layouts/head", title: @project.name_with_namespace |
4 | - %body{class: "#{app_theme} project"} | 4 | + %body{class: "#{app_theme} project", :'data-page' => body_data_page} |
5 | = render "layouts/head_panel", title: project_title(@project) | 5 | = render "layouts/head_panel", title: project_title(@project) |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | - if can?(current_user, :download_code, @project) | 7 | - if can?(current_user, :download_code, @project) |
app/views/layouts/user_team.html.haml
1 | !!! 5 | 1 | !!! 5 |
2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
3 | = render "layouts/head", title: "#{@team.name}" | 3 | = render "layouts/head", title: "#{@team.name}" |
4 | - %body{class: "#{app_theme} application"} | 4 | + %body{class: "#{app_theme} application", :'data-page' => body_data_page} |
5 | = render "layouts/head_panel", title: "team: #{@team.name}" | 5 | = render "layouts/head_panel", title: "team: #{@team.name}" |
6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
7 | %nav.main-nav | 7 | %nav.main-nav |
app/views/projects/edit.html.haml
@@ -8,6 +8,3 @@ | @@ -8,6 +8,3 @@ | ||
8 | %center | 8 | %center |
9 | = image_tag "ajax_loader.gif" | 9 | = image_tag "ajax_loader.gif" |
10 | %h3 Saving project. Please wait a moment, this page will automatically refresh when ready. | 10 | %h3 Saving project. Please wait a moment, this page will automatically refresh when ready. |
11 | - | ||
12 | -:javascript | ||
13 | - $(function(){ new Projects(); }); |
app/views/projects/new.html.haml
@@ -7,6 +7,3 @@ | @@ -7,6 +7,3 @@ | ||
7 | %center | 7 | %center |
8 | = image_tag "ajax_loader.gif" | 8 | = image_tag "ajax_loader.gif" |
9 | %h3 Creating project & repository. Please wait a moment, this page will automatically refresh when ready. | 9 | %h3 Creating project & repository. Please wait a moment, this page will automatically refresh when ready. |
10 | - | ||
11 | -:javascript | ||
12 | - $(function(){ new Projects(); }); |
app/views/projects/show.html.haml
@@ -17,5 +17,3 @@ | @@ -17,5 +17,3 @@ | ||
17 | %p Repo Size: #{@project.repository.size} MB | 17 | %p Repo Size: #{@project.repository.size} MB |
18 | %p Created at: #{@project.created_at.stamp('Aug 22, 2013')} | 18 | %p Created at: #{@project.created_at.stamp('Aug 22, 2013')} |
19 | %p Owner: #{link_to @project.owner_name, @project.owner} | 19 | %p Owner: #{link_to @project.owner_name, @project.owner} |
20 | -:javascript | ||
21 | - $(function(){ Pager.init(20); }); |