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 06b4333 Improved: Move page-specific script links to html template (OFBIZ-11799) 06b4333 is described below commit 06b4333c546dc59966f352decc75731700bf78b0 Author: James Yong <[hidden email]> AuthorDate: Sun Aug 16 19:22:18 2020 +0800 Improved: Move page-specific script links to html template (OFBIZ-11799) refactoring + use importLibrary js function to load readmore and jgrowl js. --- .../webapp/common/js/util/OfbizUtil.js | 91 +++++++++++----------- themes/common-theme/widget/CommonScreens.xml | 2 - 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js b/themes/common-theme/webapp/common/js/util/OfbizUtil.js index ff7dbc1..bb9da1b 100644 --- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js +++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js @@ -1090,47 +1090,51 @@ function submitFormDisableSubmits(form) { } function showjGrowl(showAllLabel, collapseLabel, hideAllLabel, jGrowlPosition, jGrowlWidth, jGrowlHeight, jGrowlSpeed) { + var libraryFiles = ["/common/js/jquery/plugins/Readmore.js-master/readmore.js", + "/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.js"]; + importLibrary(libraryFiles, function() { + var contentMessages = jQuery("#content-messages"); + if (contentMessages.length) { + jQuery("#content-messages").hide(); + var errMessage = jQuery("#content-messages").html(); + var classEvent = ""; + var classList = jQuery("#content-messages").attr('class').split(/\s+/); + var stickyValue = false; + jQuery(classList).each(function (index) { + var localClass = classList[index]; + if (localClass == "eventMessage" || localClass == "errorMessage") { + classEvent = localClass + "JGrowl"; + } + }); + if (classEvent == "errorMessageJGrowl") { + stickyValue = true; + } - var contentMessages = jQuery("#content-messages"); - if (contentMessages.length) { - jQuery("#content-messages").hide(); - var errMessage = jQuery("#content-messages").html(); - var classEvent = ""; - var classList = jQuery("#content-messages").attr('class').split(/\s+/); - var stickyValue = false; - jQuery(classList).each(function(index) { - var localClass = classList[index]; - if(localClass == "eventMessage" || localClass == "errorMessage" ){ - classEvent = localClass + "JGrowl"; + if (errMessage == null || errMessage == "" || errMessage == undefined) { + // No Error Message Information is set, Error Msg Box can't be created + return; } - }); - if (classEvent == "errorMessageJGrowl") { - stickyValue = true; - } + $.jGrowl.defaults.closerTemplate = '<div class="closeAllJGrowl">' + hideAllLabel + '</div>'; + if (jGrowlPosition !== null && jGrowlPosition !== undefined) $.jGrowl.defaults.position = jGrowlPosition; + $.jGrowl(errMessage, { + theme: classEvent, sticky: stickyValue, + beforeOpen: function (e, m, o) { + if (jGrowlWidth !== null && jGrowlWidth !== undefined) $(e).width(jGrowlWidth + 'px'); + if (jGrowlHeight !== null && jGrowlHeight !== undefined) $(e).height(jGrowlHeight + 'px'); + }, + afterOpen: function (e, m) { + jQuery(".jGrowl-message").readmore({ + moreLink: '<a href="#" style="display: block; width: auto; padding: 0px;text-align: right; margin-top: 10px; color: #ffffff; font-size: 0.8em">' + showAllLabel + '</a>', + lessLink: '<a href="#" style="display: block; width: auto; padding: 0px;text-align: right; margin-top: 10px; color: #ffffff; font-size: 0.8em">' + collapseLabel + '</a>', - if (errMessage == null || errMessage == "" || errMessage == undefined ) { - // No Error Message Information is set, Error Msg Box can't be created - return; + maxHeight: 75 + }); + }, + speed: jGrowlSpeed + }); + contentMessages.remove(); } - $.jGrowl.defaults.closerTemplate = '<div class="closeAllJGrowl">'+hideAllLabel+'</div>'; - if (jGrowlPosition !== null && jGrowlPosition !== undefined) $.jGrowl.defaults.position = jGrowlPosition; - $.jGrowl(errMessage, { theme: classEvent, sticky: stickyValue, - beforeOpen: function(e,m,o){ - if (jGrowlWidth !== null && jGrowlWidth !== undefined) $(e).width( jGrowlWidth+'px' ); - if (jGrowlHeight !== null && jGrowlHeight !== undefined) $(e).height( jGrowlHeight+'px' ); - }, - afterOpen: function(e,m) { - jQuery(".jGrowl-message").readmore({ - moreLink: '<a href="#" style="display: block; width: auto; padding: 0px;text-align: right; margin-top: 10px; color: #ffffff; font-size: 0.8em">'+showAllLabel+'</a>', - lessLink: '<a href="#" style="display: block; width: auto; padding: 0px;text-align: right; margin-top: 10px; color: #ffffff; font-size: 0.8em">'+collapseLabel+'</a>', - - maxHeight: 75 - }); - }, - speed:jGrowlSpeed - }); - contentMessages.remove(); - } + }); } @@ -1444,15 +1448,14 @@ var importLibrary = function() { jQuery.when.apply(jQuery, jQuery.map(urls, function (url) { if (!importLibraryFiles.has(url)) { - var folder = url.substring(0,url.lastIndexOf("/")) - var parentFolder = folder.substring(0,folder.lastIndexOf("/")) var deferObj = (url.endsWith(".css") ? jQuery.get(url, function (css) { - // convert any relative path - var updatedCss = css.replace(/\.\.\/(images|css|js)+/g, parentFolder+"/$1"); - jQuery("<style>" + updatedCss + "</style>").appendTo("head"); - } - ) : + var folder = url.substring(0,url.lastIndexOf("/")) + var parentFolder = folder.substring(0,folder.lastIndexOf("/")) + // convert any relative path + var updatedCss = css.replace(/\.\.\/(images|css|js)+/g, parentFolder+"/$1"); + jQuery("<style>" + updatedCss + "</style>").appendTo("head"); + }) : cachedScript(url)); importLibraryFiles.set(url, deferObj); return deferObj; diff --git a/themes/common-theme/widget/CommonScreens.xml b/themes/common-theme/widget/CommonScreens.xml index ea2ac50..a49716a 100644 --- a/themes/common-theme/widget/CommonScreens.xml +++ b/themes/common-theme/widget/CommonScreens.xml @@ -127,8 +127,6 @@ under the License. <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.validation.getFilePath(initialLocaleComplete)}" global="true" /> <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.dateTime.getFilePath(initialLocaleComplete)}" global="true" /> <!-- Jgrowl --> - <set field="layoutSettings.javaScripts[]" value="/common/js/jquery/plugins/Readmore.js-master/readmore.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.js" global="true"/> <set field="layoutSettings.styleSheets[+0]" value="/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.css" global="true" /> <!-- Set default user locale from browser --> <set field="layoutSettings.javaScripts[+0]" value="/common/js/util/setUserTimeZone.js"/> |
Free forum by Nabble | Edit this page |