[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm /xml lonxml.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 10 Oct 2007 00:02:28 -0000
albertel Tue Oct 9 20:02:28 2007 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm
/loncom/xml lonxml.pm
Log:
- switch to using fckeditor rather than html area
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.166 loncom/interface/lonhtmlcommon.pm:1.167
--- loncom/interface/lonhtmlcommon.pm:1.166 Wed Oct 3 21:16:58 2007
+++ loncom/interface/lonhtmlcommon.pm Tue Oct 9 20:02:19 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.166 2007/10/04 01:16:58 banghart Exp $
+# $Id: lonhtmlcommon.pm,v 1.167 2007/10/10 00:02:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1101,46 +1101,13 @@
}
sub htmlareaheaders {
- if (&htmlareablocked()) { return ''; }
- unless (&htmlareabrowser()) { return ''; }
- my $lang='en';
- if (&mt('htmlarea_lang') ne 'htmlarea_lang') {
- $lang=&mt('htmlarea_lang');
- }
+ return if (&htmlareablocked());
+ return if (!&htmlareabrowser());
return (<<ENDHEADERS);
-<script type="text/javascript">
-_editor_url='/htmlarea/';
-_editor_lang='$lang';
-</script>
-<script type="text/javascript" src="/htmlarea/htmlarea.js"></script>
-<link rel="stylesheet" type="text/css" href="/htmlarea/htmlarea.css" />
+<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
ENDHEADERS
}
-# ------------------------------------------------- Activate additional buttons
-
-sub htmlareaaddbuttons {
- if (&htmlareablocked()) { return ''; }
- unless (&htmlareabrowser()) { return ''; }
- return (<<ENDADDBUTTON);
- var config=new HTMLArea.Config();
- config.registerButton('ed_math','LaTeX Inline',
- '/htmlarea/images/ed_math.gif',false,
- function(editor,id) {
- editor.surroundHTML(' <m>\$','\$</m> ');
- }
- );
- config.registerButton('ed_math_eqn','LaTeX Equation',
- '/htmlarea/images/ed_math_eqn.gif',false,
- function(editor,id) {
- editor.surroundHTML(
- ' \\n<center><m>\\\\[','\\\\]</m></center>\\n ');
- }
- );
- config.toolbar.push(['ed_math','ed_math_eqn']);
-ENDADDBUTTON
-}
-
# ----------------------------------------------------------------- Preferences
sub disablelink {
@@ -1159,16 +1126,33 @@
return '<a href="'.&HTML::Entities::encode('/adm/preferences?action=set_wysiwyg&wysiwyg=on&returnurl=','<>&"').&escape($ENV{'REQUEST_URI'}).'">'.&mt('Enable WYSIWYG Editor').'</a>';
}
+# ------------------------------------------------- lang to use in html editor
+sub htmlarea_lang {
+ my $lang='en';
+ if (&mt('htmlarea_lang') ne 'htmlarea_lang') {
+ $lang=&mt('htmlarea_lang');
+ }
+ return $lang;
+}
+
# ----------------------------------------- Script to activate only some fields
sub htmlareaselectactive {
my @fields=@_;
unless (&htmlareabrowser()) { return ''; }
if (&htmlareablocked()) { return '<br />'.&enablelink(@fields); }
- my $output='<script type="text/javascript" defer="1">'.
- &htmlareaaddbuttons();
- foreach(@fields) {
- $output.="\nHTMLArea.replace('$_',config);";
+ my $output='<script type="text/javascript" defer="1">';
+ my $lang = &htmlarea_lang();
+ foreach my $field (@fields) {
+ $output.="
+{
+ var oFCKeditor = new FCKeditor('$field');
+ oFCKeditor.Config['CustomConfigurationsPath'] =
+ '/fckeditor/loncapaconfig.js';
+ oFCKeditor.ReplaceTextarea();
+ oFCKeditor.Config['AutoDetectLanguage'] = false;
+ oFCKeditor.Config['DefaultLanguage'] = '$lang';
+}";
}
$output.="\nwindow.status='Activated Editfields';\n</script><br />".
&disablelink(@fields);
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.462 loncom/xml/lonxml.pm:1.463
--- loncom/xml/lonxml.pm:1.462 Mon Oct 8 05:20:22 2007
+++ loncom/xml/lonxml.pm Tue Oct 9 20:02:27 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.462 2007/10/08 09:20:22 foxr Exp $
+# $Id: lonxml.pm,v 1.463 2007/10/10 00:02:27 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1464,29 +1464,31 @@
my $initialize='';
my $textarea_id = 'filecont';
my ($add_to_onload, $add_to_onresize);
- my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons();
$initialize=&Apache::lonhtmlcommon::spellheader();
if ($filetype eq 'html'
&& (!&Apache::lonhtmlcommon::htmlareablocked() &&
&Apache::lonhtmlcommon::htmlareabrowser())) {
- $textarea_id .= '_htmlarea';
+ $textarea_id .= '___Frame';
+ my $lang = &Apache::lonhtmlcommon::htmlarea_lang();
$initialize.=(<<FULLPAGE);
<script type="text/javascript">
-$addbuttons
-
- HTMLArea.loadPlugin("FullPage");
-
+lonca
function initDocument() {
- var editor=new HTMLArea("filecont",config);
- editor.registerPlugin(FullPage);
- editor.generate();
- setTimeout(
- function () {
- HTMLArea._addEvents(editor._doc,
- ["keypress","mousedown"], unClean);
- editor._iframe.id = '$textarea_id';
- resize_textarea('$textarea_id','LC_aftertextarea');
- },300);
+ var oFCKeditor = new FCKeditor('filecont');
+ oFCKeditor.Config['CustomConfigurationsPath'] = '/fckeditor/loncapaconfig.js' ;
+ oFCKeditor.Config['FullPage'] = true
+ oFCKeditor.Config['AutoDetectLanguage'] = false;
+ oFCKeditor.Config['DefaultLanguage'] = "$lang";
+ oFCKeditor.ReplaceTextarea();
+ }
+ function check_if_dirty(editor) {
+ if (editor.IsDirty()) {
+ unClean();
+ }
+ }
+ function FCKeditor_OnComplete(editor) {
+ editor.Events.AttachEvent("OnSelectionChange",check_if_dirty);
+ resize_textarea('$textarea_id','LC_aftertextarea');
}
</script>
FULLPAGE