You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2010/05/31 12:33:52 UTC

svn commit: r949710 - in /ofbiz/trunk/framework: images/webapp/images/fieldlookup.js widget/templates/htmlFormMacroLibrary.ftl

Author: jleroux
Date: Mon May 31 10:33:52 2010
New Revision: 949710

URL: http://svn.apache.org/viewvc?rev=949710&view=rev
Log:
* Remove useless white spaces in macro (make harder handling links in javascript)
* Implement target-parameter in case of layered lookup (was missing)

Modified:
    ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/fieldlookup.js?rev=949710&r1=949709&r2=949710&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/fieldlookup.js Mon May 31 10:33:52 2010
@@ -51,7 +51,7 @@ function call_fieldlookupLayer(target, v
         return lookup_error("Lookup can't be created, one of these variables is missing: target=" + target + " viewName=" + viewName);
     }
 
-    var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground);
+    var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground, arguments);
     fieldLookupPopup.showLookup();
     this.target = target;
 }
@@ -60,8 +60,8 @@ function call_fieldlookupLayer3(target, 
     if (isEmpty(target) || isEmpty(target2) || isEmpty(viewName)) {
         return lookup_error("Lookup can't be created, one of these variables is missing: target=" + target + " target2=" + target2 + " viewName=" + viewName);
     }
-        
-    var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground);
+
+    var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground, arguments);
     fieldLookupPopup.showLookup();
     this.target = target;
     this.target2 = target2;
@@ -202,7 +202,21 @@ var GLOBAL_LOOKUP_REF = new FieldLookupC
 * position - normal (under the target field), center (layer is centered), etc. (see widget-form.xsd), default: top-left 
 */
 var FieldLookupPopup = Class.create({
-    initialize: function (target, viewName, lookupWidth, lookupHeight, position, fadeBackground) {
+    initialize: function (target, viewName, lookupWidth, lookupHeight, position, fadeBackground, args) {
+        if (args != null) {
+            var argString = "";
+            if (args.length > 7) {
+                for (var i = 7; i < args.length; i++) {
+                    if ((viewName.indexOf("?") == -1) && (i - 6) == 1) {
+                        sep = "?";
+                    } else {
+                        sep = "&";
+                    }
+                    argString += sep + "parm" + (i - 6) + "=" + args[i];
+                }
+            viewName += argString;
+            }
+        }
 
         //fade the background if the flag is set
         if (fadeBackground != "false") {
@@ -253,6 +267,7 @@ var FieldLookupPopup = Class.create({
 
     createElement: function () {
         var parent = this.parentTarget;
+        
         var that = this;
         
         //set global reference
@@ -330,7 +345,6 @@ var FieldLookupPopup = Class.create({
         var lookupCont = new Element('DIV', {
             id: "fieldLookupContent"
         });
-
         new Ajax.Request(this.viewName, {
             parameters: { presentation : "layer" },
             onSuccess: function (transport) {
@@ -583,6 +597,7 @@ function modifySubmitButton (lookupDiv) 
         
         //find the lookup form
         var forms = lookupDiv.getElementsByTagName('form');
+        
         var lookupForm = null;
         for (var i = 0; i < forms.length; i++) {
             if (! isEmpty(forms[i].getAttribute('id'))) {
@@ -593,13 +608,15 @@ function modifySubmitButton (lookupDiv) 
         if (lookupForm == null) {
             return;
         }
-        
+
         //set new form name and id
         oldFormName = lookupForm.getAttribute('name');
         lookupForm.setAttribute('name', 'form_' + GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).globalRef);
         lookupForm.setAttribute('id', 'form_' + GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).globalRef);
         lookupForm = $('form_' + GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).globalRef);
         
+        
+        
         //set new links for lookups
         var newLookups = $A(lookupDiv.getElementsByClassName('field-lookup'));
         newLookups.each(function(newLookup){
@@ -620,7 +637,7 @@ function modifySubmitButton (lookupDiv) 
         //disable the form action
         var formAction = lookupForm.getAttribute('action');
         lookupForm.setAttribute('action', '');
-
+        
         //modify the form submit button
         for (var i = 0; i < lookupForm.length; i++) {
             var ele = lookupForm.elements[i];
@@ -744,7 +761,7 @@ function lookupAjaxRequest(request) {
     lookupContent = (GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).contentRef);
     
     // get request arguments
-    var arg = request.substring(request.indexOf('?')+1,(request.length));
+    var arg = request.substring(request.indexOf('?')+1,(request.length));    
 
     new Ajax.Request(request, {
         method: 'post',

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=949710&r1=949709&r2=949710&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Mon May 31 10:33:52 2010
@@ -435,17 +435,17 @@ ${item.description}</span>
 <span class="field-lookup">
 <#if size?has_content && size=="0"><input type="hidden" <#if name?has_content> name="${name}"/></#if><#else><input type="text" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if id?has_content> id="${id}"</#if><#rt/><#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/><#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/></#if>
 <#if presentation?has_content && descriptionFieldName?has_content && presentation == "window">
- <a href="javascript:call_fieldlookup3(document.${formName?html}.${name?html}, document.${formName?html}.${descriptionFieldName},'${fieldFormName}'<#rt/>
+ <a href="javascript:call_fieldlookup3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}'<#rt/>
 <#elseif presentation?has_content && presentation == "window">
  <a href="javascript:call_fieldlookup2(document.${formName}.${name},'${fieldFormName}'<#rt/>
 <#elseif descriptionFieldName?has_content>
- <a href="javascript:call_fieldlookupLayer3(document.${formName?html}.${name?html}, document.${formName?html}.${descriptionFieldName},'${fieldFormName}','${width}','${height}','${position}', '${fadeBackground}'<#rt/>
+ <a href="javascript:call_fieldlookupLayer3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}','${width}','${height}','${position}','${fadeBackground}'<#rt/>
 <#else>
- <a href="javascript:call_fieldlookupLayer(document.${formName?html}.${name?html},'${fieldFormName}','${width}','${height}','${position}', '${fadeBackground}'<#rt/>
+ <a href="javascript:call_fieldlookupLayer(document.${formName?html}.${name?html},'${fieldFormName}','${width}','${height}','${position}','${fadeBackground}'<#rt/>
 </#if>
 <#if targetParameterIter?has_content>
  <#list targetParameterIter as item>
-  ,document.${formName}.${item}.value<#rt>
+,document.${formName}.${item}.value<#rt>
  </#list>
 </#if>
 );"></a><#rt>