svn commit: r668342 - in /ofbiz/trunk/framework: images/webapp/images/selectall.js widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r668342 - in /ofbiz/trunk/framework: images/webapp/images/selectall.js widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

adrianc
Author: adrianc
Date: Mon Jun 16 16:11:14 2008
New Revision: 668342

URL: http://svn.apache.org/viewvc?rev=668342&view=rev
Log:
Bug fix for collapsible screenlet in JavaScript mode. It now updates pagination links so the collapsible state change is carried across pagination screen refreshes.

IE has a problem with the page select dropdown after a screenlet collapsible state change. I'm still working on that.

Modified:
    ofbiz/trunk/framework/images/webapp/images/selectall.js
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=668342&r1=668341&r2=668342&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/selectall.js Mon Jun 16 16:11:14 2008
@@ -321,8 +321,57 @@
     Effect.toggle(container, 'appear');
 }
 
+/** Toggle screenlet visibility on/off.
+  * @param link The <a> element calling this function
+  * @param areaId The id of the HTML container to toggle
+  * @param expandTxt Localized 'Expand' text
+  * @param collapseTxt Localized 'Collapse' text
+*/
+function toggleScreenlet(link, areaId, expandTxt, collapseTxt){
+    toggleCollapsiblePanel(link, areaId, expandTxt, collapseTxt);
+    var container = $(areaId);
+    var screenlet = container.up('div');
+    if(container.visible()){
+        var currentParam = screenlet.id + "_collapsed=false";
+        var newParam = screenlet.id + "_collapsed=true";
+    } else {
+        var currentParam = screenlet.id + "_collapsed=true";
+        var newParam = screenlet.id + "_collapsed=false";
+    }
+    var paginationMenus = $$('div.nav-pager');
+    paginationMenus.each(function(menu) {
+        if (menu) {
+            var childElements = menu.getElementsByTagName('a');
+            for (var i = 0; i < childElements.length; i++) {
+                childElements[i].href = replaceQueryParam(childElements[i].href, currentParam, newParam);
+            }
+            childElements = menu.getElementsByTagName('select');
+            for (i = 0; i < childElements.length; i++) {
+                Element.extend(childElements[i]);
+                childElements[i].writeAttribute("onchange", replaceQueryParam(childElements[i].readAttribute("onchange"), currentParam, newParam));
+            }
+        }
+    });    
+}
+
 // ===== End of Ajax Functions ===== //
 
+function replaceQueryParam(queryString, currentParam, newParam) {
+    var result = queryString.replace(currentParam, newParam);
+    if (result.indexOf(newParam) < 0) {
+        if (result.indexOf("?") < 0) {
+            result = result + "?" + newParam;
+        } else if (result.endsWith("#")) {
+            result = result.replace("#", "&" + newParam + "#");
+        } else if (result.endsWith(";")) {
+            result = result.replace(";", " + '&" + newParam + "';");
+        } else {
+            result = result + "&" + newParam;
+        }
+    }
+    return result;
+}
+
 function submitFormDisableSubmits(form) {
     for (var i=0;i<form.length;i++) {
         var formel = form.elements[i];

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=668342&r1=668341&r2=668342&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Mon Jun 16 16:11:14 2008
@@ -177,7 +177,7 @@
                 if (collapsed) {
                     writer.append("collapsed\"><a ");
                     if (javaScriptEnabled) {
-                        writer.append("onclick=\"javascript:toggleCollapsiblePanel(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\"");
+                        writer.append("onclick=\"javascript:toggleScreenlet(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\"");
                     } else {
                         requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "false");
                         String queryString = UtilHttp.urlEncodeArgs(requestParameters);
@@ -189,7 +189,7 @@
                 } else {
                     writer.append("expanded\"><a ");
                     if (javaScriptEnabled) {
-                        writer.append("onclick=\"javascript:toggleCollapsiblePanel(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\"");
+                        writer.append("onclick=\"javascript:toggleScreenlet(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\"");
                     } else {
                         requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "true");
                         String queryString = UtilHttp.urlEncodeArgs(requestParameters);