Created
November 11, 2012 15:18
-
-
Save benjaminvialle/4055200 to your computer and use it in GitHub Desktop.
Diff from RB for issue 717
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/javascripts/Grader/file_selector.js b/public/javascripts/Grader/file_selector.js | |
--- a/public/javascripts/Grader/file_selector.js | |
+++ b/public/javascripts/Grader/file_selector.js | |
@@ -8,3 +8,9 @@ function bump_select(select_node, bump_amount) { | |
$(select_node).selectedIndex = result; | |
load_submitted_file($F(select_node)); | |
} | |
+ | |
+function validate_bump_buttons(bump_prev, bump_next, select) { | |
+ var fileSelect = $(select); | |
+ $(bump_prev).disabled = (fileSelect.selectedIndex == 0); | |
+ $(bump_next).disabled = (fileSelect.selectedIndex == fileSelect.length - 1); | |
+} | |
diff --git a/app/views/results/common/_file_selector.html.erb b/app/views/results/common/_file_selector.html.erb | |
--- a/app/views/results/common/_file_selector.html.erb | |
+++ b/app/views/results/common/_file_selector.html.erb | |
@@ -1,9 +1,24 @@ | |
<% # Make sure to include the public/javascripts/Grader/file_selector.js | |
# file when using this partial | |
%> | |
+ | |
+<script type="text/javascript"> | |
+function validate() | |
+{ | |
+ validate_bump_buttons('bump_prev', 'bump_next', 'select_file_id'); | |
+} | |
+ | |
+Event.observe(window, 'load', function() { | |
+ validate(); | |
+ Event.observe('select_file_id', 'change', validate); | |
+ Event.observe('bump_prev', 'click', validate); | |
+ Event.observe('bump_next', 'click', validate); | |
+}); | |
+</script> | |
+ | |
<%= form_tag({:action => "download"}, {:id => "grader_view_file_selector_form"}) do %> | |
<%= label_tag "select_file_id", I18n.t("common.submission_file"), :class => "inline_label" %> | |
- <input type="button" onclick="bump_select($('select_file_id'), -1); return false;" value="<-" /> | |
+ <input type="button" id="bump_prev" onclick="bump_select($('select_file_id'), -1); return false;" value="<-" /> | |
<select id="select_file_id" name="select_file_id" onchange="if ($(this).getValue() != '') { load_submitted_file($(this).getValue()); }"> | |
<% if files.empty? %> | |
<option value=""><%= I18n.t("common.no_file_in_repository") %></option> | |
@@ -14,7 +29,7 @@ | |
</option> | |
<% end %> | |
</select> | |
- <input type="button" onclick="bump_select($('select_file_id'), 1); return false;" value="->" /> | |
+ <input type="button" id="bump_next" onclick="bump_select($('select_file_id'), 1); return false;" value="->" /> | |
<span id="loading_code" style="display:none;"> | |
<%=image_tag('spinner.gif')%> <%= I18n.t("common.loading_code") %> | |
</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment