[LON-CAPA-cvs] cvs: loncom(version_2_11_donebutton) /homework lonhomework.pm /interface lonmenu.pm
musolffc
musolffc at source.lon-capa.org
Tue Apr 14 17:35:56 EDT 2015
musolffc Tue Apr 14 21:35:56 2015 EDT
Modified files: (Branch: version_2_11_donebutton)
/loncom/interface lonmenu.pm
/loncom/homework lonhomework.pm
Log:
Changes to "done button"
Confirmation box is now a jQuerey dialog widget. The button is only
displayed during timed events, i.e. when the "interval" parameter is set.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.431.2.1 loncom/interface/lonmenu.pm:1.431.2.2
--- loncom/interface/lonmenu.pm:1.431.2.1 Tue Mar 3 16:53:59 2015
+++ loncom/interface/lonmenu.pm Tue Apr 14 21:35:52 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.431.2.1 2015/03/03 16:53:59 musolffc Exp $
+# $Id: lonmenu.pm,v 1.431.2.2 2015/04/14 21:35:52 musolffc Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1533,13 +1533,46 @@
return;
}
-function zeroTimer() {
- if (confirm('Are you sure?')) {
- document.getElementsByName('done')[0].value = 'true';
- document.getElementsByName('doneButton')[0].submit();
- }
+END
}
+# This creates a "done button" for timed events. The confirmation box is a jQuerey
+# dialog widget. Clicking OK will set (done = 'true') which is checked in
+# lonhomework.pm.
+sub done_button_js {
+ return <<END;
+
+<form method="post" name="doneButton">
+ <input type="hidden" name="done" value=""/>
+ <button id="done-confirm-opener" type="button">Done</button>
+</form>
+
+<div id="done-confirm" title="WARNING!">
+ <p></span>You are trying to end this timed event early. Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder. Click "OK" if you are completely finished. Click "Cancel" to continue working.</p>
+</div>
+
+<script>
+\$( "#done-confirm" ).dialog({ autoOpen: false });
+\$( "#done-confirm-opener" ).click(function() {
+ \$( "#done-confirm" ).dialog( "open" );
+ \$( "#done-confirm" ).dialog({
+ resizable: false,
+ height:320,
+ modal: true,
+ buttons: {
+ "OK": function() {
+ \$( this ).dialog( "close" );
+ \$( '[name="done"]' )[0].value = 'true';
+ \$( '[name="doneButton"]' )[0].submit();
+ },
+ Cancel: function() {
+ \$( this ).dialog( "close" );
+ }
+ }
+ })
+});
+</script>
+
END
}
@@ -2218,11 +2251,14 @@
if (($duedate && $duedate > time) ||
(!$duedate && $hastimeleft) ||
($slot_name ne '' && $slothastime)) {
- my ($collapse,$expand,$alttxt,$title,$currdisp);
+ my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton);
if ((@interval > 1 && $hastimeleft) ||
($type eq 'Task' && $slothastime)) {
$currdisp = 'inline';
$collapse = '► ';
+ $donebutton = &done_button_js();
+
+
} else {
$currdisp = 'none';
$expand = '◄ ';
@@ -2232,6 +2268,7 @@
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <<END;
<a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
@@ -2242,10 +2279,7 @@
<a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
<span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
<img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
-<form method="post" name="doneButton">
-<input type="hidden" name="done" value=""/>
-<button type="button" onclick="zeroTimer()">Done</button>
-</form>
+$donebutton
END
}
}
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.349.2.1 loncom/homework/lonhomework.pm:1.349.2.2
--- loncom/homework/lonhomework.pm:1.349.2.1 Tue Mar 3 16:54:03 2015
+++ loncom/homework/lonhomework.pm Tue Apr 14 21:35:56 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.349.2.1 2015/03/03 16:54:03 musolffc Exp $
+# $Id: lonhomework.pm,v 1.349.2.2 2015/04/14 21:35:56 musolffc Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1332,8 +1332,7 @@
}
# Sets timer to zero for the entire folder containing the current resource for the
-# current user. This is called by the done button and the javascript function
-# zeroTimer() in lonmenu.pm
+# current user.
sub zero_timer {
my $symb = shift;
my $first_access = &Apache::lonnet::get_first_access("map",$symb);
@@ -1349,7 +1348,8 @@
my ($symb) = &Apache::lonnet::whichuser();
- # Set the event timer to zero if the "done button" was clicked.
+ # Set the event timer to zero if the "done button" was clicked. The button is
+ # part of the doneButton form created in lonmenu.pm
if ($env{"form.done"} eq "true") {
&zero_timer($symb);
$env{"form.done"} = "";
More information about the LON-CAPA-cvs
mailing list