--- loncom/interface/loncommon.pm 2023/10/06 13:40:53 1.1075.2.161.2.20 +++ loncom/interface/loncommon.pm 2024/02/28 03:23:49 1.1075.2.161.2.22 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.20 2023/10/06 13:40:53 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.161.2.22 2024/02/28 03:23:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1728,8 +1728,6 @@ the id of the element to resize, second surrounds everything that comes after the textarea, this routine needs to be attached to the
for the onload and onresize events. -=back - =cut sub resize_textarea_js { @@ -2016,6 +2014,107 @@ sub insert_folding_button { value=\"".&mt('Hide')."\" onclick=\"fold_box('$curDepth','$lastresource')\">"; } +=pod + +=item * &iframe_wrapper_headjs() + +emits javascript containing two global vars to facilitate handling of resizing +by code in iframe_wrapper_resizejs() used when an iframe is present in a page +with standard LON-CAPA menus. + +=cut + +# +# 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. +# + +sub iframe_wrapper_headjs { + return <<"ENDJS"; + + +ENDJS + +} + +=pod + +=item * &iframe_wrapper_resizejs() + +emits javascript used to handle resizing for a page containing +an iframe, to ensure that the iframe does not obscure any +standard LON-CAPA menu items. + +=back + +=cut + +# +# jQuery to use when iframe is in use and a page resize occurs. +# This script will ensure that the iframe does not obscure any +# standard LON-CAPA inline menus (primary, secondary, and/or +# breadcrumbs and Functions menus. Expects javascript from +# &iframe_wrapper_headjs() to be in head portion of the web page, +# e.g., by inclusion in second arg passed to &start_page(). +# + +sub iframe_wrapper_resizejs { + my $offset = 5; + &get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); + if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) { + $offset = 0; + } + return &Apache::lonhtmlcommon::scripttag(<