[ofbiz-framework] branch trunk updated: Improved: Move page-specific script links to html template (OFBIZ-11799)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Move page-specific script links to html template (OFBIZ-11799)

James Yong-2
This is an automated email from the ASF dual-hosted git repository.

jamesyong pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b480426  Improved: Move page-specific script links to html template (OFBIZ-11799)
b480426 is described below

commit b480426e1087492c93d048a8f09f7e6808333e0f
Author: James Yong <[hidden email]>
AuthorDate: Fri Aug 21 15:13:35 2020 +0800

    Improved: Move page-specific script links to html template (OFBIZ-11799)
   
    use importLibrary js function to load impersonate.css
---
 themes/common-theme/template/ImpersonateBanner.ftl | 26 +++++++++++++++-------
 themes/common-theme/template/Impersonated.ftl      | 23 ++++++++++++-------
 themes/common-theme/widget/CommonScreens.xml       |  3 +--
 3 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/themes/common-theme/template/ImpersonateBanner.ftl b/themes/common-theme/template/ImpersonateBanner.ftl
index de1b550..900e49b 100644
--- a/themes/common-theme/template/ImpersonateBanner.ftl
+++ b/themes/common-theme/template/ImpersonateBanner.ftl
@@ -18,13 +18,23 @@ under the License.
 -->
 
 <#if parameters.originUserLogin??>
-    <a href="#impersonateContent" title="${uiLabelMap.CommonImpersonateTitle}" id="impersonateBtn"><img src="/images/img/impersonate-ico.png" alt="${uiLabelMap.CommonImpersonateTitle}"/></a>
-    <div id="impersonateContent">
-        <div class="impersonateModal">
-            <a href="#" class="btn-close" title="${uiLabelMap.CommonClose}">×</a>
-            <h3>${uiLabelMap.CommonImpersonateTitle}</h3>
-            <p>${uiLabelMap.CommonImpersonateUserLogin} : <strong>${context.userLogin.userLoginId!}</strong></p>
-            <a href="depersonateLogin" class="btn" title="${uiLabelMap.CommonImpersonateStop}">${uiLabelMap.CommonImpersonateStop}</a>
-        </div>
+    <div id="impersonateContentBody">
     </div>
+    <script id="impersonateContent-template" type="text/html">
+        <a href="#impersonateContent" title="${uiLabelMap.CommonImpersonateTitle}" id="impersonateBtn"><img src="/images/img/impersonate-ico.png" alt="${uiLabelMap.CommonImpersonateTitle}"/></a>
+        <div id="impersonateContent">
+            <div class="impersonateModal">
+                <a href="#" class="btn-close" title="${uiLabelMap.CommonClose}">×</a>
+                <h3>${uiLabelMap.CommonImpersonateTitle}</h3>
+                <p>${uiLabelMap.CommonImpersonateUserLogin} : <strong>${context.userLogin.userLoginId!}</strong></p>
+                <a href="depersonateLogin" class="btn" title="${uiLabelMap.CommonImpersonateStop}">${uiLabelMap.CommonImpersonateStop}</a>
+            </div>
+        </div>
+    </script>
+    <script>
+        importLibrary(["/common/css/impersonate.css"], function(){
+            var content = jQuery.parseHTML($('#impersonateContent-template').html());
+            $("#impersonateContentBody").append(content);
+        });
+    </script>
 </#if>
diff --git a/themes/common-theme/template/Impersonated.ftl b/themes/common-theme/template/Impersonated.ftl
index b6117ce..abf78cb 100644
--- a/themes/common-theme/template/Impersonated.ftl
+++ b/themes/common-theme/template/Impersonated.ftl
@@ -16,18 +16,25 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-
 <#assign messageMap = Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("originUserLoginId", impersonator)/>
 <#assign impersonationMessage= Static["org.apache.ofbiz.base.util.UtilProperties"].getMessage("SecurityextUiLabels", "loginevents.impersonation_in_process", messageMap, locale)/>
 <#assign fromDate = Static["org.apache.ofbiz.base.util.UtilFormatOut"].formatDateTime(impersonationFromDate, "", locale, timeZone)/>
 <div id="impersonateMode">
-  <div class="content">
-      <img src="/images/img/impersonate-ico.png" alt="${uiLabelMap.CommonImpersonateTitle}"/>
-      <p class="user">${impersonationMessage!}<p>
-      <p>${uiLabelMap.CommonSince} ${fromDate!}</p>
-      <p><a id="logout" class="user-pref-btn" href="<@ofbizUrl>logout</@ofbizUrl>">${uiLabelMap.CommonLogout}</a></p>
-  </div>
 </div>
+<script id="impersonateMode-template" type="text/html">
+    <div class="content">
+        <img src="/images/img/impersonate-ico.png" alt="${uiLabelMap.CommonImpersonateTitle}"/>
+        <p class="user">${impersonationMessage!}<p>
+        <p>${uiLabelMap.CommonSince} ${fromDate!}</p>
+        <p><a id="logout" class="user-pref-btn" href="<@ofbizUrl>logout</@ofbizUrl>">${uiLabelMap.CommonLogout}</a></p>
+    </div>
+</script>
 <script>
-    setInterval('window.location.reload()', 30000);
+    importLibrary(["/common/css/impersonate.css"], function(){
+        var parsedContent = jQuery.parseHTML($('#impersonateMode-template').html());
+        $("#impersonateMode").append(parsedContent);
+    });
+    setInterval(function (){
+        window.location.reload();
+    }, 30000);
 </script>
diff --git a/themes/common-theme/widget/CommonScreens.xml b/themes/common-theme/widget/CommonScreens.xml
index 292a50b..2a65c1a 100644
--- a/themes/common-theme/widget/CommonScreens.xml
+++ b/themes/common-theme/widget/CommonScreens.xml
@@ -150,7 +150,6 @@ under the License.
                         <set field="appbarCloseTemplateLocation" from-field="layoutSettings.VT_NAV_CLOSE_TMPLT" />
                         <set field="messagesTemplateLocation" from-field="layoutSettings.VT_MSG_TMPLT_LOC" />
                         <set field="layoutSettings.suppressTab" value="ofbizsetup"/><!-- diseable ofbiz setup by default -->
-                        <set field="layoutSettings.styleSheets[+0]" value="/common/css/impersonate.css" global="true" />
                     </actions>
                     <widgets />
                 </section>
@@ -576,7 +575,7 @@ under the License.
                             <widgets />
                         </section>
                         <platform-specific>
-                            <html><html-template location="${impersonatedTemplateLocation}"/></html>
+                            <html><html-template multi-block="true" location="${impersonatedTemplateLocation}"/></html>
                         </platform-specific>
                     </decorator-section>
                 </decorator-screen>