[LON-CAPA-cvs] cvs: loncom /html/adm/help/tex Authoring_Output_Tags.tex /interface loncommon.pm /xml scripttag.pm
www
www at source.lon-capa.org
Mon Dec 19 13:00:27 EST 2011
www Mon Dec 19 18:00:27 2011 EDT
Modified files:
/loncom/html/adm/help/tex Authoring_Output_Tags.tex
/loncom/interface loncommon.pm
/loncom/xml scripttag.pm
Log:
Toggle box tag
Index: loncom/html/adm/help/tex/Authoring_Output_Tags.tex
diff -u loncom/html/adm/help/tex/Authoring_Output_Tags.tex:1.13 loncom/html/adm/help/tex/Authoring_Output_Tags.tex:1.14
--- loncom/html/adm/help/tex/Authoring_Output_Tags.tex:1.13 Fri Aug 20 14:08:07 2010
+++ loncom/html/adm/help/tex/Authoring_Output_Tags.tex Mon Dec 19 18:00:19 2011
@@ -116,7 +116,18 @@
\item \textbf{linktext} the text that should appear as the link that causes the creation of the window
\end{itemize}
-When printing, this included text will get turned into a real footnote.
+When printing, the included text will get turned into a real footnote.
+
+\item \textbf{togglebox}\index{togglebox}: This creates a toggling box that can be clicked open and close.
+
+\begin{itemize}
+\item \textbf{heading} heading text of the box, by default no heading
+\item \textbf{headerbg} background color of the header, by default white
+\item \textbf{showtext} the text that appears to make the box visible, by default the translation of 'show'
+\item \textbf{hidetext} the text that appears to hide the box again, by default the translation of 'hide'
+\end{itemize}
+
+When printing, the included text will be rendered in a visible box.
\item \textbf{m}\index{m}: The inside text is \LaTeX{}, and is converted
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1037 loncom/interface/loncommon.pm:1.1038
--- loncom/interface/loncommon.pm:1.1037 Mon Dec 12 02:46:12 2011
+++ loncom/interface/loncommon.pm Mon Dec 19 18:00:23 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1037 2011/12/12 02:46:12 www Exp $
+# $Id: loncommon.pm,v 1.1038 2011/12/19 18:00:23 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6737,6 +6737,7 @@
&& !$args->{'frameset'}) {
$result .= &help_menu_js();
$result.=&modal_window();
+ $result.=&togglebox_script();
$result.=&wishlist_window();
} else {
if ($args->{'add_modal'}) {
@@ -6745,6 +6746,9 @@
if ($args->{'add_wishlist'}) {
$result.=&wishlist_window();
}
+ if ($args->{'add_togglebox'}) {
+ $result.=&togglebox_script();
+ }
}
if (ref($args->{'redirect'})) {
my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
@@ -7053,6 +7057,27 @@
ENDADHOC
}
+sub togglebox_script {
+ return(<<ENDTOGGLE);
+<script type="text/javascript">
+// <![CDATA[
+function LCtoggleDisplay(id,hidetext,showtext) {
+ link = document.getElementById(id + "link").childNodes[0];
+ with (document.getElementById(id).style) {
+ if (display == "none" ) {
+ display = "inline";
+ link.nodeValue = hidetext;
+ } else {
+ display = "none";
+ link.nodeValue = showtext;
+ }
+ }
+}
+// ]]>
+</script>
+ENDTOGGLE
+}
+
sub modal_adhoc_window {
my ($funcname,$width,$height,$content,$linktext)=@_;
my $innerwidth=$width-20;
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.160 loncom/xml/scripttag.pm:1.161
--- loncom/xml/scripttag.pm:1.160 Mon Dec 19 01:49:32 2011
+++ loncom/xml/scripttag.pm Mon Dec 19 18:00:27 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.160 2011/12/19 01:49:32 www Exp $
+# $Id: scripttag.pm,v 1.161 2011/12/19 18:00:27 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,7 +41,7 @@
BEGIN {
&Apache::lonxml::register('Apache::scripttag',
('script','scriptlib','parserlib','import',
- 'window','display','storetc','physnet',
+ 'window','togglebox','display','storetc','physnet',
'standalone','comment','num','parse','algebra',
'LONCAPA_INTERNAL_TURN_STYLE_ON',
'LONCAPA_INTERNAL_TURN_STYLE_OFF'));
@@ -297,8 +297,7 @@
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'linktext',
- 'width','height',
- 'mimetype');
+ 'width','height');
if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
}
return $result;
@@ -327,6 +326,62 @@
return $result;
}
+
+sub start_togglebox {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result = '';
+ if ($target eq 'web' || $target eq 'webgrade') {
+ my $id="LONCAPA_togglebox_$Apache::lonxml::curdepth";
+ my $heading=&Apache::lonxml::get_param('heading',$parstack,$safeeval);
+ unless ($heading) { $heading=''; } else { $heading.=' '; }
+ my $showtext=&Apache::lonxml::get_param('showtext',$parstack,$safeeval);
+ unless ($showtext) { $showtext=&mt('show'); }
+ my $hidetext=&Apache::lonxml::get_param('hidetext',$parstack,$safeeval);
+ unless ($hidetext) { $hidetext=&mt('hide'); }
+ my $headerbg=&Apache::lonxml::get_param('headerbg',$parstack,$safeeval);
+ unless ($headerbg) { $headerbg='#FFFFFF'; }
+ $result=&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().'<td bgcolor="'.$headerbg.'">'.$heading.
+ '[<a id="'.$id.'link" href="javascript:LCtoggleDisplay(\''.$id.'\',\''.$hidetext.'\',\''.
+ $showtext.'\')">'.$showtext.'</a>]</td>'.
+ &Apache::loncommon::end_data_table_header_row().
+ '<tr id="'.$id.'" style="display:none""><td>';
+ } elsif ($target eq 'tex') {
+ my $heading=&Apache::lonxml::get_param('heading',$parstack,$safeeval);
+ unless ($heading) { $heading=''; } else { $heading.=' '; }
+ $result = "\n\n".'\fbox{{\bf '.$heading.'} \qquad '."\n";
+ } elsif ($target eq 'edit') {
+ $result.=&Apache::edit::tag_start($target,$token);
+ $result.=&Apache::edit::text_arg('Heading:','heading',$token,70);
+ $result.=&Apache::edit::text_arg('Header Background:','headerbg',$token,7);
+ $result.=&Apache::edit::text_arg('Show text:','showtext',$token,10);
+ $result.=&Apache::edit::text_arg('Hide text:','hidetext',$token,10);
+ $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,
+ $safeeval,'heading',
+ 'showtext','hidetext',
+ 'headerbg','textbg');
+ if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
+ }
+ return $result;
+}
+
+sub end_togglebox {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result;
+ if ($target eq 'web' || $target eq 'webgrade') {
+ $result='</td></tr>'.&Apache::loncommon::end_data_table();
+ } elsif ($target eq 'tex') {
+ $result = "}\n\n";
+ } else {
+ $result = '';
+ }
+ return $result;
+}
+
+
+
sub start_import {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $bodytext=$$parser[$#$parser]->get_text("/import");
More information about the LON-CAPA-cvs
mailing list