Author: trong.tran
Date: 2011-11-03 04:08:39 -0400 (Thu, 03 Nov 2011)
New Revision: 7951
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js
Log:
GTNPORTAL-2255 Group Navigation management portlet would be able to fill up free space of
the page
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-11-03
08:02:27 UTC (rev 7950)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-11-03
08:08:39 UTC (rev 7951)
@@ -115,6 +115,7 @@
UIVirtualList virtualList = getChild(UIVirtualList.class);
virtualList.dataBind(new ObjectPageList<UserNavigation>(groupNav,
groupNav.size()));
+ virtualList.setAutoAdjustHeight(true);
}
public void setScope(Scope scope)
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-03
08:02:27 UTC (rev 7950)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIVirtualList.js 2011-11-03
08:08:39 UTC (rev 7951)
@@ -23,81 +23,74 @@
var uiVirtualList = document.getElementById(componentId);
if (uiVirtualList == null) return;
- var virtualHeight = 300;
-
- //If parent of virtualList have style.display = none --> can't get
virtualList's height
- var tmp = uiVirtualList;
- if (tmp.offsetHeight == 0) {
- tmp = uiVirtualList.cloneNode(true);
- tmp.style.visibility = "hidden";
- tmp.style.display = "block";
- document.body.appendChild(tmp);
+ if (!hasNext)
+ {
+ uiVirtualList.isFinished = true;
}
- if (eXo.core.DOMUtil.getStyle(tmp, "height")) {
- virtualHeight = tmp.offsetHeight;
- }
+ var virtualHeight = eXo.core.DOMUtil.getStyle(uiVirtualList, 'height', true);
+
+ if (virtualHeight == 0)
+ {
+ virtualHeight = 300;
+ }
+
uiVirtualList.style.height = virtualHeight + "px";
if (autoAdjustHeight)
{
+ uiVirtualList.autoAdjustHeight = autoAdjustHeight;
eXo.core.Browser.fillUpFreeSpace(uiVirtualList);
}
+
+ uiVirtualList.scrollTop = 0;
- var children = eXo.core.DOMUtil.getChildrenByTagName(tmp,"div");
- var childrenHeight = 0;
- for (var i=0; i<children.length;i++) {
- childrenHeight += children[i].offsetHeight;
- }
-
- if (tmp !== uiVirtualList) {
- document.body.removeChild(tmp);
- }
-
- if (childrenHeight <= uiVirtualList.offsetHeight)
+ this.loadIfNeeded(uiVirtualList);
+}
+
+UIVirtualList.prototype.loadIfNeeded = function(uiVirtualList)
+{
+ if (uiVirtualList.clientHeight == uiVirtualList.scrollHeight)
{
- if (hasNext && childrenHeight != 0)
+ if (uiVirtualList.isFinished)
{
- uiVirtualList.onscroll();
- }
- else
- {
- uiVirtualList.isFinished = true;
- if (autoAdjustHeight)
+ if (uiVirtualList.autoAdjustHeight)
{
uiVirtualList.style.height = "auto";
}
}
+ else
+ {
+ uiVirtualList.onscroll();
+ }
}
- uiVirtualList.isInitiated = true;
- uiVirtualList.scrollTop = 0;
}
UIVirtualList.prototype.getFeedBox = function(componentId) {
- var DOMUtil = eXo.core.DOMUtil;
- var uiVirtualList = document.getElementById(componentId);
- var feedBox = DOMUtil.findFirstDescendantByClass(uiVirtualList,
"div","FeedBox");
- if (feedBox == null) {
- feedBox = DOMUtil.findFirstDescendantByClass(uiVirtualList,
"tbody","FeedBox");
- }
- return feedBox;
+ var DOMUtil = eXo.core.DOMUtil;
+ var uiVirtualList = document.getElementById(componentId);
+ var feedBox = DOMUtil.findFirstDescendantByClass(uiVirtualList,
"div","FeedBox");
+ if (feedBox == null) {
+ feedBox = DOMUtil.findFirstDescendantByClass(uiVirtualList,
"tbody","FeedBox");
+ }
+ return feedBox;
}
UIVirtualList.prototype.onScroll = function(uiVirtualList, url) {
- if (uiVirtualList.isFinished || uiVirtualList.isLocked) return;
- var DOMUtil = eXo.core.DOMUtil;
- var componentHeight = uiVirtualList.offsetHeight;
- var scrollPosition = uiVirtualList.scrollTop;
- var scrollerHeight = uiVirtualList.scrollHeight;
- var scrollable_gap = scrollerHeight - (scrollPosition + componentHeight);
- // if scrollbar reaches bottom
- if (scrollable_gap <= 1) {
- var feedBox = this.getFeedBox(uiVirtualList.id);
- var appendHTML = feedBox.innerHTML;
- uiVirtualList.storeHTML = appendHTML;
- uiVirtualList.isLocked = true;
- ajaxGet(url);
- }
+ if (uiVirtualList.isFinished || uiVirtualList.inProgress) return;
+ var DOMUtil = eXo.core.DOMUtil;
+ var componentHeight = uiVirtualList.offsetHeight;
+ var scrollPosition = uiVirtualList.scrollTop;
+ var scrollerHeight = uiVirtualList.scrollHeight;
+ var scrollable_gap = scrollerHeight - (scrollPosition + componentHeight);
+ // if scrollbar reaches bottom
+ if (scrollable_gap <= 1) {
+ var feedBox = this.getFeedBox(uiVirtualList.id);
+ var html = feedBox.innerHTML;
+ uiVirtualList.backupHTML = html;
+ uiVirtualList.inProgress = true;
+ ajaxGet(url);
+ }
}
UIVirtualList.prototype.updateList = function(componentId, hasNext) {
@@ -111,21 +104,20 @@
}
var feedBox = this.getFeedBox(uiVirtualList.id);
- var loadedContent = uiVirtualList.storeHTML;
+ var loadedContent = uiVirtualList.backupHTML;
if (eXo.core.Browser.browserType != "ie") {
- feedBox.innerHTML = loadedContent + feedBox.innerHTML;
- } else {
- var index = uiVirtualList.innerHTML.indexOf(feedBox.className);
- index = uiVirtualList.innerHTML.indexOf(">", index) + 1;
- var firstSec = uiVirtualList.innerHTML.substring(0, index);
- var secondSec = uiVirtualList.innerHTML.substring(index);
- uiVirtualList.innerHTML = firstSec + loadedContent + secondSec;
+ feedBox.innerHTML = loadedContent + feedBox.innerHTML;
+ } else {
+ var index = uiVirtualList.innerHTML.indexOf(feedBox.className);
+ index = uiVirtualList.innerHTML.indexOf(">", index) + 1;
+ var firstSec = uiVirtualList.innerHTML.substring(0, index);
+ var secondSec = uiVirtualList.innerHTML.substring(index);
+ uiVirtualList.innerHTML = firstSec + loadedContent + secondSec;
}
- uiVirtualList.isLocked = false;
- if (!uiVirtualList.isFinished && !uiVirtualList.isInitiated) {
- this.init(componentId);
- }
+ uiVirtualList.inProgress = false;
+
+ this.loadIfNeeded(uiVirtualList);
}
eXo.webui.UIVirtualList = new UIVirtualList();