[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 fc44f9c  Improved: Move page-specific script links to html template (OFBIZ-11799)
fc44f9c is described below

commit fc44f9ce3bbf5d2c95d5c887003b6b11c3cd7c7d
Author: James Yong <[hidden email]>
AuthorDate: Sun Aug 30 21:25:10 2020 +0800

    Improved: Move page-specific script links to html template (OFBIZ-11799)
   
    Use importLibrary js function to load fjTimer/jquerytimer-min.js
    Tested on /partymgr/control/viewprofile?partyId=DemoEmployee
---
 .../webapp/partymgr/static/PartyProfileContent.js  | 70 +++++++++++-----------
 .../webapp/common/js/util/OfbizUtil.js             | 36 ++++++-----
 themes/common-theme/widget/CommonScreens.xml       |  1 -
 themes/common-theme/widget/Theme.xml               |  1 -
 themes/docs/themes.adoc                            |  1 -
 5 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/applications/party/webapp/partymgr/static/PartyProfileContent.js b/applications/party/webapp/partymgr/static/PartyProfileContent.js
index 8765b8a..59e2e04 100644
--- a/applications/party/webapp/partymgr/static/PartyProfileContent.js
+++ b/applications/party/webapp/partymgr/static/PartyProfileContent.js
@@ -84,40 +84,42 @@ function checkIframeStatus() {
 }
 
 function getUploadProgressStatus(event){
-    jQuery('#uploadPartyContent').append("<span id='progressBarSavingMsg' class='label'>" + uiLabelJsonObjects.CommonUiLabels[0] + "...</span>");
-    var i=0;
-    jQuery.fjTimer({
-        interval: 1000,
-        repeat: true,
-        tick: function(counter, timerId) {
-            var timerId = timerId;
-            jQuery.ajax({
-                url: 'getFileUploadProgressStatus',
-                dataType: 'json',
-                success: function(data) {
-                    if (data._ERROR_MESSAGE_LIST_ != undefined) {
-                        jQuery('#content-messages').html(data._ERROR_MESSAGE_LIST_);
-                        timerId.stop();
-                     } else if (data._ERROR_MESSAGE_ != undefined) {
-                         jQuery('#content-messages').html(data._ERROR_MESSAGE_);
-                        timerId.stop();
-                     } else {
-                        var readPercent = data.readPercent;
-                        jQuery("#progress_bar").progressbar("option", "value", readPercent);
-                        jQuery('#progressBarSavingMsg').html(uiLabelJsonObjects.CommonUiLabels[0] + "... (" + readPercent + "%)");
-                        if(readPercent > 99){
-                            jQuery('#progressBarSavingMsg').html(uiLabelJsonObjects.CommonUiLabels[1] + "...");
-                            // stop the fjTimer
+    importLibrary(["/common/js/jquery/plugins/fjTimer/jquerytimer-min.js"], function(){
+        jQuery('#uploadPartyContent').append("<span id='progressBarSavingMsg' class='label'>" + uiLabelJsonObjects.CommonUiLabels[0] + "...</span>");
+        var i=0;
+        jQuery.fjTimer({
+            interval: 1000,
+            repeat: true,
+            tick: function(counter, timerId) {
+                var timerId = timerId;
+                jQuery.ajax({
+                    url: 'getFileUploadProgressStatus',
+                    dataType: 'json',
+                    success: function(data) {
+                        if (data._ERROR_MESSAGE_LIST_ != undefined) {
+                            jQuery('#content-messages').html(data._ERROR_MESSAGE_LIST_);
                             timerId.stop();
-                            // call the upload complete method to do final stuff
-                            checkIframeStatus();
-                        }
-                     }
-                },
-                error: function() {
-                     timerId.stop();
-                }
-            });
-        }
+                         } else if (data._ERROR_MESSAGE_ != undefined) {
+                             jQuery('#content-messages').html(data._ERROR_MESSAGE_);
+                            timerId.stop();
+                         } else {
+                            var readPercent = data.readPercent;
+                            jQuery("#progress_bar").progressbar("option", "value", readPercent);
+                            jQuery('#progressBarSavingMsg').html(uiLabelJsonObjects.CommonUiLabels[0] + "... (" + readPercent + "%)");
+                            if(readPercent > 99){
+                                jQuery('#progressBarSavingMsg').html(uiLabelJsonObjects.CommonUiLabels[1] + "...");
+                                // stop the fjTimer
+                                timerId.stop();
+                                // call the upload complete method to do final stuff
+                                checkIframeStatus();
+                            }
+                         }
+                    },
+                    error: function() {
+                         timerId.stop();
+                    }
+                });
+            }
+        });
     });
 }
diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
index 4736fdd..c662c01 100644
--- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js
+++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
@@ -607,23 +607,27 @@ function ajaxUpdateAreas(areaCsvString) {
   * @param interval The update interval, in seconds.
 */
 function ajaxUpdateAreaPeriodic(areaId, target, targetParams, interval) {
-    var intervalMillis = interval * 1000;
-    jQuery.fjTimer({
-        interval: intervalMillis,
-        repeat: true,
-        tick: function(container, timerId){
-            jQuery.ajax({
-                url: target,
-                type: "POST",
-                data: targetParams,
-                success: function(data) {
-                    jQuery("#" + areaId).html(data);
-                    waitSpinnerHide();
-                },
-                error: function(data) {waitSpinnerHide()}
-            });
+    importLibrary(["/common/js/jquery/plugins/fjTimer/jquerytimer-min.js"], function() {
+        var intervalMillis = interval * 1000;
+        jQuery.fjTimer({
+            interval: intervalMillis,
+            repeat: true,
+            tick: function (container, timerId) {
+                jQuery.ajax({
+                    url: target,
+                    type: "POST",
+                    data: targetParams,
+                    success: function (data) {
+                        jQuery("#" + areaId).html(data);
+                        waitSpinnerHide();
+                    },
+                    error: function (data) {
+                        waitSpinnerHide()
+                    }
+                });
 
-        }
+            }
+        });
     });
 }
 
diff --git a/themes/common-theme/widget/CommonScreens.xml b/themes/common-theme/widget/CommonScreens.xml
index 11f7189..41b236e 100644
--- a/themes/common-theme/widget/CommonScreens.xml
+++ b/themes/common-theme/widget/CommonScreens.xml
@@ -438,7 +438,6 @@ under the License.
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/jeditable/jquery.jeditable-1.7.3.js" global="true"/>
-                <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/fjTimer/jquerytimer-min.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/validate/jquery.validate.min.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/browser-plugin/jquery.browser-0.1.0.min.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/jquery-migrate-3.3.0.min.js" global="true" />
diff --git a/themes/common-theme/widget/Theme.xml b/themes/common-theme/widget/Theme.xml
index 1128924..f4b842c 100644
--- a/themes/common-theme/widget/Theme.xml
+++ b/themes/common-theme/widget/Theme.xml
@@ -62,7 +62,6 @@ under the License.
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/browser-plugin/jquery.browser-0.1.0.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js"/>
-        <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/fjTimer/jquerytimer-min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/jeditable/jquery.jeditable-1.7.3.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/validate/jquery.validate.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/OfbizUtil.js"/>
diff --git a/themes/docs/themes.adoc b/themes/docs/themes.adoc
index 62f2bcc..e30f3e1 100644
--- a/themes/docs/themes.adoc
+++ b/themes/docs/themes.adoc
@@ -286,7 +286,6 @@ The blue light theme has been these properties in VisualThemeRessource :
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/ui/js/jquery-ui-1.10.3.min.js" sequenceId="03"/>
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.js" sequenceId="05"/>
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon.min-1.4.3.js" sequenceId="07"/>
-    <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/fjTimer/jquerytimer-min.js" sequenceId="09"/>
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/mask/jquery.mask-1.14.13.min.js" sequenceId="10"/>
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/jeditable/jquery.jeditable-1.7.3.js" sequenceId="11"/>
     <VisualThemeResource visualThemeId="BLUELIGHT" resourceTypeEnumId="VT_HDR_JAVASCRIPT" resourceValue="/common/js/jquery/plugins/validate/jquery.validate.min.js" sequenceId="12"/>