Author: haint
Date: 2011-11-02 03:13:00 -0400 (Wed, 02 Nov 2011)
New Revision: 7924
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageManagementPortlet.java
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/Browser.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/UIPortalApplicationSkin.css
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
Log:
GTNPORTAL-2248 Page Management is too short
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageManagementPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageManagementPortlet.java 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageManagementPortlet.java 2011-11-02
07:13:00 UTC (rev 7924)
@@ -19,10 +19,11 @@
package org.exoplatform.navigation.webui.component;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.portal.webui.page.UIPageBrowser;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.core.UIPortletApplication;
+import org.exoplatform.webui.core.UIVirtualList;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
/**
@@ -36,8 +37,13 @@
@Serialized
public class UIPageManagementPortlet extends UIPortletApplication
{
+ public static String PAGE_LIST_HEIGHT = "pageListHeight";
+
public UIPageManagementPortlet() throws Exception
{
- addChild(UIPageBrowser.class, null, null).setShowAddNewPage(true);
+ UIPageBrowser pageBrowser = addChild(UIPageBrowser.class, null, null);
+ pageBrowser.setShowAddNewPage(true);
+ UIVirtualList virtualList = pageBrowser.getChild(UIVirtualList.class);
+ virtualList.setAutoAdjustHeight(true);
}
}
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/Browser.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/Browser.js 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/Browser.js 2011-11-02
07:13:00 UTC (rev 7924)
@@ -539,6 +539,32 @@
if(document.getElementById("UIPageDesktop")) return true ;
return false ;
}
+
+/**
+ * Return the height of free space in the page if it is available.
+ * Otherwise, returns a negative which is equal to the height of content not visible on
the screen.
+ */
+Browser.prototype.getHeightOfFreeSpace = function() {
+ var elements = document.body.children;
+ var height = 0;
+ var ln = elements.length ;
+ for(var k = 0; k < ln; k++) {
+ height += elements[k].offsetHeight ;
+ }
+ return (this.getBrowserHeight() - height);
+}
+
+/**
+ * Adjust height of the element to fill up free space if any
+ */
+Browser.prototype.fillUpFreeSpace = function(elemt) {
+ var height = eXo.core.Browser.getHeightOfFreeSpace();
+ if (height > 0)
+ {
+ height += elemt.offsetHeight;
+ elemt.style.height = height + "px";
+ }
+}
/************************************************************************************/
eXo.core.Browser = new Browser() ;
-eXo.core.Mouse = new MouseObject() ;
\ No newline at end of file
+eXo.core.Mouse = new MouseObject() ;
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js 2011-11-02
07:13:00 UTC (rev 7924)
@@ -19,20 +19,31 @@
function UIVirtualList() {}
-UIVirtualList.prototype.init = function(componentId) {
+UIVirtualList.prototype.init = function(componentId, hasNext, autoAdjustHeight) {
var uiVirtualList = document.getElementById(componentId);
if (uiVirtualList == null) return;
- uiVirtualList.style.height = "300px";
+ var virtualHeight = 300;
+
//If parent of virtualList have style.display = none --> can't get
virtualList's height
var tmp = uiVirtualList;
- if (uiVirtualList.offsetHeight == 0) {
+ if (tmp.offsetHeight == 0) {
tmp = uiVirtualList.cloneNode(true);
tmp.style.visibility = "hidden";
+ tmp.style.display = "block";
document.body.appendChild(tmp);
}
- var virtualHeight = tmp.offsetHeight;
+ if (eXo.core.DOMUtil.getStyle(tmp, "height")) {
+ virtualHeight = tmp.offsetHeight;
+ }
+ uiVirtualList.style.height = virtualHeight + "px";
+
+ if (autoAdjustHeight)
+ {
+ eXo.core.Browser.fillUpFreeSpace(uiVirtualList);
+ }
+
var children = eXo.core.DOMUtil.getChildrenByTagName(tmp,"div");
var childrenHeight = 0;
for (var i=0; i<children.length;i++) {
@@ -43,12 +54,23 @@
document.body.removeChild(tmp);
}
- if (!uiVirtualList.isFinished && childrenHeight <= virtualHeight &&
childrenHeight != 0) {
- uiVirtualList.onscroll();
- } else {
- uiVirtualList.isInitiated = true;
- uiVirtualList.scrollTop = 0;
+ if (childrenHeight <= uiVirtualList.offsetHeight)
+ {
+ if (hasNext && childrenHeight != 0)
+ {
+ uiVirtualList.onscroll();
+ }
+ else
+ {
+ uiVirtualList.isFinished = true;
+ if (autoAdjustHeight)
+ {
+ uiVirtualList.style.height = "auto";
+ }
+ }
}
+ uiVirtualList.isInitiated = true;
+ uiVirtualList.scrollTop = 0;
}
UIVirtualList.prototype.getFeedBox = function(componentId) {
@@ -61,7 +83,7 @@
return feedBox;
}
-UIVirtualList.prototype.scrollMove = function(uiVirtualList, url) {
+UIVirtualList.prototype.onScroll = function(uiVirtualList, url) {
if (uiVirtualList.isFinished || uiVirtualList.isLocked) return;
var DOMUtil = eXo.core.DOMUtil;
var componentHeight = uiVirtualList.offsetHeight;
@@ -78,11 +100,16 @@
}
}
-UIVirtualList.prototype.updateList = function(componentId) {
+UIVirtualList.prototype.updateList = function(componentId, hasNext) {
var DOMUtil = eXo.core.DOMUtil;
-var uiVirtualList = document.getElementById(componentId);
+ var uiVirtualList = document.getElementById(componentId);
if (uiVirtualList == null) return;
+ if (!hasNext)
+ {
+ uiVirtualList.isFinished = true;
+ }
+
var feedBox = this.getFeedBox(uiVirtualList.id);
var loadedContent = uiVirtualList.storeHTML;
@@ -101,10 +128,4 @@
}
}
-UIVirtualList.prototype.loadFinished = function(componentId) {
- var uiVirtualList = document.getElementById(componentId);
- if (uiVirtualList == null) return;
- uiVirtualList.isFinished = true;
-}
-
-eXo.webui.UIVirtualList = new UIVirtualList();
\ No newline at end of file
+eXo.webui.UIVirtualList = new UIVirtualList();
Modified:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/UIPortalApplicationSkin.css
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/UIPortalApplicationSkin.css 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/UIPortalApplicationSkin.css 2011-11-02
07:13:00 UTC (rev 7924)
@@ -161,4 +161,8 @@
.ClearBoth {
clear: both;
-}
\ No newline at end of file
+}
+
+.UIVirtualList {
+ height: 300px;
+}
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-11-02
07:13:00 UTC (rev 7924)
@@ -191,20 +191,29 @@
<%
} else {
if(windowState != WindowState.MINIMIZED) {
- String windowWidth = uicomponent.getWidth();
- if(windowWidth!= null && !windowWidth.contains("%") &&
!windowWidth.contains("px")) windowWidth += "px";
- String windowHeight = uicomponent.getHeight();
- if(windowHeight != null && !windowHeight.contains("%") &&
!windowHeight.contains("px")) windowHeight += "px";
- String cssStyle = "style=\"";
- cssStyle += "width: "+ windowWidth +";";
- cssStyle += "height: "+ windowHeight +";";
- cssStyle += "\"";
-%>
- <div id="<%=portalMode == UIPortalApplication.NORMAL_MODE ? portletId :
"EditMode-"+ portletId%>">
- <div class="PORTLET-FRAGMENT" ${cssStyle}>
- <%
- if(hasPermission) println portletContent;
- else println "<div
class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
+ String cssStyle = "";
+ String windowWidth = uicomponent.getWidth();
+ if(windowWidth!= null && !windowWidth.contains("%") &&
!windowWidth.contains("px"))
+ {
+ cssStyle += "width: "+ windowWidth +"px;";
+ }
+ String windowHeight = uicomponent.getHeight();
+ if(windowHeight != null && !windowHeight.contains("%") &&
!windowHeight.contains("px"))
+ {
+ cssStyle += "height: "+ windowHeight +"px;";
+ }
+ %>
+ <div id="<%=portalMode == UIPortalApplication.NORMAL_MODE ? portletId :
"EditMode-"+ portletId%>">
+ <div class="PORTLET-FRAGMENT" style="${cssStyle}">
+ <%
+ if(hasPermission)
+ {
+ println portletContent;
+ }
+ else
+ {
+ println "<div
class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
+ }
%>
</div>
</div>
@@ -243,4 +252,4 @@
</div>
</div>
</div>
-<%}%>
\ No newline at end of file
+<%}%>
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl 2011-11-02
07:13:00 UTC (rev 7924)
@@ -3,6 +3,7 @@
import org.exoplatform.webui.bean.UIDataFeed;
boolean hasNext = uicomponent.getDataFeed().hasNext();
+ boolean isAutoAdjustHeight = uicomponent.isAutoAdjustHeight();
def rcontext = _ctx.getRequestContext();
rcontext.getJavascriptManager().importJavascript('eXo.core.DOMUtil');
@@ -10,17 +11,15 @@
rcontext.getJavascriptManager().importJavascript('eXo.webui.UIVirtualList');
String url = uicomponent.url("LoadNext") +
"&ajaxRequest=true";
+ String css = "";
+ if (uicomponent.getHeight() > 0) {
+ css = "height: " + uicomponent.getHeight() + "px";
+ }
%>
-<div id="$uicomponent.id" style="overflow:auto;"
- onscroll="eXo.webui.UIVirtualList.scrollMove(this,'$url');">
- <div>
- <% uicomponent.renderChildren();%>
- </div>
+<div id="$uicomponent.id" class="UIVirtualList"
style="overflow:auto; $css"
+ onscroll="eXo.webui.UIVirtualList.onScroll(this,'$url');">
+ <% uicomponent.renderChildren();%>
<%
- if (!hasNext) {
-
rcontext.getJavascriptManager().addJavascript("eXo.webui.UIVirtualList.loadFinished('$uicomponent.id');");
- }
-
rcontext.getJavascriptManager().addJavascript("eXo.webui.UIVirtualList.init('$uicomponent.id');");
-
+
rcontext.getJavascriptManager().addJavascript("eXo.webui.UIVirtualList.init('$uicomponent.id',
$hasNext, $isAutoAdjustHeight);");
%>
-</div>
\ No newline at end of file
+</div>
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2011-11-02
07:13:00 UTC (rev 7924)
@@ -35,6 +35,10 @@
{
private int pageSize = 1;
+
+ private int height;
+
+ private boolean autoAdjustHeight;
public int getPageSize()
{
@@ -45,6 +49,26 @@
{
this.pageSize = pageSize;
}
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
+
+ public boolean isAutoAdjustHeight()
+ {
+ return autoAdjustHeight;
+ }
+
+ public void setAutoAdjustHeight(boolean auto)
+ {
+ this.autoAdjustHeight = auto;
+ }
public String event(String name, String beanId) throws Exception
{
@@ -89,13 +113,17 @@
return;
}
- if (!dataFeed.hasNext())
+ if (dataFeed.hasNext())
{
rContext.getJavascriptManager().addJavascript(
- "eXo.webui.UIVirtualList.loadFinished('" +
virtualList.getId() + "');");
+ "eXo.webui.UIVirtualList.updateList('" + virtualList.getId()
+ "', true);");
}
- rContext.getJavascriptManager().addJavascript(
- "eXo.webui.UIVirtualList.updateList('" + virtualList.getId() +
"');");
+ else
+ {
+ rContext.getJavascriptManager().addJavascript(
+ "eXo.webui.UIVirtualList.updateList('" + virtualList.getId()
+ "', false);");
+ }
+
rContext.addUIComponentToUpdateByAjax((UIComponent)dataFeed);
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-11-02
04:56:04 UTC (rev 7923)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-11-02
07:13:00 UTC (rev 7924)
@@ -23,8 +23,6 @@
import java.util.List;
import java.util.ResourceBundle;
-import javassist.bytecode.analysis.Type;
-
import javax.portlet.ActionResponse;
import javax.xml.namespace.QName;
@@ -71,18 +69,10 @@
import org.exoplatform.webui.event.Event.Phase;
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormInputItemSelector;
import org.exoplatform.webui.form.UIFormInputSet;
import org.exoplatform.webui.form.UIFormSelectBox;
import org.exoplatform.webui.form.UIFormStringInput;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import javax.portlet.ActionResponse;
-import javax.xml.namespace.QName;
-
@ComponentConfigs({
@ComponentConfig(template =
"system:/groovy/portal/webui/page/UIPageBrowser.gtmpl", events = {
@EventConfig(listeners = UIPageBrowser.DeleteActionListener.class, confirm =
"UIPageBrowse.deletePage"),
@@ -230,7 +220,7 @@
{
this.showAddNewPage = showAddNewPage;
}
-
+
public void processDecode(WebuiRequestContext context) throws Exception
{
super.processDecode(context);