diff --git a/framework/example/widget/example/FormWidgetExampleForms.xml b/framework/example/widget/example/FormWidgetExampleForms.xml index 741a4f0d0a..23ce75b203 100644 --- a/framework/example/widget/example/FormWidgetExampleForms.xml +++ b/framework/example/widget/example/FormWidgetExampleForms.xml @@ -285,7 +285,7 @@ under the License. - +
diff --git a/framework/images/webapp/images/fieldlookup.js b/framework/images/webapp/images/fieldlookup.js index a628b1eb02..5cdb1ebb84 100644 --- a/framework/images/webapp/images/fieldlookup.js +++ b/framework/images/webapp/images/fieldlookup.js @@ -45,7 +45,7 @@ function call_fieldlookup(target, viewName, formName, viewWidth, viewheight) { if (! viewheight) viewheight = 200; fieldLookup.popup(viewName, formName, viewWidth, viewheight); } -function call_fieldlookupLayer(target, viewName, lookupWidth, lookupHeight, lookupPosition) { +function call_fieldlookupLayer(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground) { if (isEmpty(target) || isEmpty(viewName)) { return lookup_error("Lookup can't be created, one of these variables is missing: target=" + target + " viewName=" + viewName); } @@ -56,12 +56,12 @@ function call_fieldlookupLayer(target, viewName, lookupWidth, lookupHeight, look return; } } - var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition); + var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground); fieldLookupPopup.showLookup(); this.target = target; } -function call_fieldlookupLayer3(target, target2, viewName, lookupWidth, lookupHeight, lookupPosition) { +function call_fieldlookupLayer3(target, target2, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground) { 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); } @@ -72,7 +72,7 @@ function call_fieldlookupLayer3(target, target2, viewName, lookupWidth, lookupHe return; } } - var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition); + var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground); fieldLookupPopup.showLookup(); this.target = target; this.target2 = target2; @@ -185,13 +185,17 @@ function close_on_click(evt) { * position - normal (under the target field), center (layer is centered) [default: normal] -- !work still in process */ var FieldLookupPopup = Class.create({ - initialize: function (target, viewName, lookupWidth, lookupHeight, position) { + initialize: function (target, viewName, lookupWidth, lookupHeight, position, fadeBackground) { //removes a existing Lookup if (CURRENT_LOOKUP != null) { CURRENT_LOOKUP.removeLayer(); } + //fade the background if the flag is set + if (fadeBackground) { + this.createFadedBackground(); + } //set dimension isn't set, set default parameters if (isEmpty(lookupWidth)) { lookupWidth = '700px'; @@ -296,7 +300,23 @@ var FieldLookupPopup = Class.create({ } }); }, + + createFadedBackground: function(){ + //remove the faded Background if exists + var fb = $('fadedBackground') + if (fb != null) { + fb.parentNode.removeChild(fb); + } + var pageSize = this.getPageSize(); + var fadedBackground = new Element ('DIV', { + id: "fadedBackground", + style: "width: " + pageSize[0] + "px; height: " + pageSize[1] + "px;" + }); + + document.body.appendChild(fadedBackground); + }, + setPosition: function (lookupDiv) { //set layer position var bdy = document.body; @@ -384,8 +404,62 @@ var FieldLookupPopup = Class.create({ Element.stopObserving(document, "keypress"); Element.stopObserving(document, "mousedown"); CURRENT_LOOKUP.divRef.parentNode.removeChild(CURRENT_LOOKUP.divRef); + //remove the faded Background if exists + var fb = $('fadedBackground') + if (fb != null){ + fb.parentNode.removeChild(fb); + } CURRENT_LOOKUP = null; this.target = null; + }, + + getPageSize: function() { + + var xScroll, yScroll; + + if (window.innerHeight && window.scrollMaxY) { + xScroll = window.innerWidth + window.scrollMaxX; + yScroll = window.innerHeight + window.scrollMaxY; + } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac + xScroll = document.body.scrollWidth; + yScroll = document.body.scrollHeight; + } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari + xScroll = document.body.offsetWidth; + yScroll = document.body.offsetHeight; + } + + var windowWidth, windowHeight; + + if (self.innerHeight) { // all except Explorer + if (document.documentElement.clientWidth){ + windowWidth = document.documentElement.clientWidth; + } else { + windowWidth = self.innerWidth; + } + windowHeight = self.innerHeight; + } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode + windowWidth = document.documentElement.clientWidth; + windowHeight = document.documentElement.clientHeight; + } else if (document.body) { // other Explorers + windowWidth = document.body.clientWidth; + windowHeight = document.body.clientHeight; + } + + // for small pages with total height less then height of the viewport + if (yScroll < windowHeight){ + pageHeight = windowHeight; + } else { + pageHeight = yScroll; + } + + // for small pages with total width less then width of the viewport + if (xScroll < windowWidth){ + pageWidth = xScroll; + } else { + pageWidth = windowWidth; + } + + return [pageWidth,pageHeight]; } }); diff --git a/framework/widget/dtd/widget-form.xsd b/framework/widget/dtd/widget-form.xsd index 3b97cc45a7..19c93ba5af 100644 --- a/framework/widget/dtd/widget-form.xsd +++ b/framework/widget/dtd/widget-form.xsd @@ -938,6 +938,15 @@ under the License. + + True = The Background will be faded. + + + + + + + diff --git a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java index 7bac3a23a5..b9a92bc62a 100644 --- a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java @@ -1953,6 +1953,11 @@ public class MacroFormRenderer implements FormStringRenderer { lookupPosition = ""; } + String fadeBackground = lookupField.getFadeBackground(); + if (UtilValidate.isEmpty(fadeBackground)){ + fadeBackground = "false"; + } + StringWriter sr = new StringWriter(); sr.append("<@renderLookupField "); sr.append(" className=\""); @@ -2004,6 +2009,8 @@ public class MacroFormRenderer implements FormStringRenderer { sr.append(lookupWidth); sr.append("\" lookupPosition=\""); sr.append(lookupPosition); + sr.append("\" fadeBackground=\""); + sr.append(fadeBackground); sr.append("\" />"); executeMacro(sr.toString()); diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java index 9a764723bf..4fcb272374 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java @@ -3475,6 +3475,7 @@ public class ModelFormField { protected String lookupWidth; protected String lookupHeight; protected String lookupPosition; + protected String fadeBackground; public LookupField(Element element, ModelFormField modelFormField) { super(element, modelFormField); @@ -3485,6 +3486,7 @@ public class ModelFormField { this.lookupHeight = element.getAttribute("height"); this.lookupWidth = element.getAttribute("width"); this.lookupPosition = element.getAttribute("position"); + this.fadeBackground = element.getAttribute("fade-background"); Element subHyperlinkElement = UtilXml.firstChildElement(element, "sub-hyperlink"); if (subHyperlinkElement != null) { @@ -3564,6 +3566,14 @@ public class ModelFormField { public void setLookupPosition(String str) { this.lookupPosition = str; } + + public String getFadeBackground() { + return this.fadeBackground; + } + + public void setFadeBackground(String str) { + this.fadeBackground = str; + } } public static class FileField extends TextField { diff --git a/framework/widget/templates/csvFormMacroLibrary.ftl b/framework/widget/templates/csvFormMacroLibrary.ftl index 4782576036..dc23cd23fb 100644 --- a/framework/widget/templates/csvFormMacroLibrary.ftl +++ b/framework/widget/templates/csvFormMacroLibrary.ftl @@ -103,7 +103,7 @@ under the License. <@renderField value /> -<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition> +<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition fadeBackground> <#macro renderNextPrev paginateStyle paginateFirstStyle viewIndex highIndex listSize viewSize ajaxEnabled javaScriptEnabled ajaxFirstUrl firstUrl paginateFirstLabel paginatePreviousStyle ajaxPreviousUrl previousUrl paginatePreviousLabel pageLabel ajaxSelectUrl selectUrl ajaxSelectSizeUrl selectSizeUrl commonDisplaying paginateNextStyle ajaxNextUrl nextUrl paginateNextLabel paginateLastStyle ajaxLastUrl lastUrl paginateLastLabel paginateViewSizeLabel> <#macro renderFileField className alert name value size maxlength autocomplete><@renderField value /> <#macro renderPasswordField className alert name value size maxlength id autocomplete> diff --git a/framework/widget/templates/foFormMacroLibrary.ftl b/framework/widget/templates/foFormMacroLibrary.ftl index e25b1958b3..1a5b85e027 100644 --- a/framework/widget/templates/foFormMacroLibrary.ftl +++ b/framework/widget/templates/foFormMacroLibrary.ftl @@ -122,7 +122,7 @@ under the License. <@makeBlock className value /> -<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition> +<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition fadeBackground> <#macro renderNextPrev paginateStyle paginateFirstStyle viewIndex highIndex listSize viewSize ajaxEnabled javaScriptEnabled ajaxFirstUrl firstUrl paginateFirstLabel paginatePreviousStyle ajaxPreviousUrl previousUrl paginatePreviousLabel pageLabel ajaxSelectUrl selectUrl ajaxSelectSizeUrl selectSizeUrl commonDisplaying paginateNextStyle ajaxNextUrl nextUrl paginateNextLabel paginateLastStyle ajaxLastUrl lastUrl paginateLastLabel paginateViewSizeLabel> <#macro renderFileField className alert name value size maxlength autocomplete><@makeBlock className value /> <#macro renderPasswordField className alert name value size maxlength id autocomplete><@makeBlock className "" /> diff --git a/framework/widget/templates/htmlFormMacroLibrary.ftl b/framework/widget/templates/htmlFormMacroLibrary.ftl index 7bade38139..863a780426 100644 --- a/framework/widget/templates/htmlFormMacroLibrary.ftl +++ b/framework/widget/templates/htmlFormMacroLibrary.ftl @@ -431,11 +431,11 @@ ${item.description} -<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition> +<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName lookupFieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled lookupPresentation lookupWidth lookupHeight lookupPosition fadeBackground>
    <#if size?has_content && size="0">
  • name="${name}"/>
  • <#else>
  • <#if name?has_content> name="${name}"<#if value?has_content> value="${value}"<#if size?has_content> size="${size}"<#if maxlength?has_content> maxlength="${maxlength}"<#if id?has_content> id="${id}"<#rt/><#if disabled?has_content && disabled> disabled="disabled"<#rt/><#if event?has_content && action?has_content> ${event}="${action}"<#rt/><#if autocomplete?has_content> autocomplete="off"/><#rt/>
  • <#if lookupPresentation?has_content && descriptionFieldName?has_content && lookupPresentation == "layer"> - <#elseif lookupPresentation?has_content && lookupPresentation == "layer">