From efd15e282f5789990dee548eab18c2ecc81212f0 Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Wed, 14 Jun 2023 14:48:04 +0100 Subject: [PATCH] Fix theme_boosto365teams not applied issue in Teams mobile apps for iOS and Android --- .../amd/build/iframeChecker.min.js | 2 +- .../boost_o365teams/amd/src/iframeChecker.js | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/theme/boost_o365teams/amd/build/iframeChecker.min.js b/theme/boost_o365teams/amd/build/iframeChecker.min.js index 8bf3314b7..3873a51c5 100644 --- a/theme/boost_o365teams/amd/build/iframeChecker.min.js +++ b/theme/boost_o365teams/amd/build/iframeChecker.min.js @@ -1 +1 @@ -define(["jquery"],function(t){return{init:function(){window.location==window.parent.location?(t("nav.navbar").show(),t("nav.navbar").css("display","flex"),t("div#nav-drawer").show(),t('section[data-region="blocks-column"]').show(),t("footer#page-footer").show(),t("div#course_page_title").css("display","none"),t(".popupicon").css("display","none")):(t("body.drawer-open-left").css("margin-left","0"),t("div#page").css("margin-top","0"),t("section#region-main.has-blocks").css("width","100%"),t("div#page-wrapper").css("margin-bottom","0"),t("div.context-header-settings-menu").remove(),t("div.region-main-settings-menu").remove(),t("div.region_main_settings_menu_proxy").remove(),t("div.action-menu-trigger").remove(),t("div.ml-auto").remove(),t("a.printicon").remove(),t("header#page-header").css("display","none"),t(".activityinstance a").click(function(){t(this).attr("target","_blank")}),t(".modtype_assign .activityinstance a").click(function(){t(this).attr("target","_self")}),t(".modtype_quiz .activityinstance a").click(function(){t(this).attr("target","_self")}),t("#page-mod-assign-view .submissionlinks a").click(function(){t(this).attr("target","_blank")}),t(".quizattempt .singlebutton form").click(function(){t(this).attr("target","_blank"),t(this).attr("method","get")})),t("body").fadeIn(150)}}}); \ No newline at end of file +define(["jquery"],function(t){return{init:function(){window.location!=window.parent.location||/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(t("body.drawer-open-left").css("margin-left","0"),t("div#page").css("margin-top","0"),t("section#region-main.has-blocks").css("width","100%"),t("div#page-wrapper").css("margin-bottom","0"),t("div.context-header-settings-menu").remove(),t("div.region-main-settings-menu").remove(),t("div.region_main_settings_menu_proxy").remove(),t("div.action-menu-trigger").remove(),t("div.ml-auto").remove(),t("a.printicon").remove(),t("header#page-header").css("display","none"),t(".activityinstance a").click(function(){t(this).attr("target","_blank")}),t(".modtype_assign .activityinstance a").click(function(){t(this).attr("target","_self")}),t(".modtype_quiz .activityinstance a").click(function(){t(this).attr("target","_self")}),t("#page-mod-assign-view .submissionlinks a").click(function(){t(this).attr("target","_blank")}),t(".quizattempt .singlebutton form").click(function(){t(this).attr("target","_blank"),t(this).attr("method","get")})):(t("nav.navbar").show(),t("nav.navbar").css("display","flex"),t("div#nav-drawer").show(),t('section[data-region="blocks-column"]').show(),t("footer#page-footer").show(),t("div#course_page_title").css("display","none"),t(".popupicon").css("display","none")),t("body").fadeIn(150)}}}); \ No newline at end of file diff --git a/theme/boost_o365teams/amd/src/iframeChecker.js b/theme/boost_o365teams/amd/src/iframeChecker.js index 47ad3952a..cb54e3288 100644 --- a/theme/boost_o365teams/amd/src/iframeChecker.js +++ b/theme/boost_o365teams/amd/src/iframeChecker.js @@ -1,17 +1,8 @@ define(['jquery'], function ($) { return { init: function() { - if (window.location == window.parent.location) { - // not in iframe, show page elements - $('nav.navbar').show(); - $('nav.navbar').css('display', 'flex'); - $('div#nav-drawer').show(); - $('section[data-region="blocks-column"]').show(); - $('footer#page-footer').show(); - $('div#course_page_title').css('display', 'none'); - $('.popupicon').css('display', 'none'); - } else { - // in iframe, hide page elements + if (in_teams()) { + // In Teams, hide page elements. $('body.drawer-open-left').css('margin-left', '0'); $('div#page').css('margin-top', '0'); $('section#region-main.has-blocks').css('width', '100%'); @@ -39,8 +30,21 @@ define(['jquery'], function ($) { $(this).attr('target', '_blank'); $(this).attr('method', 'get'); }); + } else { + // Not in Teams, show page elements. + $('nav.navbar').show(); + $('nav.navbar').css('display', 'flex'); + $('div#nav-drawer').show(); + $('section[data-region="blocks-column"]').show(); + $('footer#page-footer').show(); + $('div#course_page_title').css('display', 'none'); + $('.popupicon').css('display', 'none'); } $("body").fadeIn(150); } }; + + function in_teams() { + return ((window.location != window.parent.location) || (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent))); + }; });