[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /xml scripttag.pm
raeburn
raeburn at source.lon-capa.org
Wed Sep 14 10:55:07 EDT 2016
raeburn Wed Sep 14 14:55:07 2016 EDT
Modified files: (Branch: version_2_11_X)
/loncom/xml scripttag.pm
Log:
- For 2.11
- Backport 1.173.
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.172.2.1 loncom/xml/scripttag.pm:1.172.2.2
--- loncom/xml/scripttag.pm:1.172.2.1 Mon Apr 6 16:55:46 2015
+++ loncom/xml/scripttag.pm Wed Sep 14 14:55:06 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.172.2.1 2015/04/06 16:55:46 raeburn Exp $
+# $Id: scripttag.pm,v 1.172.2.2 2016/09/14 14:55:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -120,7 +120,40 @@
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
$result=&Apache::edit::tag_start($target,$token,'Script');
- $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+
+ my $depth = $Apache::lonxml::curdepth;
+ $result.='<span id="LC_edit_problem_codemirror">';
+ unless ($env{'environment.nocodemirror'}) {
+ # only show button if codemirror activated
+ $result.='<input type="button" id="fitsize'.$depth.'" value="'.&mt("Dynamic size").
+ '" onclick="autosize(\''.$depth.'\')" />';
+ }
+ $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4).'</span>';
+
+ unless ($env{'environment.nocodemirror'}) {
+ $result.='<script type="text/javascript">
+ var cm'.$depth.' = CodeMirror.fromTextArea(document.getElementById("homework_edit_'.$depth.'"),
+ {
+ mode: "perl",
+ lineWrapping: true,
+ lineNumbers: true,
+ tabSize: 4,
+ indentUnit: 4,
+ autoCloseBrackets: true,
+ styleActiveLine: true,
+
+ extraKeys: {
+ "Tab": "indentMore",
+ "Shift-Tab": "indentLess"
+ }
+ });
+ if(sessionStorage.getItem("autosized_'.$depth.'") != null) {
+ document.getElementById("fitsize'.$depth.'").value = "'.&mt("Fixed size").'";
+ cm'.$depth.'.setSize("","auto");
+ }
+ </script>';
+ }
+
} elsif ($target eq 'meta') {
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
}
More information about the LON-CAPA-cvs
mailing list