version 1.10, 2024/03/03 00:08:37
|
version 1.14, 2024/03/31 01:50:18
|
Line 72 sub handler {
|
Line 72 sub handler {
|
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'noif' => 'No iframe support.', |
'noif' => 'No iframe support.', |
'show' => 'Show content in pop-up window', |
'show' => 'Show content in pop-up window', |
|
'save' => 'Save', |
|
'text' => 'Text Editor', |
'oeds' => 'other editors', |
'oeds' => 'other editors', |
'othe' => 'other editor', |
'othe' => 'other editor', |
'edit' => 'Edit', |
'edit' => 'Save and Edit', |
|
'disc' => 'Discard and View', |
|
'save' => 'Save and View', |
); |
); |
my $name = $uri; |
my $name = $uri; |
$name =~ s/^.*\/([^\/]+)$/$1/; |
$name =~ s/^.*\/([^\/]+)$/$1/; |
|
my $lang = &Apache::lonlocal::current_language(); |
|
my $filearg = '/daxeopen'.$uri; |
my $daxeurl = '/adm/daxe/daxe.html?config=config/loncapa_config.xml&save=/daxesave'. |
my $daxeurl = '/adm/daxe/daxe.html?config=config/loncapa_config.xml&save=/daxesave'. |
'&file=/daxeopen'.$uri; |
'&file='.$filearg; |
my $headjs = &Apache::loncommon::iframe_wrapper_headjs(). |
my $headjs = &Apache::loncommon::iframe_wrapper_headjs(). |
&toggle_LCmenus_js(). |
&listener_js($lang,$filearg,$is_assess). |
|
&toggle_LCmenus_js().&saveandview_js(). |
&Apache::edit::js_change_detection(); |
&Apache::edit::js_change_detection(); |
|
|
|
my ($clickexit,$clicksave,$clickedit); |
if ($is_assess) { |
if ($is_assess) { |
$headjs .= &Apache::lonxml::setmode_javascript(); |
$headjs .= &Apache::lonxml::setmode_javascript(); |
|
$clickexit = "javascript:setmode(this.form,'view');"; |
} else { |
} else { |
$headjs .= &Apache::lonxml::seteditor_javascript(); |
$headjs .= &Apache::lonxml::seteditor_javascript(); |
|
$clickexit = "javascript:seteditmode(this.form,'view');"; |
} |
} |
|
$clicksave = "javascript:daxesave('exit');"; |
|
$clickedit = "javascript:daxesave();"; |
my $form_events = &Apache::edit::form_change_detection(); |
my $form_events = &Apache::edit::form_change_detection(); |
my $editheader = '<form '.$form_events.' method="post" name="daxeedit" action="'.$uri.'">'. |
my $editheader = '<form '.$form_events.' method="post" name="daxeedit" action="'.$uri.'">'. |
'<input type="hidden" name="problemmode" value="daxe" />'."\n". |
'<input type="hidden" name="problemmode" value="daxe" />'."\n". |
'<div class="LC_edit_problem_editxml_header">'."\n"; |
'<div class="LC_edit_problem_editxml_header">'."\n"; |
|
my $saveeditbutton = '<input type="button" name="submitmode" accesskey="s" value="'.$lt{'edit'}. |
|
'" onclick="'.$clickedit.'" />'."\n"; |
|
my $exitbutton = '<input type="button" name="submitmode" accesskey="d" value="'.$lt{'disc'}. |
|
'" onclick="'.$clickexit.'" />'."\n"; |
|
my $saveexitbutton = '<input type="button" name="submitmode" accesskey="v" value="'.$lt{'save'}. |
|
'" onclick="'.$clicksave.'" />'."\n"; |
|
$editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'. |
|
$uri.'</td><td align="right"><span class="LC_nobreak">'. |
|
$saveeditbutton.$saveexitbutton.$exitbutton.'</span>'; |
if ($editors{'edit'} || $editors{'xml'}) { |
if ($editors{'edit'} || $editors{'xml'}) { |
my $other = (($editors{'edit'} && $editors{'xml'})? $lt{'oeds'} : $lt{'othe'}); |
my $other = (($editors{'edit'} && $editors{'xml'})? $lt{'oeds'} : $lt{'othe'}); |
$editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'. |
$editheader .= ' | <span class="LC_nobreak">'.$other.':</span> '. |
$uri. |
'<span class="LC_nobreak">'; |
'</td><td align="right"><span class="LC_nobreak">'.$other.': '; |
|
if ($is_not_assess) { |
if ($is_not_assess) { |
$editheader .= '<input type="hidden" name="editmode" value="" />'."\n". |
$editheader .= '<input type="hidden" name="editmode" value="" />'."\n". |
'<input type="button" name="editordefault" value="'.$lt{'edit'}. |
'<input type="button" name="editordefault" value="'.$lt{'text'}. |
'" onclick="seteditmode(this.form,'."'edit'".');" />'."\n"; |
'" onclick="seteditmode(this.form,'."'edit'".');" />'."\n"; |
} else { |
} else { |
if ($editors{'edit'}) { |
if ($editors{'edit'}) { |
Line 111 sub handler {
|
Line 132 sub handler {
|
'onclick="javascript:setmode(this.form,'."'editxml'".')" />'."\n"; |
'onclick="javascript:setmode(this.form,'."'editxml'".')" />'."\n"; |
} |
} |
} |
} |
$editheader .= '</span></td></tr></table>'; |
$editheader .= '</span>'; |
} else { |
|
$editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'. |
|
$uri. |
|
'</td></tr></table>'; |
|
} |
} |
$editheader .= '</div></form>'."\n"; |
$editheader .= '</td></tr></table></div></form>'."\n"; |
my $start_collapsed = &collapsible_std_LCmenus(); |
my $start_collapsed = &collapsible_std_LCmenus(); |
my $args = { |
my $args = { |
'collapsible_header' => $editheader, |
'collapsible_header' => $editheader, |
Line 136 sub handler {
|
Line 153 sub handler {
|
$startpage |
$startpage |
$script |
$script |
<div class="LC_iframecontainer" style="padding-right: 5px"> |
<div class="LC_iframecontainer" style="padding-right: 5px"> |
<iframe src="$dest">$lt{'noif'} $noiframe</iframe> |
<iframe src="$dest" id="lcdiframe">$lt{'noif'} $noiframe</iframe> |
</div> |
</div> |
$endpage |
$endpage |
ENDFRAME |
ENDFRAME |
return OK; |
return OK; |
} |
} |
|
|
|
sub listener_js { |
|
my ($lang,$filearg,$is_assess) = @_; |
|
return <<"ENDJS"; |
|
<script type="text/javascript"> |
|
//<![CDATA[ |
|
|
|
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; |
|
var eventer = window[eventMethod]; |
|
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; |
|
|
|
eventer(messageEvent,function(e) { |
|
var reqdOrigin = window.location.protocol+'//'+window.location.hostname; |
|
var is_assess = '$is_assess'; |
|
if (e.origin == reqdOrigin) { |
|
if (e.data == '$filearg') { |
|
if (is_assess) { |
|
setmode(document.daxeedit,'view'); |
|
} else { |
|
seteditmode(document.daxeedit,'view'); |
|
} |
|
} else if ((e.data == 'userlclang') || (e.data == 'userlang')) { |
|
window.myIframe = document.getElementById("lcdiframe").contentWindow; |
|
window.myIframe.postMessage(e.data+':$lang',reqdOrigin); |
|
} |
|
return; |
|
} |
|
},false); |
|
|
|
//]]> |
|
</script> |
|
ENDJS |
|
|
|
} |
|
|
|
sub saveandview_js { |
|
return <<"ENDJS"; |
|
|
|
<script type="text/javascript"> |
|
//<![CDATA[ |
|
|
|
function daxesave(exit) { |
|
window.myIframe = document.getElementById("lcdiframe").contentWindow; |
|
window.myIframe.focus(); |
|
window.myIframe.savelcdoc(exit); |
|
return; |
|
} |
|
|
|
//]]> |
|
</script> |
|
ENDJS |
|
} |
|
|
sub toggle_LCmenus_js { |
sub toggle_LCmenus_js { |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
altc => 'menu state: collapsed', |
altc => 'menu state: collapsed', |