Author: jleroux
Date: Sat Nov 4 14:06:56 2017 New Revision: 1814292 URL: http://svn.apache.org/viewvc?rev=1814292&view=rev Log: Improved: Replace Inline Javascript with External Javascript (OFBIZ-9465) As discussed in http://ofbiz.markmail.org/thread/ti54omjdt4fy662m inline javascript for various macros like renderLookupField, makeHyperlinkString, shortDateInput etc in HtmlFormMacroLibrary.ftl should be replaced with a generic code written as external javascript. Generic Javascript code should be written in OfbizUtil.js and appropriate classes or identifiers should be used for applying that. Any additional data can be passed with HTML 5 custom data attribute (https://www.w3.org/TR/2011/WD-html5-20110525/elements.html #embedding-custom-non-visible-data-with-the-data-attributes). Deepak: I think we can use data-mask attribute to recognize the element instead of adding class. jeloux: I noticed a MaskFieldExampleForm was introduced with r1804027 but not used in FormWidgetExampleScreens.xml so was not visible Thanks: Aditya and Deepak Modified: ofbiz/ofbiz-framework/trunk/framework/security/config/security.properties ofbiz/ofbiz-framework/trunk/themes/common/template/macro/HtmlFormMacroLibrary.ftl ofbiz/ofbiz-framework/trunk/themes/common/webapp/common/js/util/OfbizUtil.js ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml Modified: ofbiz/ofbiz-framework/trunk/framework/security/config/security.properties URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/security/config/security.properties?rev=1814292&r1=1814291&r2=1814292&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/security/config/security.properties (original) +++ ofbiz/ofbiz-framework/trunk/framework/security/config/security.properties Sat Nov 4 14:06:56 2017 @@ -126,7 +126,17 @@ protect-view.preprocessor=java.org.apach #default.error.response.view=none: default.error.response.view=view:viewBlocked -# If false, then no externalLoginKey parameters will be added to cross-webapp urls +# -- If false, then no externalLoginKey parameters will be added to cross-webapp urls security.login.externalLoginKey.enabled=true -#Security key used to encrypt and decrypt the autogenerated password in forgot password functionality. -login.secret_key_string=Secret Key \ No newline at end of file +# -- Security key used to encrypt and decrypt the autogenerated password in forgot password functionality. +login.secret_key_string=Secret Key + +# -- If true, then it's possible to connect to another webapp on another server w/o signing in +use-external-server=Y +# -- Name of the external server (DNS) +#external-server-name=localhost:8443 +external-server-name=demo-trunk.ofbiz.apache.org +# -- Query part of the URL to use +external-server-query=/catalog/control/ +# -- Time To Live of the token send to the external server +external-server-token-duration=30 Modified: ofbiz/ofbiz-framework/trunk/themes/common/template/macro/HtmlFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/template/macro/HtmlFormMacroLibrary.ftl?rev=1814292&r1=1814291&r2=1814292&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/themes/common/template/macro/HtmlFormMacroLibrary.ftl (original) +++ ofbiz/ofbiz-framework/trunk/themes/common/template/macro/HtmlFormMacroLibrary.ftl Sat Nov 4 14:06:56 2017 @@ -49,11 +49,6 @@ under the License. <#macro renderHyperlinkField></#macro> <#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask tabindex readonly placeholder="" delegatorName="default"> - <#if mask?has_content> - <script type="text/javascript"> - jQuery(function($){jQuery("#${id}").mask("${mask}");}); - </script> - </#if> <input type="text" name="${name?default("")?html}"<#t/> <@renderClass className alert /> <#if value?has_content> value="${value}"</#if><#rt/> @@ -61,6 +56,7 @@ under the License. <#if maxlength?has_content> maxlength="${maxlength}"</#if><#rt/> <#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/> <#if readonly?has_content && readonly> readonly="readonly"</#if><#rt/> + <#if mask?has_content> data-mask="${mask}"</#if><#rt/> <#if id?has_content> id="${id}"</#if><#rt/> <#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/> <#if clientAutocomplete?has_content && clientAutocomplete=="false"> autocomplete="off"</#if><#rt/> @@ -76,6 +72,9 @@ under the License. </#macro> <#macro renderTextareaField name className alert cols rows maxlength id readonly value visualEditorEnable buttons tabindex language=""> + <#if visualEditorEnable?has_content> + <#local className = className + " visual-editor"> + </#if> <textarea name="${name}"<#t/> <@renderClass className alert /> <#if cols?has_content> cols="${cols}"</#if><#rt/> @@ -84,26 +83,11 @@ under the License. <#if readonly?has_content && readonly=='readonly'> readonly="readonly"</#if><#rt/> <#if maxlength?has_content> maxlength="${maxlength}"</#if><#rt/> <#if tabindex?has_content> tabindex="${tabindex}"</#if><#rt/> + <#if visualEditorEnable?has_content> data-toolbar="${buttons?default("maxi")}"</#if><#rt/> + <#if language?has_content> data-language="${language!"en"}"</#if><#rt/> ><#t/> <#if value?has_content>${value}</#if><#t/> </textarea><#lt/> - <#if visualEditorEnable?has_content> - <script language="javascript" src="/common/js/jquery/plugins/elrte-1.3/js/elrte.min.js" type="text/javascript"></script><#rt/> - <#if language?has_content && language != "en"> - <script language="javascript" src="/common/js/jquery/plugins/elrte-1.3/js/i18n/elrte.${language!"en"}.js" type="text/javascript"></script><#rt/> - </#if> - <link href="/common/js/jquery/plugins/elrte-1.3/css/elrte.min.css" rel="stylesheet" type="text/css"> - <script language="javascript" type="text/javascript"> - var opts = { - cssClass : 'el-rte', - lang : '${language!"en"}', - toolbar : '${buttons?default("maxi")}', - doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', //'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">', - cssfiles : ['/common/js/jquery/plugins/elrte-1.3/css/elrte-inner.css'] - } - jQuery('#${id?default("")}').elrte(opts); - </script> - </#if> </#macro> <#macro renderDateTimeField name className alert title value size maxlength id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName="" mask="" event="" action="" step="" timeValues="" tabindex="" > Modified: ofbiz/ofbiz-framework/trunk/themes/common/webapp/common/js/util/OfbizUtil.js URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/webapp/common/js/util/OfbizUtil.js?rev=1814292&r1=1814291&r2=1814292&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/themes/common/webapp/common/js/util/OfbizUtil.js (original) +++ ofbiz/ofbiz-framework/trunk/themes/common/webapp/common/js/util/OfbizUtil.js Sat Nov 4 14:06:56 2017 @@ -49,6 +49,25 @@ function bindObservers(bind_element) { if (jQuery(".selectAll").is(":checked")) { jQuery(".selectAll").removeAttr("checked").trigger("click"); } + jQuery(bind_element).find("[data-mask]").each(function(){ + var element = jQuery(this); + var mask = element.data('mask'); + element.mask(mask); + }); + jQuery(bind_element).find(".visual-editor").each(function(){ + var element = jQuery(this); + var toolbar = element.data('toolbar'); + var language = element.data('language'); + var opts = { + cssClass : 'el-rte', + lang : language, + toolbar : toolbar, + doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', //'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">', + cssfiles : ['/images/jquery/plugins/elrte-1.3/css/elrte-inner.css'] + } + element.elrte(opts); + }); + } /* SelectAll: This utility can be used when we need to use parent and child box combination over any page. Here is the list of tasks it will do: Modified: ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml?rev=1814292&r1=1814291&r2=1814292&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml (original) +++ ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml Sat Nov 4 14:06:56 2017 @@ -67,6 +67,7 @@ under the License. <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/jeditable/jquery.jeditable.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/validate/jquery.validate.min.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/images/OpenLayers-2.13.1.js"/> + <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/elrte-1.3/js/elrte.min.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/OfbizUtil.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/fieldlookup.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/plugins/date/date.format-1.2.3-min.js"/> @@ -79,6 +80,7 @@ under the License. <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/plugins/date/FromThruDateCheck.js"/> <property name="VT_HDR_JAVASCRIPT['add']" value="/flatgrey/js/application.js"/> <!--Css styles: don't load them since they differ depending on theme --> + <property name="VT_STYLESHEET['add']" value="/common/js/jquery/plugins/elrte-1.3/css/elrte.min.css"/> </theme-properties> <templates><!-- Freemarker template use by this theme to render widget model--> |
Free forum by Nabble | Edit this page |