Commit 5067423b8c3eb4993269860c39b492a14e3d66ee
1 parent
de625053
Exists in
master
and in
23 other branches
[Mezuro] Refactoring javascripts
Showing
7 changed files
with
49 additions
and
51 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -14,4 +14,9 @@ class MezuroPluginProfileController < ProfileController |
14 | 14 | render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result } |
15 | 15 | end |
16 | 16 | |
17 | + def project_state | |
18 | + project_content = profile.articles.find(params[:id]) | |
19 | + project_content.project.state | |
20 | + end | |
21 | + | |
17 | 22 | end | ... | ... |
plugins/mezuro/lib/mezuro_plugin.rb
plugins/mezuro/public/javascripts/autoreload.js
... | ... | @@ -1,23 +0,0 @@ |
1 | -function show_autoreload($){ | |
2 | - var profile = $('#autoreload').attr('data-profile'); | |
3 | - var project = $('#autoreload').attr('data-project-id'); | |
4 | - var project_state = $('#autoreload').attr('data-project-state'); | |
5 | - var project_name = $('#autoreload').attr('data-project-name'); | |
6 | - var endpoint = '/profile/' + profile + '/plugins/mezuro/autoreload/' + project; | |
7 | - | |
8 | - jQuery('#autoreload').html('Loading results for ...' + project_name); // #FIXME | |
9 | - $.get(endpoint, {project_name: project_name}, show_page_with_results); | |
10 | - return false; | |
11 | -} | |
12 | - | |
13 | -function show_page_with_results(content){ | |
14 | - var done = true; // FIXME; test the content in some way | |
15 | - if (done) { | |
16 | - jQuery('#autoreload').html(content); | |
17 | - } else { | |
18 | - var wait = 10; // FIXME; how many seconds to wait? | |
19 | - setTimeout(function() { | |
20 | - show_autoreload(jQuery); | |
21 | - }, wait * 1000); | |
22 | - } | |
23 | -} | |
24 | 0 | \ No newline at end of file |
... | ... | @@ -0,0 +1,38 @@ |
1 | +function dynamic($) { | |
2 | + $('.module-result-link').click(show_module_result); | |
3 | +} | |
4 | + | |
5 | +function endpoint(action){ | |
6 | + var profile = jQuery('#ids').attr('data-profile'); | |
7 | + var project = jQuery('#ids').attr('data-content'); | |
8 | + return '/profile/' + profile + '/plugins/mezuro/' + action + '/' + project; | |
9 | +} | |
10 | + | |
11 | +function show_module_result(){ | |
12 | + var module_name = jQuery(this).attr('data-module-name'); | |
13 | + jQuery('#module-result').html("Loading results for " + module_name + "..."); | |
14 | + jQuery.get(endpoint('module_result'), {module_name: module_name}, show_result_table); | |
15 | + return false; | |
16 | +} | |
17 | + | |
18 | +function show_result_table(content){ | |
19 | + jQuery('#module-result').html(content); | |
20 | +} | |
21 | + | |
22 | +function show_autoreload($){ | |
23 | + jQuery('#autoreload').html('Loading results for ...' + project_name); // #FIXME | |
24 | + jQuery.get(endpoint('project_result'), {project_name: project_name}, show_page_with_results); | |
25 | + return false; | |
26 | +} | |
27 | + | |
28 | +function show_page_with_results(content){ | |
29 | + var done = true; // FIXME; test the content in some way | |
30 | + if (done) { | |
31 | + jQuery('#autoreload').html(content); | |
32 | + } else { | |
33 | + var wait = 10; // FIXME; how many seconds to wait? | |
34 | + setTimeout(function() { | |
35 | + show_autoreload(jQuery); | |
36 | + }, wait * 1000); | |
37 | + } | |
38 | +} | |
0 | 39 | \ No newline at end of file | ... | ... |
plugins/mezuro/public/javascripts/results.js
... | ... | @@ -1,21 +0,0 @@ |
1 | -function results($) { | |
2 | - $('.module-result-link').click(show_module_result); | |
3 | -} | |
4 | - | |
5 | -function show_module_result(){ | |
6 | - var profile = jQuery('#ids').attr('data-profile'); | |
7 | - var project = jQuery('#ids').attr('data-content'); | |
8 | - var module_name = jQuery(this).attr('data-module-name'); | |
9 | - var endpoint = '/profile/' + profile + '/plugins/mezuro/module_result/' + project; | |
10 | - show_loading_message(module_name); | |
11 | - jQuery.get(endpoint, {module_name: module_name}, show_result_table); | |
12 | - return false; | |
13 | -} | |
14 | - | |
15 | -function show_loading_message(module_name) { | |
16 | - jQuery('#module-result').html("Loading results for " + module_name + "..."); | |
17 | -} | |
18 | - | |
19 | -function show_result_table(content){ | |
20 | - jQuery('#module-result').html(content); | |
21 | -} | |
22 | 0 | \ No newline at end of file |
plugins/mezuro/views/content_viewer/_project_result.rhtml
plugins/mezuro/views/content_viewer/show_project.rhtml
... | ... | @@ -48,5 +48,8 @@ |
48 | 48 | <%= render :partial => 'project_result', :locals => { :project_result => @page.project_result } %> |
49 | 49 | <% end %> |
50 | 50 | |
51 | -<div id="ids" data-profile="<%= @page.profile.identifier %>" data-content='<%= @page.id %>'> | |
52 | -</div> | |
51 | +<div id="ids" data-profile="<%= @page.profile.identifier %>" data-content='<%= @page.id %>'/> | |
52 | + | |
53 | +<script type="text/javascript"> | |
54 | + jQuery(dynamic); | |
55 | +</script> | ... | ... |