[LON-CAPA-cvs] cvs: rat / lonwrapper.pm

raeburn raeburn at source.lon-capa.org
Sun Feb 16 18:07:36 EST 2020


raeburn		Sun Feb 16 23:07:36 2020 EDT

  Modified files:              
    /rat	lonwrapper.pm 
  Log:
  - Prevent overlap of iframe and Functions menu in corner case.
  
  
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.72 rat/lonwrapper.pm:1.73
--- rat/lonwrapper.pm:1.72	Sun Feb 16 21:57:49 2020
+++ rat/lonwrapper.pm	Sun Feb 16 23:07:36 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.72 2020/02/16 21:57:49 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.73 2020/02/16 23:07:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,7 +89,7 @@
         $args->{'only_body'} = $env{'form.only_body'};
     }
 
-    my ($countdown,$donemsg);
+    my ($countdown,$donemsg,$headjs);
     if (($exttool) && (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i)) {
         $Apache::lonhomework::browse = &Apache::lonnet::allowed('bre',$url);
         if ($env{'form.markaccess'}) {
@@ -135,7 +135,23 @@
         }
     }
 
-    my $startpage = &Apache::loncommon::start_page('Menu',undef,$args).$countdown.$donemsg;
+#
+# Where iframe is in use, if window.onload() executes before the custom resize function
+# has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef)
+# are used to ensure document.ready() triggers a call to resize, so the iframe contents
+# do not obscure the Functions menu.
+#
+
+    unless (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab') || $uselink) {
+        $headjs = '
+<script type="text/javascript">
+// <![CDATA[
+var LCnotready = 0;
+var LCresizedef = 0;
+// ]]>
+</script>'."\n";
+
+    my $startpage = &Apache::loncommon::start_page('Menu',$headjs,$args).$countdown.$donemsg;
     my $endpage = &Apache::loncommon::end_page();
 
     if (($uselink) && ($title eq '')) {
@@ -243,8 +259,20 @@
                 var pos = height + hdrtop + offset;
                 \$('.LC_iframecontainer').css('top', pos);
             });
+            LCresizedef = 1;
+            if (LCnotready == 1) {
+                LCnotready = 0;
+                \$(window).trigger('resize');
+            }
         });
-        window.onload = function(){  \$(window).trigger('resize') };
+        window.onload = function(){
+             if (LCresizedef) {
+                 LCnotready = 0;
+                 \$(window).trigger('resize') };
+             } else {
+                 LCnotready = 1;
+             }
+        };
 SCRIPT
         # javascript will position the iframe if window was resized (or zoomed)
         my $dest = &HTML::Entities::encode($url.$anchor,'&<>"');
@@ -292,7 +320,7 @@
 
     for ($url){
         s|^/adm/wrapper||;
-        $is_ext = $_ =~ s|^/ext/|http://|;         
+        $is_ext = $_ =~ s|^/ext/|http://|;
         s|http://https://?|https://| if ($is_ext);
         s|:|:|g;
     }




More information about the LON-CAPA-cvs mailing list