Diff for /loncom/homework/daxepage.pm between versions 1.11 and 1.12

version 1.11, 2024/03/03 18:16:27 version 1.12, 2024/03/23 23:11:52
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',
                                           'oeds' => 'other editors',                                            'oeds' => 'other editors',
                                           'othe' => 'other editor',                                            'othe' => 'other editor',
                                           'edit' => 'Edit',                                            'edit' => 'Save and Edit',
                                           'exit' => 'Exit Daxe',                                            'disc' => 'Discard and View',
                                             'save' => 'Save and View',
                                         );                                          );
     my $name = $uri;      my $name = $uri;
     $name =~ s/^.*\/([^\/]+)$/$1/;      $name =~ s/^.*\/([^\/]+)$/$1/;
       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($filearg).
                    &toggle_LCmenus_js().&saveandview_js().
                  &Apache::edit::js_change_detection();                   &Apache::edit::js_change_detection();
     my $clickexit;   
       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')";          $clickexit = "javascript:setmode(this.form,'view');";
     } else {      } else {
         $headjs .= &Apache::lonxml::seteditor_javascript();          $headjs .= &Apache::lonxml::seteditor_javascript();
         $clickexit = "javascript:seteditmode(this.form,'view')";          $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 $exitbutton = '<input type="button" name="submitmode" accesskey="t" value="'.$lt{'exit'}.      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";                       '" 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 .= '&nbsp;&nbsp;|&nbsp;&nbsp;<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{'edit'}.
Line 117  sub handler { Line 130  sub handler {
                                'onclick="javascript:setmode(this.form,'."'editxml'".')" />'."\n";                                 'onclick="javascript:setmode(this.form,'."'editxml'".')" />'."\n";
             }              }
         }          }
         $editheader .= '&nbsp;&nbsp;|&nbsp;&nbsp;'.$exitbutton.'</span></td></tr></table>';          $editheader .= '</span>';
     } else {  
         $editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'.  
                        $uri.  
                        '</td><td align="right"><span class="LC_nobreak">'.  
                        $exitbutton.'</span></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 143  sub handler { Line 151  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 ($filearg) = @_;
       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;
       if (e.origin == reqdOrigin) {
           if (e.data == '$filearg') {
               setmode(document.daxeedit,'view');
           }
           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',

Removed from v.1.11  
changed lines
  Added in v.1.12


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>